Migrate Tuya's `PowerOnState` attribute to `start_up_on_off` OnOff cluster attribute
See original GitHub issueNow that @dmulcahey has added support for configuring from HA the power on state of ZHA devices, I’ve realized that the implementation followed with Tuya devices is not ideal.
In Tuya devices, the power_on_state (id: 0x8002) attribute has been added to manage this property instead of using the start_up_on_off (id: 0x4003) attribute, but if the standard Zigbee property is used, we can take advantage of the implementation made to also control those Tuya devices from HA without any extra coding.
I am in favor of quirks implementing standard Zigbee attributes/functionalities whenever possible, and for me this is a clear candidate to improve the implementation.
However, there are some aspects to review before tackling the task:
- There is no match between the Tuya attribute values and Zigbee attribute:
| Status | Zigbee | Tuya |
|---|---|---|
Off |
0x00 | 0x00 |
On |
0x01 | 0x01 |
Toggle |
0x02 | don’t exists |
PreviousValue |
0xFF | 0x02 |
- In Tuya’s MCU devices this attribute is just a quirk attribute (fake) to read and set the value, but I am not sure about the behavior in Tuya’s (real) Zigbee devices. There is a real 0x8002 attribute in these devices?
In function of the answer to point 2. I see two approachs:
a. remove the power_on_state (id: 0x8002) attribute and make use of a wrapper class to ‘translate’ values (¿?)
b. overwritte the read/write start_up_on_off (id: 0x4003) attribute to make use of (and translate) the get/set power_on_state (id: 0x8002)
Any comment or help on this is welcome.
I can take care of the implementation and I can test with some MCU type devices that I have, but I think that the solution for the Tuya Zigbee devices can condition the implementation of the MCUs.
References:
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:13 (6 by maintainers)

Top Related StackOverflow Question
We can target manufacturer / model / attribute name together in ZHA. What I would say is this: if it is as easy as extending the entity class in ZHA and overriding the attribute name it probably makes more sense to do it in ZHA. If it would drastically change how the support in ZHA works we should probably quirk the device to make it match the spec if it is functionality that the spec offers. For functionality that isn’t even in the spec it probably makes more sense to just do the work in ZHA.
A good example may be the new innovelli switch. We will probably have a ton of innovelli specific configuration entities in ZHA because there is a ton of stuff that isn’t part of the spec that the device can be configured to do.
All of this said… we need to evaluate what needs to be done to make this sustainable moving forward. if we follow the approach above things could get unruly very quickly.
@puddly @Adminiuga do either of you have any thoughts?
I also prefer this approach. ZHA was developed with the thought that vendors would stick to the specs and quirks were supposed to address some “minor” incompatibilities. Well, Tuya buried this idea and I think implementing Tuya in ZHA is more flexible approach in the long run.