mdeweerd / zha-toolkit

🧰 Zigbee Home Assistant Toolkit - service for "rare" Zigbee operations using ZHA on Home Assistant
GNU General Public License v3.0
171 stars 17 forks source link

Setting New reportable_change on Tuya TS0201 (Temp + Humidity - No Display) #211

Closed alxscott closed 7 months ago

alxscott commented 8 months ago

Hi,

I was getting incorrect / invalid results using conf_report_read: on the above device. Applying the Tuya Magic Spell ( and a restart) showed the correct values which aligned to those shown during a ZHA Reconfigure.

However, I cannot apply new values ( mainly reportable_change: although min/max also fail. The command is successful but the values do not change on the device.

I note on the wiki a point around "currently only the "read" part is implemented - if needed a super_magic_spell can be added to also execute the write procedure.".

Could this be why my new values are not being applied? And if so would I be able to trial the ability to write to Tuya devices as well as read?

Thanks.

PS First Zigbee devices and ZHA-Toolkit has been really helpful so thank you

mdeweerd commented 8 months ago

Hi Up-to-now the Tuya Magic spell seems to suffice "as-is", and because your device changed behavior I suppose it still does.

The comment where this was labeled a magic spell also mentions the following write that was observed:

    Command: Write Attributes (0x02)
    Attribute Field, Uint8: 13
        Attribute: Unknown (0xffde)
        Data Type: 8-Bit Unsigned Integer (0x20)
        Uint8: 13 (0x0d)

Device responce:
    Command: Write Attributes Response (0x04)
    Status Record
        Status: Success (0x00)

Meaning that the current magic spell may need to be followeb by a write of value 0x0D to attribute 0xffde in unmentioned cluster (supposedly 0. Something that can be achieved with "zha_toolkit.attr_write" exactly with attr_type set to 0x20, read_before_write set to false, and the other values set as indicated. You could do that in a script so that you can call the magic spell first and then that write in a precise sequence.

The command is successful but the values do not change on the device.

I suppose that you verified the values doing a "conf_report_read"? What do you read back? By "command is successful", do you mean that the zha-toolkit command was accepted, or that you can see that the device replied with success? How many tries did you define? Did you check how many were needed (can be seen if you enable zha-toolkit debug messages).

I suppose that the TS0201 is a sleepy device and that you need a high number of tries.

There is an example script to set the reporting of a Zigbee thermometer: https://github.com/mdeweerd/zha-toolkit/blob/main/examples/script_Thermometer_setReporting.yaml It has a default of 100 tries (sometimes not enough). The script also reads back the reporting configuration. However, you need to set the log level to debug and check the home-assistant.log.

alxscott commented 8 months ago

Thanks for the quick response! Wanted to try and have a look at this tonight but I didn't get a chance. I'll follow your advice and report back this week. Thank you!