xZetsubou / hass-localtuya

🔹 A Home Assistant integration to handle Tuya devices locally "fork from localtuya"
https://xzetsubou.github.io/hass-localtuya/
GNU General Public License v3.0
291 stars 30 forks source link

Support light transition/gradient configuration #153

Closed LiZhenhuan1019 closed 2 months ago

LiZhenhuan1019 commented 4 months ago

The problem

I tried in hass to call the light in localtuya with transition parameter, but it seems not having any effect. I found that I was able to configure the transition time in tuya app. So, I investigated it and here was what I found:

DP 35, switch_gradient image

The value is a base64 encoding of 7 bytes data. The first 1 byte is always 0x00. The 2-4th bytes are transition time in milliseconds used when turning on the light, and the 5-7 bytes are used when turning off. For example, if I set both the transition time to 60s in tuya app, the value of this dp will AADqYADqYA==, and the decoded data will be 0x00 00ea60 00ea60. 0x00ea60 is 60000 in decimal. For another example, if I set the on-transition time to 10.1s, and the off-transition time to 2.5s, then the value will be AAAndAAJxA== and the decoded data will be 0x00 002774 0009c4. 0x2774 is 10100 in decimal and 0x9c4 is 2500 in decimal.

I hope that this can be used to support transition configuration.

xZetsubou commented 4 months ago

I really appreciate your effort and the explanation you made made it kinda clear to me. But this may only works for you and not for everyone, so I'm really not sure.

by the way have you made tests? You can change the value of "35" DP using set_dp service

andrus2049 commented 3 months ago

See my solution to decode tuya datapoints rawdata:

https://github.com/rospogrigio/localtuya/issues/1193#issuecomment-1951057842

xZetsubou commented 3 months ago

@andrus2049 I tested your method before here: https://github.com/xZetsubou/hass-localtuya/issues/156#issuecomment-1973975514 but it didn't ends up well for me.

github-actions[bot] commented 3 months ago

This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days.