Conversation
* Add support for SONOFF SNZB-03PR2 occupancy and illuminance reporting * Implement custom cluster for illuminance compensation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #4714 +/- ##
=======================================
Coverage 92.60% 92.60%
=======================================
Files 424 425 +1
Lines 14667 14679 +12
=======================================
+ Hits 13582 13594 +12
Misses 1085 1085 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| class AttributeDefs(OccupancySensing.AttributeDefs): | ||
| """Custom occupancy-related attributes for SNZB-03PR2.""" | ||
|
|
||
| pir_occupied_to_unoccupied_delay = ZCLAttributeDef( |
There was a problem hiding this comment.
This already exists in the ZCL on the normal OccupancySensing cluster as pir_o_to_u_delay.
| id=SONOFF_ILLUM_COMP_ATTR_ID, | ||
| type=t.int16s, | ||
| access="rw", | ||
| is_manufacturer_specific=True, |
There was a problem hiding this comment.
We've moving from is_manufacturer_specific=True to explicit manufacturer codes per attribute/command. From your diagnostics, it looks like it should be manufacturer_code=0x1286.
There was a problem hiding this comment.
Logger: zhaquirks
Source: /usr/local/lib/python3.13/site-packages/zhaquirks/__init__.py:481
First appearance: 10:16:41 (1 occurrence)
Last record: 10:16:41
Unexpected exception importing custom quirk 'snzb03pr2'
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/zhaquirks/__init__.py", line 479, in setup
spec.loader.exec_module(module)
~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^
File "<frozen importlib._bootstrap_external>", line 1023, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/config/zha_quirks/snzb03pr2.py", line 11, in <module>
class SonoffPrivateCluster(CustomCluster):
...<13 lines>...
)
File "/config/zha_quirks/snzb03pr2.py", line 17, in SonoffPrivateCluster
class AttributeDefs(BaseAttributeDefs):
...<7 lines>...
)
File "/config/zha_quirks/snzb03pr2.py", line 20, in AttributeDefs
illumination_compensation = ZCLAttributeDef(
id=0x2018,
...<2 lines>...
manufacturer_code=None,
)
TypeError: ZCLAttributeDef.__init__() got an unexpected keyword argument 'manufacturer_code'Hello, I encountered an error after changing is_manufacturer_specific to manufacturer_code.
There was a problem hiding this comment.
Make sure you're running the latest Home Assistant beta, it will be in the stable release in a few days.
Remove custom OccupancySensing cluster in favor of standard zigpy attribute. Clean up constant definitions and explicitly set manufacturer_code for private cluster attribute.
|
hello, I have made the changes and completed the testing. |
TheJulianJES
left a comment
There was a problem hiding this comment.
This looks fine in general. I'll get back to you on whether we want to do the pir_o_to_u_delay number entity per v2 quirk or just generally in ZHA for all devices.
Co-authored-by: TheJulianJES <TheJulianJES@users.noreply.github.com>
|
This PR has completed code changes and testing, CI is all green, and all review comments have been addressed. Are there any further actions required? If everything is in order, when can this PR be merged into the |
|
Hi, I would like to ask about the current status of this PR. The driver has been tested and appears to work correctly, but it has not yet been merged into the main branch. Could you please let me know if there are any outstanding issues, required changes, or additional reviews needed before it can be accepted? I’m happy to make adjustments if necessary. Thank you for your time and support! |
Proposed change
This PR adds a new quirk for the SONOFF SNZB-03PR2 motion sensor.
While the device identifies as a standard motion sensor, it requires specific cluster handling for:
IlluminanceMeasurementcluster to provide real-time light level data.Additional information
Device Type: Zigbee End Device (Motion & Light Sensor).
Testing: Verified that the motion entity resets correctly according to the defined "Detection Interval" and that the illuminance values reflect the "Illumination Offset" set in the attributes.
Dependencies: This quirk is compatible with recent
zigpyversions (tested with 0.91.5+ style method signatures).Device diagnostics
sonoff_snzb03pr2_diagnostics.json
Checklist
pre-commitchecks pass / the code has been formatted using Black