zigbee2mqtt icon indicating copy to clipboard operation
zigbee2mqtt copied to clipboard

[Feature request]: Add support for tuya scene modes (dev info inside)

Open felipejfc opened this issue 2 years ago • 1 comments

Is your feature request related to a problem? Please describe

Adding a new functionality for tuya lights.

Describe the solution you'd like

It will be possible to use scenes with breathing and flashing cycles with tuya lights.

Describe alternatives you've considered

There's no alternative.

Additional context

This is what the screen in the app look like:

image

Did some sniffing of a bulb here with this functionality and saw this data flowing from the tuya gateway to the light bulb when cycling through the different scenes:

night (static) f1 00 00 28 28 00 00 00 00 c8 00

read (static) f1 01 00 28 28 00 0d 00 00 e8 f4

read less brightness f1 01 00 28 28 00 09 00 00 70 f4

working (static) image

f1 02 00 0e 0d 00 0f 00 00 e8 e8

leisure (static) f1 03 00 28 28 00 05 00 00 f4 f4

soft (breath) f1 04 03 46 46 78 f0 e8 e8 00 00 46 46 78 c0 e8 0a 00 00

colorful (flash) image

f1 05 00 c6 46 00 f0 e8 e8 00 00 c6 46 78 f0 e8 e8 00 00 c6 46 f0 f0 e8 e8 00 00 c6 46 3d f0 e8 e8 00 00 c6 46 ae f0 e8 e8 00 00 c6 c6 13 f0 e8 e8 00 00

dazzling (flash) image f1 06 00 c6 46 00 f0 e8 e8 00 00 c6 46 78 f0 e8 e8 00 00 c6 46 f0 f0 e8 e8 00 00

gorgeous (breath) image

f1 07 3f 46 46 00 f0 e8 e8 00 00 46 46 78 f0 e8 e8 00 00 46 46 f0 f0 e8 e8 00 00 46 46 3d f0 e8 e8 00 00 46 46 ae f0 e8 e8 00 00 46 c6 13 f0 e8 e8 00 00

gorgeous less brightness (normal speed) f1 07 3f 46 46 00 e0 e8 3d 00 00 46 46 78 e0 e8 3d 00 00 46 46 f0 e0 e8 3d 00 00 46 46 3d e0 e8 3d 00 00 46 46 ae e0 e8 3d 00 00 46 c6 13 e0 e8 3d 00 00

gorgeous faster f1 07 3f 63 63 00 f0 e8 e8 00 00 63 63 78 f0 e8 e8 00 00 63 63 f0 f0 e8 e8 00 00 63 63 3d f0 e8 e8 00 00 63 63 ae f0 e8 e8 00 00 63 e3 13 f0 e8 e8 00 00

gorgeous slower f1 07 3f 28 28 00 f0 e8 e8 00 00 28 28 78 f0 e8 e8 00 00 28 28 f0 f0 e8 e8 00 00 28 28 3d f0 e8 e8 00 00 28 28 ae f0 e8 e8 00 00 28 a8 13 f0 e8 e8 00 00


From deduction, here are some assumptions, lets take gorgeous:

f1 07 3f f1 -> command 241 07 -> scene id, see how it increases from one to the other in sequence same as they're presented in the app screen 3f -> this one I THINK is a bitmask indicating how many colors the breath flows will have, 3f = 00111111 in binary, 6 bits set and 6 colors selected.

the rest is an array composed of speed, color and brightness info:

46 46 00 f0 e8 e8 00 00 46 46 -> speed? 00 -> hue, first color is red f0 -> saturation? e8 -> lightness? e8 -> probably brightness the one that you set in the slider on the top, see how it's lower in the (lower brightness) example. 00 00 -> I'm not sure, althoigh given it's being set to values in the first static examples maybe this one controls white led temperature and so on?

other 5 colors only changing Hue and Saturation

46 46 78 f0 e8 e8 00 00 46 46 f0 f0 e8 e8 00 00 46 46 3d f0 e8 e8 00 00 46 46 ae f0 e8 e8 00 00 46 c6 13 f0 e8 e8 00 00

I think supporting the breath and flashing ones would be super nice. There's no good way (that I know of?) of doing these color cycles currently. From reading thorugh different parts of z2m code I think we basically need to create a new command interpreter for this f1 (241) cmd, and construct the arrays for passing the colors info to the light? Though I prefered to post this here before giving a go since there might be a easy/right way of doing it that a newbie in the project wouldn't know :)

felipejfc avatar Nov 02 '23 03:11 felipejfc

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

github-actions[bot] avatar May 01 '24 00:05 github-actions[bot]