-
Notifications
You must be signed in to change notification settings - Fork 728
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 Philips Hue contact sensor quirk #3432
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## dev #3432 +/- ##
==========================================
+ Coverage 89.37% 89.39% +0.01%
==========================================
Files 308 309 +1
Lines 9990 10004 +14
==========================================
+ Hits 8929 8943 +14
Misses 1061 1061 ☔ View full report in Codecov by Sentry. |
… in the custom cluster class.
As discussed here and on the HA Discord, I am advocating in handling the functions of the sensor entirely based on the stateful manufacturer specific cluster as it was intended by Signify. It is a breaking change. What the device-handler does
Reasons supporting this
Other reasons supporting my decision
I hope this proposal will convince to consider this pull request. Other notes
|
zhaquirks/philips/soc001.py
Outdated
class OnOff(CustomCluster): | ||
"""Custom On/Off cluster to still allow binding.""" | ||
|
||
cluster_id = 6 # 0x0006 | ||
name = "On/Off cluster" | ||
ep_attribute = "on_off_cluster" | ||
|
||
class AttributeDefs(BaseAttributeDefs): | ||
"""Attribute definitions.""" | ||
|
||
on_off = ZCLAttributeDef( | ||
id=0x0000, | ||
type=types.Bool, | ||
is_manufacturer_specific=False, | ||
) |
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.
I don't think we should/can do this. We're replacing a ZCL cluster and are also changing the ep_attribute
here.
IIRC there are places where ZHA expects the ep_attribute
to be unchanged for a standard ZCL cluster.
Not subclassing OnOff
(and its AttributeDefs
) is also not good.
Like I mentioned on Discord, I'd remove the custom We can still consider on how we want to deal with the "contact" binary sensor then. It's not trivial, as breaking changes are always bad (especially for a security device where the behavior might go unnoticed in automations until it's too late). The parts where the change would be breaking:
|
Also, to re-iterate some of the points I mentioned on Discord:
Tuya intends that we shouldn't work with its devices all.. 😄
Well, we're doing exactly that. ZHA requests the
Even for a binary sensor based on the custom attribute, it wouldn't fix this. If ZHA is restarted after a power outage, we only poll some attributes of mains-powered devices (based on what's defined in the ZHA cluster handler).
But the same behavior would happen for the binary sensor based on the custom attribute. ZHA doesn't poll entities by default, especially not ones on battery-powered devices. The only benefit that I'm seeing for such a breaking charge (or large change if we make it not breaking) is that you can poll the entity state (assuming the device is always somewhat awake, but that does seem to be the case according to what you mentioned). So just to repeat myself, I'd change the scope of this PR to only include the tamper entity for now (and the custom contact cluster with both custom attributes defined). We can also merge the ZHA PR then. Everyone who installs/pairs a Hue sensor after a release with those changes will at least have the custom Hue cluster bound (and a tamper entity), so if we make the binary sensor switch in the future (whatever that may look like), they won't have to reconfigure or re-pair the device at least. |
Another thought I'm not sure works (ideally for a future PR): This won't solve the issue of needing to re-pair the sensor though, unless we still listen to the actual |
I just want to say first, thank you so much for following up. I recognise the quality of your free time spent on this project and the effort you took to assist me. For this reason I was about to submit as you proposed because I don't want to drag you forever for something with mild consequences. But I wanted to make sure the consequences we're as you described so it can be at worst, left like this. I did 2 tests :
This also apply to a transmission failure, I've seen the sensor fail 1 or 2 times to transmit on the network but tried again right after. And the reason is simple enough : result_conf:
- cluster: On/Off
cluster_id: "0x0006"
ep: 2
attr_id: "0x0000"
direction: 0
status: 134 #(not supported)
attr: on_off Where on the custom cluster : result_conf:
- cluster: Philips contact cluster
cluster_id: "0xFC06"
ep: 2
attr_id: "0x0100"
direction: 0
status: 0
type: "0x30"
min_interval:
- 0
max_interval:
- 900
reportable_change:
- null
attr: contact The on_off cluster in this case is a client type and does not seem to support reporting configuration but will report a change on the bind device. I don't know if it's per specification but seems logical to not report a state multiple times if it's to command a light as you might have turned off the light with a remote meanwhile. Also it's a light sleeper, it does respond to commands within the timeout of the network. You're the maintainer and I want to respect that. If the breaking change is unacceptable I'll submit without it. |
Ok, this is good to know.
Yeah. Using the Just redirecting attribute reports from the custom Hue cluster to the OnOff cluster would get those 15 minute interval reports to come through. Depending on the implementation, it may also allow for manual polling. Anyways, like mentioned before: We can basically instantly merge this PR for the tamper entity if the contact entity and custom |
Absolutely. It was a crude way to get to the result. There's surely a proper way to do it.
I agree to look at that in another PR so we at least start to bind and report as soon as possible.
I'm ok with that. As long as we have a reliable sensor at the end. Let's get that merge and I could learn how to do tests at some point. |
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.
This should be good. Thanks!
We can't really do a lot in terms of unit tests for this quirk. Entity creation only happens in ZHA/HA, so there's no real code to test here. |
Proposed change
This adds the custom Philips Hue contact cluster with all its custom attributes.
A v2 quirk entity for the binary temper sensor is also added.
Additional information
Needed by this PR: zigpy/zha#238
Fixes: #3314
Checklist
pre-commit
checks pass / the code has been formatted using Black