-
Notifications
You must be signed in to change notification settings - Fork 60
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: Light scene list not assigned properly #392
Comments
Is the names only are incorrect or the scenes not working as well. you can add RGBW as custom scenes to test as well. "Night": "000e0d00002e03e802cc00000000",
"Read": "010e0d000084000003e800000000",
"Working": "020e0d00001403e803e800000000",
"Leisure": "030e0d0000e80383031c00000000",
"Soft": "04464602007803e803e800000000464602007803e8000a00000000",
"Colorful": "05464601000003e803e800000000464601007803e803e80000000046460100f003e803e800000000464601003d03e803e80000000046460100ae03e803e800000000464601011303e803e800000000",
"Dazzling": "06464601000003e803e800000000464601007803e803e80000000046460100f003e803e800000000",
"Gorgeous": "07464602000003e803e800000000464602007803e803e80000000046460200f003e803e800000000464602003d03e803e80000000046460200ae03e803e800000000464602011303e803e800000000",
}
|
The scenes do work, but the colors are of course wrong. I of course could just configure custom scenes for each device, and that does work. |
@curious-ninja Pardon for jumping in, but I have several Tuya bulbs, Zigbee, BLE, WiFi, and I also investigated how Tuya and LocalTuya provides an access to pre-defined scenes. It's me who added "Default", "Mode color", "Mode scene" into the list of effects in HA light UI for LocalTuya, to activate white, color and scene modes with parameters defined in the Tuya app. You can also use "white", "color", "scene" effects in automations for them. The result of my research is: The list of scenes in the Tuya applications (SmartLife in my case), both names of the scenes and their actual values, depend on the manufacturer of a particular bulb, and can't be detected from outside. What Tuya app shows is an UI application that manufacturer has chosen, either from a set of made by Tuya, or modified, or made by himsef using Tuya developers tools. Tuya app is able to download the UI from the cloud and then run. LocalTuya can't. LocalTuya has implemented some sets of scenes with names and values taken from some devices, and uses a logic to assign a set to a particular device. The logic is not perfect, but I see no other way. Considering that it corresponds to some existing bulbs, I failed to implement support for my bulbs without breaking support for those original samples. By the way, I tried to add my Zigbee bulbs to both ZHA and Zigbee2mqtt intergations. ZHA offers no a scene list at all. Zigbee2mqtt offers a list of "effects" which is the same for different kinds of light entities, and is not relevant to RGBCW bulbs at all: blink, breathe, okay, channel_change, finish_effect, stop_effect, colorloop, stop_colorloop. You can read about them here. So, LocalTuya offers the best of what is possible outside Tuya app! 😄 |
@Lurker00 Ah ok that all makes sense. I don't know enough about tuya devices, but was assuming maybe the "product_key" values were unique to specific models and that could be used. But I guess that's not the case? My product_id is keytg5kq8gvkv9dh. Appreciate the responses guys, thanks. |
Probably, it can be used. But, you see, I just checked and found out that:
It means, meaning, somebody should support a registry of keys and scene sets from hundreds of Chinese "white box" manufacturers! Would you start such a project? 😉 |
It's possible to add a select option where user able to choose pre-set however I don't know how many scenes sets out there and what the most used and if these two set are is actually most used one.
It's also possible to make "multi select option" where it's possible to choose the set one by one however due to conflict of sets name where "night" is actually used twice seems above yet the have different values. edit: since I don't used scenes often just checked the both lights in my bedroom -- both has incorrect sets where one has similar issue to OP and other has completely different sets. |
I have quite a different issue: all my Zigbee bulbs have assigned the list of scenes by this condition: hass-localtuya/custom_components/localtuya/light.py Lines 178 to 179 in 816bd41
and I don't understand what does it mean! If it is the DP number of scene_data_v2 , yes, it is 6 for them.
The correct list is hass-localtuya/custom_components/localtuya/light.py Lines 180 to 181 in 816bd41
is False . So the logic is broken for these bulbs, but I can't offer something better, without creating database of different bulbs.
localtuya-944c1616039a1d1ec6b9745179bff74e-ВС_ Zigbee Bulb-6e477bc6604f0282c806c9399a0b3c50 (1).json |
So I made some tests it seems the scenes are not static for specific device or something, It more like a bunch of colors effects that create a scene, I tried to create custom scene on one of my light and use it on another one and it worked as well. so at the end instead of making multi scenes sets and similar to the "Tuya APP" we could just make a one set for all the lights. You can test it out: using SET DP Service quicker. Kamzai Smart Bulb
Default
So what's the goal, do we want to match the scenes with the same one as tuya app probably impossible? OR provide more scenes includes one in the app |
Hmm interesting. I suppose if there are so many scene varieties out there, there really is no method to choose the proper default set, and no method to pull from tuya app. So seems like creating a custom list manually is the solution. Would be amazing if there could be a UI that is similar to the tuya app scene designer page, and it would spit out the scene code that you can then use in the localtuya device config. This way scenes can easily be made in home assistant and the tuya app can be forgotten. |
This looks like the solution, providing we can't guess what is inside MiniApp of a particular device. We are speaking about "dj" devices, right? According to Tuya description and my experience, for a scene capable bulb, WiFi and Zigbee bulbs use the same data format, but BLE bulbs are different. But BLE (which are write-only) bulbs is another story anyway... In the current code, the set According to this document, DP for the scene value can be either 25 or 6, so that the current LocalTuya logic looks wrong. I failed to find a link to the formal description of the byte sequence that encodes a scene. But is is here as JSON. Note, that the first byte is a "scene number" 0-255 (in binary format), whatever it means. As I understand, bulbs just ignore it. |
@xZetsubou I realized that this condition hass-localtuya/custom_components/localtuya/light.py Lines 178 to 179 in 816bd41
is an attempt to tell which DP name is in use: DPCode.SCENE_DATA (the condition is true) or DPCode.SCENE_DATA_V2 (then use what we are talking about). So, you have to somehow provide LocalTuyaLight object information about the name of the CONF_SCENE DP.
Then, this condition hass-localtuya/custom_components/localtuya/light.py Lines 180 to 181 in 816bd41
has no sense, because scenes utilize only RGB LEDs, and they all compatible regardless of the while LEDs in a bulb. This condition shall be removed, and any DPCode.SCENE_DATA_V2 -capable light should be assigned the common list of scenes.
This way it should still work for all the currently supported lights, but with even better support! As I said before, the first byte (first two characters in the hex form of a scene) is a "scene number" and shall be ignored when comparing different scenes to create a set of unique scenes. |
If the DP is always lower then 20 than it uses I assume changing And maybe add change default set from entity light config, in case |
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. |
Any updates on this? Will it be left as is? Just curious |
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. |
LocalTuya Version
2024.9.0
Home Assistant Version
2024.11.2
Environment
What happened?
When I add my lights using the automatic add feature, they are assigned a set of scenes (DP 25).
The scenes are incorrect though. My scene names in the Tuya app are:
Night, Read, Working, Leisure, Soft, Colorful, Dazzling, and Gorgeous.
But this LocalTuya integration assigns these instead:
Night, Read, Meeting, Leisure, Soft, Rainbow, Shine, and Beautiful.
I took a quick look at light.py and noticed that these are 2 separate lists named "SCENE_LIST_RGBW_1000" and "SCENE_LIST_RGB_1000", respectively. The deciding factor to assign "SCENE_LIST_RGB_1000" is whether or not "CONF_BRIGHTNESS" is None. For my lights, CONF_BRIGHTNESS is in fact assigned, DP 22 bright_value_v2.
So maybe my devices aren't classified properly? My lights are being assigned to SCENE_LIST_RGBW_1000, but they should be SCENE_LIST_RGB_1000, even though the CONF_BRIGHTNESS is not None.
hass-localtuya/custom_components/localtuya/light.py
Line 180 in 54593b5
My devices are "InfiBrite Slim LED Downlight", marketed as "RGBCW", Y-CB2L-RGBCW.
https://www.infibrite.com/product/infibrite-6-inch-wifi-smart-ultra-thin-led-recessed-ceiling-light-12w-1100lm-dimmable-with-junction-box-easy-install-app-voice-control-alexa-google-compatible-etl-energy-star-wet-rated/
Also, as a side note, if I try to reconfigure an existing device manually, and modify the DP 20 entity, select DP 25 for the scene dropdown, and don't fill in anything for "(Optional) Scene values".. the typical automatically assigned default scenes are no longer there. They do no get assigned. I have to delete the device and re-add it to get them back. Is there a way around this?
Steps to reproduce.
Relevant log output
No response
Diagnostics information.
localtuya-01JCPN3WY6GNV5EFSSZQ56ZBHM-Living Room 1-2a7b2df33bf3e20a29369523401aa4fc.json
The text was updated successfully, but these errors were encountered: