rospogrigio / localtuya

local handling for Tuya devices
GNU General Public License v3.0
2.95k stars 563 forks source link

Scene mode #131

Closed SmartM-ui closed 3 years ago

SmartM-ui commented 4 years ago

@rospogrigio @postlund @ultratoto14

Hi, I remember that by setting the value to 63 of the bulb supported features (in local tuya I see the value 19) the "effect" menu was displayed, as happens in the original Smart Life app.

In the other custom component (Tuya Custom) even though the scene menu was displayed, it was still empty.

Could you bring the scenes from the Smart Life app back to Local tuya?

It is not an indispensable function, but it would be an added value.

homeassistant: customize: light.xxxx: #entity name supported_features: 63

86342278-ab47af80-bc57-11ea-8d49-0b363e9b2159

86342270-a7b42880-bc57-11ea-96ec-eefaef86fed7

postlund commented 4 years ago

Anyone know how effects work? I have no idea. Maybe we need DPS dumps when different effects are activated?

SmartM-ui commented 4 years ago

Anyone know how effects work? I have no idea. Maybe we need DPS dumps when different effects are activated?

Hi! These are the effects of the smartlife app

20201102_184529

postlund commented 4 years ago

Question is how we translate this into something we can send to the bulb .

postlund commented 4 years ago

Ok, so scenes are manged by DP 25 according to:

light_dps

Maybe we can just try to set 25 to Night or night (or any of the others) and see what happens?

ultratoto14 commented 4 years ago

Here is what dps 25 is set on my RGBW Led strip:

"25": 07464602000003e803e800000000464602007803e803e80000000046460200f003e803e800000000464602003d03e803e80000000046460200ae03e803e800000000464602011303e803e800000000

Night or night will not work i must admit. Also, i have multiple bulbs, they all have different scenes.

"21" is set to scene and Colored scene: "25": 05464601000003e803e800000000464601007803e803e80000000046460100f003e803e800000000 Night scene: "25": 000e0d0000000000000000c80000

Available scenes in this one: Night, Reading, Work, Soft, Colored, 3 others (do not know how to translate in English ;-))

postlund commented 4 years ago

Right, so the scenes are probably encoding of various changes to colors, brightness and temperatures. So we could probably build our own scenes if we figure out the format. I noticed 03e8 (1000 in decimal) which is likely maximum brightness. Wouldn't be surprised if we found HSV or RGB encoded colors in there...

ultratoto14 commented 4 years ago

I dug a little bit into the scenes and here are my findings about simple scenes, white only

Night:
000e0d0000000000000000c80000
Work:
020e0d0000000000000003e803e8
Read:
010e0d0000000000000003e801f4
Loisir:
030e0d0000000000000001f401f4
Loisir brightness 100%
030d0d0000000000000003e801f4
Loisir brightness 100% colortemp 100%
030d0d0000000000000003e803e8
03 0d 0d00000000000000 03e8 03e8
two first, index of the scene
two next, 0e if default, 0d if modified
last 4 color_temp
the 4 before brightness

edit:
Loisir brightness 50% color Red Sat 100%
030d0d00016803e801f400000000
Loisir brightness 100% color Red Sat 100%
030d0d00016803e803e800000000
Loisir brightness 100% color Red Sat 50%
030d0d00016801f403e800000000
030d0d00 0168 01f4 03e8 00000000
HSV (360, 500, 1000)

Continue digging.

SmartM-ui commented 4 years ago

Here is what dps 25 is set on my RGBW Led strip:

"25": 07464602000003e803e800000000464602007803e803e80000000046460200f003e803e800000000464602003d03e803e80000000046460200ae03e803e800000000464602011303e803e800000000

Night or night will not work i must admit. Also, i have multiple bulbs, they all have different scenes.

"21" is set to scene and Colored scene: "25": 05464601000003e803e800000000464601007803e803e80000000046460100f003e803e800000000 Night scene: "25": 000e0d0000000000000000c80000

Available scenes in this one: Night, Reading, Work, Soft, Colored, 3 others (do not know how to translate in English ;-))

Hi @ultratoto14 @postlund I'm back. I saw that you worked during my absence!

I try to carry out some tests too, re-enabling debugging. Is there a possibility to enable debugging for only one light bulb? Between the switches and the other bulbs, the log is difficult to read.

My scenes are as follows: night, read, meeting, leisure, soft, rainbow, shine, beautiful

Thanks!

ultratoto14 commented 4 years ago

What you can do is just a grep on the log as the logs contains the bulb id =>

tail -f home-assistant.log | grep yourid
SmartM-ui commented 4 years ago

What you can do is just a grep on the log as the logs contains the bulb id =>

I wanted to avoid generating too heavy a log. OK, I'll use debugging only when needed for the various tests.

ultratoto14 commented 4 years ago

I use a sensor to debug the DP 25, look this #135 and the fix #138

SmartM-ui commented 4 years ago

I use a sensor to debug the DP 25, look this #135 and the fix #138

The fix https://github.com/rospogrigio/localtuya/pull/138 has also been implemented here: https://github.com/rospogrigio/localtuya/pull/129

Which one should I try tonight?

ultratoto14 commented 4 years ago

They are not linked, #129 is for white home assistant scenes and #138 may help you debug the tuya scenes ;-)

SmartM-ui commented 4 years ago

Hi @ultratoto14 pull 138 is about "string sensor" (https://github.com/ultratoto14/localtuya/tree/string_sensor) and you can download the code to try (localtuya-string_sensor.zip) and not debug for tuya scenes.

This is why I was asking which .zip to install to perform the tests: localtuya-string_sensor.zip or localtuya-light_scene_fix.zip Confusion :-)

pergolafabio commented 4 years ago

I bought an rgb led strip yesterday, I can also turn on music modes and stuff like that, will this also be contrable with this PR?

ultratoto14 commented 4 years ago

There is no PR yet, the music mode is using the mic of the phone, so it will not be available with HA for the moment

pergolafabio commented 4 years ago

Hmm, quite sure that's it's not using the mic of my phone :-)

I think the wifi controller of the led strip has a mic... When I clap my hands , I see the rgb strip flashing, ist cool for kids :+)

ultratoto14 commented 4 years ago

I also have one, i'll try ;-)

ultratoto14 commented 4 years ago

For my led strip, it is linked to the phone, if you can confirm that yours is using only the led strip (i tested with my phone in the fridge ;-))

pergolafabio commented 4 years ago

yes, my phone was 1 floor down, closed all doors

i have this RGB strip :https://nl.aliexpress.com/item/4000103478758.html?spm=a2g0s.9042311.0.0.4b0f4c4dXqJrSP

ultratoto14 commented 4 years ago

@SmartM-ui , @pergolafabio you may try this PR: #146

pergolafabio commented 4 years ago

@ultratoto14

will do, but i removed localtuya for now i have an RGB led strip, when it drops the wifi, its not coming back to HA

in the HA log, i see every 5 mins disconnect warning, but it doesnt reconnect i have to restart HA to make it work again... strange, because i can still ping it, also the IP are static (dhcp MAC reservation)

with tuya cloud , its stays working

SmartM-ui commented 4 years ago

@SmartM-ui , @pergolafabio you may try this PR: #146

@ultratoto14 Hello, my friend! I'm away for work and I'm coming home on Friday night. As soon as I can I try your new PR and it will get feedback. See you soon and don't have fun without me :-)

ultratoto14 commented 3 years ago

PR is merged, you can check on your side and close the issue if it is satisfying. @SmartM-ui I initiated a wiki page for known working devices, if you can give the specifications of yours, i can then add them to the list.

SmartM-ui commented 3 years ago

Perfect, it seems to work!

stephanbosch commented 1 year ago

The scene string is documented here: https://developer.tuya.com/en/docs/iot/product-function-definition?id=K9s9rhj576ypf#title-8-DP25%3A%20scene Tested this with tinytuya and it works.

This will allow implementing the sliders that the tuya app has for these effects/scenes: speed, brightness, and saturation. We can create custom scenes that Tuya app doesn't provide. Maybe we could even make some sort of scene editor.