-
Notifications
You must be signed in to change notification settings - Fork 726
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add initial NodOn SIN-4-FP-21 (Adeo SIN-4-FP-21_EQU) quirk #3364
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #3364 +/- ##
==========================================
+ Coverage 89.72% 89.74% +0.02%
==========================================
Files 319 320 +1
Lines 10348 10370 +22
==========================================
+ Hits 9285 9307 +22
Misses 1063 1063 ☔ View full report in Codecov by Sentry. |
64cbe5e
to
62418ea
Compare
ed08401
to
228e8a9
Compare
@TheJulianJES I've re-pushed commits to use the v2 interface of If you think tests are necessary here, please give me an example of any test that uses the v2 interface. |
9ab2186
to
a69894d
Compare
Any news on this? I would love this to be merged, I myself own a bunch of those modules. |
Please validate. I need this quirk as well |
@TheJulianJES, I have a question. I didn't find a better place to ask it. There is a slight problem with this quirk. An entity added to HA gets the '_none' suffix (see attached picture). I would expect it to get the '_pilot_wire_mode' suffix. Of course, one can rename the HA entity, but getting it right from the start is better. I did a lot of debugging on my side but got lost, to be honest. I see that the ZHA objects receive the correct This problem is not only with an enum but also with a configuration number. I'm preparing a PR to allow configuring impulse mode on NodOn switches (similar to this). My entity also has the I'd appreciate your help or guidance. P.S. With no success, I've tried setting |
a69894d
to
6c1f551
Compare
The |
Thank you for the answer. Can you point out where I should add it in HA? I want to try it locally. I will change HA's code in my installation. |
Hi @ikruglov thank you so much for this merge request. I'm waiting for it ! @TheJulianJES do you have any idea where this translation key is located, so that @ikruglov could test his code ? |
606521e
to
a973655
Compare
Hi @ikruglov, |
Try this : """NODON module for custom device handlers."""
from zigpy.quirks import CustomCluster
from zigpy.quirks.v2 import EntityType, QuirkBuilder
import zigpy.types as t
from zigpy.zcl.foundation import (
BaseAttributeDefs,
BaseCommandDefs,
DataTypeId,
Direction,
ZCLAttributeDef,
ZCLCommandDef,
)
class NodOnPilotWireMode(t.enum8):
"""Pilot wire mode."""
OFF = 0x00
COMFORT = 0x01
ECO = 0x02
FROST_PROTECTION = 0x03
COMFORT_MINUS_1 = 0x04
COMFORT_MINUS_2 = 0x05
NODON = "NodOn"
NODON_PILOT_WIRE_CLUSTER_ID = 0xFC00 # 64512
class NodOnPilotWireCluster(CustomCluster):
"""NodOn manufacturer specific cluster to set Pilot Wire mode."""
name: str = "NodOnPilotWireCluster"
cluster_id: t.uint16_t = NODON_PILOT_WIRE_CLUSTER_ID
ep_attribute: str = "nodon_pilot_wire_cluster"
class AttributeDefs(BaseAttributeDefs):
"""Attribute definitions."""
pilot_wire_mode = ZCLAttributeDef(
id=0x0000,
type=NodOnPilotWireMode,
zcl_type=DataTypeId.uint8,
is_manufacturer_specific=True,
)
class ServerCommandDefs(BaseCommandDefs):
"""Server command definitions."""
set_pilot_wire_mode = ZCLCommandDef(
id=0x00,
schema={"mode": NodOnPilotWireMode},
direction=Direction.Client_to_Server,
is_manufacturer_specific=True,
)
(
QuirkBuilder(NODON, "SIN-4-FP-21")
.replaces(NodOnPilotWireCluster)
.enum(
attribute_name=NodOnPilotWireCluster.AttributeDefs.pilot_wire_mode.name,
enum_class=NodOnPilotWireMode,
cluster_id=NodOnPilotWireCluster.cluster_id,
entity_type=EntityType.STANDARD,
translation_key="pilot_wire",
fallback_name="Pilot Wire",
)
.add_to_registry()
) |
@Mookunicorn this time, I get no error in the logs, but my SIN-4-FP-21 module still shows a on/off switch, no modes alternative. |
@Mookunicorn Naming the python file |
But it looks like my heater does not support other modes, or the module fails to interpret the commands sent :( |
Make sure that you got file names right. pilot_wire.py can't import classes from init.py (note there is double underscore on each size of 'init'). |
Hello @ikruglov, |
@ikruglov In fact, placing the quirk in the correct path made everything work as expected. I'm now a happy 6 modes pilot wire user :) |
@TheJulianJES I've addressed your suggestions except for the enum. Let me know what you want to see there. |
After some discussion, we might need to implement it as a climate entity, similar to the screenshots seen in the description of #3031. Since we can't expose climate devices via quirks v2, we'd need to partly implement this in ZHA. I'm aware this is annoying, but can we remove the enum/select entity for now? |
Per my previous comment, I've removed the enum entity for now. It needs to be discussed how the heating mode is handled: presets in a HA climate entity or just a select entity like Zigbee2MQTT provides for devices like this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And of course, thanks for the PR!
I hope we can implement an entity for the wire mode soon. For now, you'll at least have some initial support by directly writing to the attribute.
Opened the following issue for tracking and so this is not forgotten about: |
@TheJulianJES. Thanks for merging, but it's unfortunate that you removed the enum as it makes automation harder. I'm willing to investigate necessary changes in HA if you can tell me what is needed and give me some guidance. |
It also really wasn't what I wanted, but we have to make sure to adhere to Home Assistant standards. We'll follow up in the issue on what to do next. Just thought it would be useful to get some initial support for the attribute at least. Quirks v2 adding entities is relatively new and it's uncommon for something like this to work with HA. We just have to double check we're doing everything correctly. |
many thanks @ikruglov for proposing this PR. I am currently using the quirk defined in this comment. I don't get what will happen when my home-assistant container will be upgraded to the december version: |
@ofthesun9, it depends on how you set it up. I run HA in a docker container and mount modified files on top of original ones. So, in this case, there will be no change. If your setup is different I can't comment then. |
You can keep using the custom quirk with the select entity. from zigpy.quirks import DEVICE_REGISTRY
# other existing imports from custom quirk
# remove upstream quirk from registry
del DEVICE_REGISTRY._registry_v2[("NodOn", "SIN-4-FP-21")]
# original custom quirk code here For more details on the issue, see: zigpy/zigpy#1508 (This is not required if the original library files are modified, but that's not as easy to do and could break things. The custom quirks config + path is recommended in general.) |
thanks @TheJulianJES and @ikruglov for your help. Enabling custom quirks in config/configuration.yaml
Adding two files in config/custom_zha_quirks/nodon
|
Thank you, nice and clean workaround waiting for full upstream integration :) |
Proposed change
This PR adds a quirk for SIN-4-FP-21 (PilotWire). The device reports itself as a SmartPlug but it has special manufacturer-specific cluster which allows setting the following modes:
Additional information
Important
The HA entity shown below is not yet implemented with this version.
See this comment for more information: #3364 (comment)
The result look like this in Home Assitant:
The PR also contains a solution for Adeo SIN-4-FP-21_EQU, which seems to be an exact clone of NodOn. However, it requires zigpy/zigpy#1505 in HA to work. zigpy/zigpy#1505 has not yet been released as part of HA as of writing.
Checklist
pre-commit
checks pass / the code has been formatted using Black