Support for the Tuya PJ-1203 single channel clamp power meter _TZE204_cjbofhxw, _TZE284_cjbofhxw Model: TS0601 #4529
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.
This quirk adds support for the Tuya PJ-1203 single channel clamp power meter.
The device reports voltage, current, power and energy used. Apparent power and power factor are calculated from these values.
Manufacturer IDs: _TZE204_cjbofhxw, _TZE284_cjbofhxw
Model: TS0601
Purchase link: https://www.aliexpress.com/item/1005005994777032.html
Datapoints:
DP 18: Current (mA)
DP 19: Power (W × 10)
DP 20: Voltage (V × 10)
DP 101: Energy (Wh)
Exposed entities:
Voltage (V)
Current (A)
Power (W)
Apparent Power (VA) - calculated
Power Factor (%) - calculated
Energy (kWh)
Proposed change:
Add a new quirk for the Tuya PJ-1203 single channel clamp energy meter that maps Tuya datapoints to ZHA ElectricalMeasurement cluster attributes and calculates apparent power and power factor from the reported values.
Additional information:
This is a single channel variant; dual channel PJ-1203A models use different datapoints and would need a separate quirk
The device does not report AC frequency, so that entity will remain unavailable
Tested and working with ZHA on Home Assistant 2025.11.2
Device diagnostics
zha-01KAEDWDH9AYZDVE1HTD8MCW6X-_TZE284_cjbofhxw TS0601-6850c3f422189896ca2536b313d6e7fb.json
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
After pulling enough logs and comparing the energy used vs power I found a dip in cumulative energy consumption.
To alleviate that an implementation of energy offset restoration from ZHA's attribute cache to maintain
energy accumulation continuity across quirk reloads/restarts was introduced. When the device
counter is lower than the cached value, the offset is restored to prevent energy loss.
I have monitored the data over 24h period and I am happy to report that there is no longer dips in cumulative energy readings, please find the attached history file. The initial dip around 11:55hrs on the 26/11/25 was from the previous version of the quirk, so it is possible to observe that the fix had really worked.
energy.csv
There are still edge cases when stale cache from crash, multiple resets during offline period or cache loss and a few more even more obscure cases can lead to some data loss and dips in energy used but it is still far better than the original implementation, which was all over the place.
I have made a proper mess with the previous commit so apologies for that! I am still trying to learn how to work with LLMs to help me with the coding tasks.