Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## dev #4835 +/- ##
==========================================
+ Coverage 92.76% 92.78% +0.02%
==========================================
Files 385 385
Lines 12818 12868 +50
==========================================
+ Hits 11890 11940 +50
Misses 928 928 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
zhaquirks/tuya/ts0601_rcbo.py
Outdated
| under_voltage_threshold: Final = ZCLAttributeDef( | ||
| id=0xEF21, type=t.uint16_t, is_manufacturer_specific=True | ||
| ) | ||
|
|
||
| dp_to_attribute: dict[int, list[DPToAttributeMapping]] = { | ||
| 1: [DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "state")], | ||
| 17: [DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "energy")], | ||
| 18: [DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "current")], | ||
| 19: [DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "power")], | ||
| 20: [DPToAttributeMapping(TuyaMCUCluster.ep_attribute, "voltage")], |
There was a problem hiding this comment.
We also have methods, like tuya_dp, in the TuyaQuirkBuilder to both create the local attributes and the mappings. Is there a reason why you've done it like this instead?
For reference, see:
zha-device-handlers/zhaquirks/tuya/builder/__init__.py
Lines 641 to 671 in c5634ab
and: https://github.com/zigpy/zha-device-handlers/blob/dev/tuya.md#tuya_dp_attribute.
There was a problem hiding this comment.
Refactored this to use the v2 TuyaQuirkBuilder DP helpers instead of the hand-written AttributeDefs / dp_to_attribute block.
Concretely:
- single-DP entities now use
tuya_switch,tuya_sensor, andtuya_enum - the composite DP48/DP49 payloads now use
tuya_attribute+tuya_dp_multiwith the same reserved-byte-preserving write converters as before - the custom
TuyaRCBO2ManufClusterclass is gone, so the manufacturer-cluster attributes/mappings are now declared the waytuya.mdand the builder API recommend
I reran:
uv run pytest tests/test_tuya_rcbo.py -quv run pytest tests/test_quirks_v2.py -quv run pre-commit run --files zhaquirks/tuya/ts0601_rcbo.py tests/test_tuya_rcbo.py
Thanks, that is a better fit for this v2 quirk.
Proposed change
Add support for the Tuya RCBO variant
_TZE284_5m4nchbm/TS0601.This PR adds a new v2 quirk entry in
zhaquirks/tuya/ts0601_rcbo.pythat maps the datapoints from a working Zigbee2MQTT converter, including the composite raw datapoints48and49used for the alarm/breaker threshold payloads. The implementation preserves the reserved bytes in those payloads when writing updated thresholds back to the device.The PR also adds tests to verify:
Additional information
This is additive only and should not be a breaking change.
The device diagnostics used for this work show the unsupported device before this quirk is applied:
_TZE284_5m4nchbmTS0601MainsRouterquirk_applied: falseValidation run locally:
uv run pytest tests/test_tuya_rcbo.py -quv run pytest tests/test_quirks_v2.py -quv run pre-commit run --all-filesDevice diagnostics
zha-01KKZ1NW5GS19MYYHNAPKR43FC-_TZE284_5m4nchbm TS0601-bb977f4b1014ef6e4cf4f7a3f15e139a.json
Checklist
pre-commitchecks pass / the code has been formatted using Black