Repository navigation
Bind and configure reporting for the Hue contact sensor cluster again - #1047
Draft
zigpy-review-bot wants to merge 1 commit into
Draft
zigpy-review-bot wants to merge 1 commit into
zigpy-review-bot wants to merge 1 commit into
Conversation
The Replace cluster handlers with entity attributes change (#657) dropped the handler for the Philips contact cluster (0xFC06) without a replacement, so a Hue SOC001 contact sensor paired since then gets the cluster neither bound nor configured to report its contact and tamper attributes, and its tamper binary sensor never updates. Restore the old behaviour as a virtual entity: bind the cluster and configure the contact and tamper reporting as before (0 s / 900 s / 1), limited to Philips and Signify devices. Without the SOC001 quirk the cluster has no attribute definitions, so only bind it then instead of failing the device's configuration on the unknown attribute names.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #1047 +/- ##
=======================================
Coverage 97.48% 97.49%
=======================================
Files 61 61
Lines 10870 10881 +11
=======================================
+ Hits 10597 10608 +11
Misses 273 273 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
zigpy-review-bot
left a comment
Collaborator
Author
There was a problem hiding this comment.
No code findings at 8db4b44: the change does what the body says, and the would-be verdict is ready to merge. It stays a draft for the two open items below, both outside what a review can settle.
Open items
- Maintainer call: the red blink in zigpy/zha-device-handlers#5020. Binding 0xFC06 brings the sensor's manufacturer-specific contact reports back for newly paired and reconfigured sensors. That issue ties the red blink to the late Default Response zigpy sends to exactly those reports (the reporter's sensor was on zha 1.3.x, which still bound the cluster), so this PR may bring the blink back together with the tamper updates. Land it as is and fix the reply separately (in zigpy, where zigpy/zigpy#1917 tracks the one-slot reply queue for sleepy devices, or with the quirk workaround tested in that thread), or wait for that fix?
- Not checked on a device. That an unbound SOC001 sends no 0xFC06 reports, so that its Tamper entity has been stale since zha 1.4.0, follows from ZCL R8 Table 2-4 (reports go to the destinations resolved by the cluster's bindings) and from Zigbee2MQTT binding the cluster. No sensor was observed. An owner can settle it: reconfigure the sensor on this build, trigger its tamper switch, and check that the Tamper entity turns on.
Verified (7 checks)
- The full suite passes at the head (1783 tests), mypy on
zha/is clean, pre-commit (codespell, ruff, mypy) passes on the changed files, and CI is green. - Both new tests fail with dev's
virtual.pyandconst.py(the cluster is never bound) and pass with the PR's. - The per-instance
_server_cluster_configset in__init__is whataggregate_cluster_configsreads (zha/zigbee/cluster_config.py), so the quirk-less fallback (bind only) applies on join and reconfigure alike. - The entity's
read_on_startup=Falsedoesn't weaken the quirk's own Tamper binary sensor on the same cluster:AggregatedAttrConfig.mergeORsread_on_startup. - The manufacturer filter covers the quirk's manufacturer (Signify Netherlands B.V.). Of the snapshots in
tests/data/devices, only the Yokis TLC1/TLM2 expose 0xFC06, and the filter keeps them out, where the old handler matched them too.test_devices_from_filespasses unchanged. - History: the old handler came in with #238 (636ad13) and went with #657, first tagged in zha 1.4.0. #788 is still an open draft, so the guard is needed for now.
- A second-opinion pass by two models on the diff and the body's claims found nothing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Severity: medium (the audit's estimate)
#657 removed the cluster handler that bound the Philips contact cluster (0xFC06) of the Hue contact sensor (Signify SOC001) and configured reporting for its
contactandtamperattributes, and nothing replaced it. A sensor paired since zha 1.4.0 therefore never reportstamperto the coordinator, and its Tamper binary sensor keeps whatever value it had at pairing. This restores the binding and reporting setup the old handler did (added in #238).Changes
zha/application/platforms/const.py: addPHILIPS_CONTACT_CLUSTER(0xFC06), which Replace cluster handlers with entity attributes #657 dropped.zha/application/platforms/virtual.py: addPhilipsContactClusterBind, a virtual entity on 0xFC06 for Philips and Signify devices. It binds the cluster and configurescontactandtamperto report at 0 s / 900 s / change 1, the old handler'sREPORT_CONFIG_IMMEDIATE. Without the SOC001 quirk the cluster has no attribute definitions, and the reporting setup would raiseKeyErroron the attribute names and abort the device's configuration, so the entity only binds the cluster then. The open draft Fix discovery crash from quirk removing ZCL attributes #788 skips undefined attributes inconfigure_cluster_configsfor every entity; if it lands first, this guard can go.The manufacturer filter is new: the old handler matched 0xFC06 on any device, but other vendors use that ID for their own clusters.
Sensors paired since zha 1.4.0 pick the fix up on a reconfigure or a re-pair, since ZHA binds and configures reporting when a device joins or is reconfigured, not at startup.
Testing
test_philips_contact_cluster_binding_reportingjoins a SOC001 with its quirk applied and checks that 0xFC06 is bound and both attributes get their reporting config. It fails at 2da1a5b (the cluster is never bound) and passes with the fix.test_philips_contact_cluster_without_quirkjoins the same device without the quirk and checks that the device still configures and the cluster is only bound. Without the guard, this test fails with theKeyError.Opened by the scheduled code audit; not requested by a maintainer.
Fixes #1046