Skip to content

Bind and configure reporting for the Hue contact sensor cluster again - #1047

Draft
zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/bind-hue-contact-sensor-cluster
Draft

zigpy-review-bot wants to merge 1 commit into
devfrom
zigpy-bot/audit/bind-hue-contact-sensor-cluster

Conversation

@zigpy-review-bot

Copy link
Copy Markdown
Collaborator

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 contact and tamper attributes, and nothing replaced it. A sensor paired since zha 1.4.0 therefore never reports tamper to 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: add PHILIPS_CONTACT_CLUSTER (0xFC06), which Replace cluster handlers with entity attributes #657 dropped.
  • zha/application/platforms/virtual.py: add PhilipsContactClusterBind, a virtual entity on 0xFC06 for Philips and Signify devices. It binds the cluster and configures contact and tamper to report at 0 s / 900 s / change 1, the old handler's REPORT_CONFIG_IMMEDIATE. Without the SOC001 quirk the cluster has no attribute definitions, and the reporting setup would raise KeyError on 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 in configure_cluster_configs for 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_reporting joins 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_quirk joins 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 the KeyError.
  • The full test suite passes (1783 tests), and pre-commit (codespell, ruff, mypy) passes on the changed files.

Opened by the scheduled code audit; not requested by a maintainer.

Fixes #1046

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.
@zigpy-review-bot zigpy-review-bot added bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bugfix This PR fixes a bug bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) labels Nov 21, 2026
@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.49%. Comparing base (2da1a5b) to head (8db4b44).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zigpy-review-bot zigpy-review-bot left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

  1. 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?
  2. 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.py and const.py (the cluster is never bound) and pass with the PR's.
  • The per-instance _server_cluster_config set in __init__ is what aggregate_cluster_configs reads (zha/zigbee/cluster_config.py), so the quirk-less fallback (bind only) applies on join and reconfigure alike.
  • The entity's read_on_startup=False doesn't weaken the quirk's own Tamper binary sensor on the same cluster: AggregatedAttrConfig.merge ORs read_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_files passes 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot: code audit Found by the bot's scheduled code audit bot: unrequested PR PR: opened by the bot's issue triage, not requested by a maintainer bot-watch: fix zigpy-review-bot follows this thread and also pushes fixes (review + fix) bugfix This PR fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hue contact sensor (SOC001) paired since zha 1.4.0 gets its contact cluster neither bound nor configured to report, so its tamper sensor never updates

1 participant