-
Notifications
You must be signed in to change notification settings - Fork 716
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 modern configuration options for NodOn SIN-4-1-20, SIN-4-1-21, SIN-4-2-20, and alike #3568
base: dev
Are you sure you want to change the base?
Add modern configuration options for NodOn SIN-4-1-20, SIN-4-1-21, SIN-4-2-20, and alike #3568
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #3568 +/- ##
==========================================
+ Coverage 89.79% 89.81% +0.01%
==========================================
Files 323 323
Lines 10414 10434 +20
==========================================
+ Hits 9351 9371 +20
Misses 1063 1063 ☔ View full report in Codecov by Sentry. |
One TODO for this PR: |
ZHA should try and read the attribute during pairing. If it's returned as unsupported, it shouldn't create the select entity. |
Hmm, when ZHA reads the attribute during pairing, we should get "unsupported attribute" back. It will cause that attribute to be added to the "unsupported attributes" list for that device. ZHA should not create the entity then: Can you try and restart HA to see if the entity disappears then? Also, when you download the diagnostics file for that device (from the device page -> three dots), is |
@TheJulianJES, it's weird.
|
No wait. I think I missed something. |
okay, I got why the code is not executed for the if condition is:
Looks like either a feature of ZHA, or a bug :-) |
This small patch makes it work as expected. I'm not sure if this is the right approach, though $ git diff
diff --git a/zha/application/platforms/select.py b/zha/application/platforms/select.py
index 1012966..4f42dd2 100644
--- a/zha/application/platforms/select.py
+++ b/zha/application/platforms/select.py
@@ -185,15 +185,22 @@ class ZCLEnumSelectEntity(PlatformEntity):
Return entity if it is a supported configuration, otherwise return None
"""
+
+ if ENTITY_METADATA in kwargs:
+ entity_metadata = kwargs.get(ENTITY_METADATA)
+ attr_name = entity_metadata.attribute_name if hasattr(entity_metadata, 'attribute_name') else None
+ else:
+ attr_name = cls._attribute_name
+
cluster_handler = cluster_handlers[0]
- if ENTITY_METADATA not in kwargs and (
- cls._attribute_name in cluster_handler.cluster.unsupported_attributes
- or cls._attribute_name not in cluster_handler.cluster.attributes_by_name
- or cluster_handler.cluster.get(cls._attribute_name) is None
+ if attr_name is not None and (
+ attr_name in cluster_handler.cluster.unsupported_attributes
+ or attr_name not in cluster_handler.cluster.attributes_by_name
+ or cluster_handler.cluster.get(attr_name) is None
):
_LOGGER.debug(
"%s is not supported - skipping %s entity creation",
- cls._attribute_name,
+ attr_name,
cls.__name__,
)
return None |
FTR: Firmware images I used are from Koenkk/zigbee-OTA#599. NodOn's CTO submits them. |
Ah, of course! So we always "force create" all entities defined via quirks v2. I think the original intention was to skip this part: Yeah, well, I guess we should change this for all platforms.. I'll try to have another look at this in the next few days. We might need to adopt something similar to your patch. I think we could compact it a bit though. |
@TheJulianJES I'd be happy to prepare a PR for all platforms. As long as the direction I initially took is the right one. Please let me know. I've also created zigpy/zigpy#1515 to track the problem |
Proposed change
This PR adds the following configuration options for NodOn switches:
SIN-4-1-20, SIN-4-1-21, SIN-4-1-20_PRO
switch_type (Bistable, Monostable, AutoDetect)
This setting is only available with firmware 3.4.0 and older. It allows one to manually configure SwitchType. In principle, NodOn switches auto-detect Toggle vs. Momentary mode. However, the auto-detection mechanism is not always reliable, and this option allows one to override it.
impulse_mode_duration
These switches have pulse mode, i.e., they turn off after a configured number of milliseconds. This setting allows one to configure it. 0 (the default value) means deactivation of the impulse mode.
SIN-4-2-20
Same as above. For both endpoints.
Additional information
The logic is a port of https://github.com/Koenkk/zigbee-herdsman-converters/blob/master/src/devices/nodon.ts#L100
This is how it looks in UI:
All UI entities are initially disabled.
Checklist
pre-commit
checks pass / the code has been formatted using Black