Skip to content

Let Hue sensor cluster inherit from OccupancySensing#4793

Merged
TheJulianJES merged 2 commits intozigpy:devfrom
TheJulianJES:tjj/hue_sensor_ep_attribute
Mar 4, 2026
Merged

Let Hue sensor cluster inherit from OccupancySensing#4793
TheJulianJES merged 2 commits intozigpy:devfrom
TheJulianJES:tjj/hue_sensor_ep_attribute

Conversation

@TheJulianJES
Copy link
Copy Markdown
Collaborator

@TheJulianJES TheJulianJES commented Feb 27, 2026

Proposed change

This removes the ep_attribute override for the Hue sensor occupancy cluster. The cluster now also inherits from OccupancySensing.

Additional information

Recently, ZHA introduced support for the pir_o_to_u_delay attribute/entity with zigpy/zha#669. This should be supported by the Hue sensors as well. However, the number entities aren't created as they require the occupancy ep_attribute (cluster handler name), yet the Hue sensors use philips_occupancy: zha/application/platforms/binary_sensor/init.py#L199-L209.

This was done as the custom Hue attributes conflicted with the ZCL attribute IDs for physical_contact_u_to_o_delay + physical_contact_o_to_u_delay attributes. As zigpy now properly supports ZCL attributes and manufacturer-specific ones using the same attribute ID, we no longer need this workaround.

Device diagnostics

Should be in ZHA.

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works
  • Device diagnostics data has been attached

@TheJulianJES TheJulianJES changed the title Let Hue sensor cluster inherit from OccupancySensing and remove `ep… Let Hue sensor cluster inherit from OccupancySensing Feb 27, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.66%. Comparing base (becb068) to head (572d4e4).
⚠️ Report is 4 commits behind head on dev.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #4793   +/-   ##
=======================================
  Coverage   92.65%   92.66%           
=======================================
  Files         379      380    +1     
  Lines       12745    12766   +21     
=======================================
+ Hits        11809    11829   +20     
- Misses        936      937    +1     

☔ View full report in Codecov by Sentry.
📢 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.

@TheJulianJES TheJulianJES marked this pull request as ready for review March 4, 2026 00:35
Copilot AI review requested due to automatic review settings March 4, 2026 00:35
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Philips Hue occupancy cluster implementation to use the standard OccupancySensing inheritance and endpoint attribute name, enabling ZHA to create the new occupancy delay number entities (e.g., pir_o_to_u_delay) introduced upstream.

Changes:

  • Make PhilipsOccupancySensing inherit from OccupancySensing and remove the custom ep_attribute override.
  • Switch Philips occupancy manufacturer attributes to use explicit manufacturer_code=0x100B.
  • Adjust test_attributes_updated_not_replaced to accommodate the Philips occupancy cluster’s attribute definition behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
zhaquirks/philips/__init__.py Updates the Philips occupancy cluster to inherit OccupancySensing and use explicit manufacturer codes for vendor attributes.
tests/test_quirks.py Updates attribute-extension tests to avoid failing on the Philips occupancy cluster’s overlapping manufacturer/ZCL attribute IDs.

@TheJulianJES
Copy link
Copy Markdown
Collaborator Author

Tested and working with this ZHA PR:

It's a small-ish change and confirmed working. I'll go ahead with this, so users can finally get the timeout entities on Hue sensors.

@TheJulianJES TheJulianJES merged commit 20a0777 into zigpy:dev Mar 4, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants