tuya-home-assistant
tuya-home-assistant copied to clipboard
Lights don't change color mode correctly when a scene is applied
Describe the bug If a light is in white mode, and the scene specifies a color, the light doesn't switch to color mode when the scene is activated. If the light was already in color mode, it switches to the correct color when the scene is activated.
To reproduce:
- Create new scene with the light. Choose a color, e.g. blue
- Manually switch light to white mode from home assistant
- Activate scene, nothing happens
- Manually switch light to red from home assistant
- Activate scene, now it correctly switches to blue
Expected behavior The light should switch to color mode according to the scene.
Home Assistant Version 2021.11.4
Device info (please complete the following information, which can be found in log): I followed the instructions in the link, but there was nothing in the log
Additional context Tried it with many different brand/model Tuya lights
This behaviour is the same when you use automation to set specific lighting levels/colour
you cant set the warmth/brightness and colour the same time
the short work around is to manually edit your scenes yaml file, remove what you don't need
if your setting a colour mode remove the brightness/colour temp
if your setting a colour mode remove the brightness/colour temp
Unfortunately, for many of my scenes, I need to set both color and brightness. So the only option is to turn my scenes into scripts, with two service calls for each light. Plus, you need a delay of at least 1 s between setting the color and brightness, otherwise it doesn't work or turns back to white mode. That isn't as maintainable or easy to edit as a scene.
Same for me, exactly this behavior - tried multiple combinations in yaml and such.
I have also noticed that this also happens when trying to set the color manually by a button. Will work when already set to a color, but when the bulb is white and vice versa.
System Health
version | core-2021.11.5 |
---|---|
installation_type | Home Assistant OS |
dev | false |
hassio | true |
docker | true |
user | root |
virtualenv | false |
python_version | 3.9.7 |
os_name | Linux |
os_version | 5.10.75 |
arch | x86_64 |
timezone | America/Winnipeg |
Home Assistant Community Store
GitHub API | ok |
---|---|
Github API Calls Remaining | 4178 |
Installed Version | 1.18.0 |
Stage | running |
Available Repositories | 974 |
Installed Repositories | 23 |
AccuWeather
can_reach_server | ok |
---|---|
remaining_requests | 17 |
Home Assistant Cloud
logged_in | false |
---|---|
can_reach_cert_server | ok |
can_reach_cloud_auth | ok |
can_reach_cloud | ok |
Home Assistant Supervisor
host_os | Home Assistant OS 6.6 |
---|---|
update_channel | stable |
supervisor_version | supervisor-2021.10.8 |
docker_version | 20.10.8 |
disk_total | 30.8 GB |
disk_used | 7.0 GB |
healthy | true |
supported | true |
board | ova |
supervisor_api | ok |
version_api | ok |
installed_addons | Mosquitto broker (6.0.1), Visual Studio Code (3.6.2), TasmoAdmin (0.16.0), SSH & Web Terminal (9.1.1), CEC Scanner (3.0), motionEye (0.16.0) |
Lovelace
dashboards | 1 |
---|---|
resources | 10 |
views | 7 |
mode | storage |
I just decided to get rid of this buggy mess of an integration and go with Local Tuya. It responds faster and also allows you to set color and brightness simultaneously.
I just found out. You need to remove :
brightness: 255
Example:
name: Red
entities:
light.escri_1:
# supported_color_modes:
# - brightness
# - color_temp
# - hs
# - onoff
# brightness: 255
color_name: red
friendly_name: escri 1
state: 'on'
Most of the code are "default" so no need to keep them.
The following examples will works
light.corre_3:
transition: 3
color_mode: hs
hs_color:
- 360
- 100
friendly_name: corre 3
state: 'on'
light.corre_3:
color_name: red
friendly_name: corre 3
state: 'on'
For brightness I'm making a separated scene:
light.corre_3:
brightness: 60
friendly_name: corre 3
state: 'on'
@rDini thanks for the snips, this helped me with my lights. I updated my scene.yaml and I removed the supported_color_modes section and removed brightness. I also saw some people updated supported_features to 63. Once I did all three and restarted HA, the lights worked as expected.
# Define an entity for a Tuya smart light bulb
- id: '1661801893318'
name: After Hours Desk Lamp
entities:
# Define the entity ID for the light bulb
light.desk_color_lights:
# Define the minimum and maximum color temperature values
min_mireds: 153
max_mireds: 500
# Set the color mode to "hs"
color_mode: hs
# Define the hue and saturation values
hs_color:
- 360
- 100
# Define the red, green, and blue values
rgb_color:
- 255
- 0
- 0
# Define the x and y values
xy_color:
- 0.701
- 0.299
# Set a friendly name for the light bulb
friendly_name: Desk Color Lights
# Set the supported features to all
supported_features: 63
# Set the state to "on"
state: 'on'
# Define any additional metadata for the entity
metadata: {}
# Set the icon to use for the entity in the Home Assistant UI
icon: mdi:desk-lamp
Same for me, exactly this behavior. However the behavior now carries over to the Scene Editor. The displayed color mode in the scene editor is dependent on the current color mode of the light and not the contents of the yaml file.
System information Version core-2022.9.2 Installation Type Home Assistant OS Development false Supervisor true Docker true User root Virtual Environment false Python Version 3.10.5 Operating System Family Linux Operating System Version 5.15.60 CPU Architecture x86_64 Timezone Australia/Sydney Configuration Directory /config
To replicate ().
- Setup and save a scene using the color mode.
- Check that the yaml file shows color_mode: hs
- Set the light manually to a colour
- Edit the scene and check the color mode is selected
- Do not save the edited scene
- Set the light manually to a temperature
- Again edit the scene and in this case check that temperature mode is selected.
- Do not save the edited scene
- Check that the yaml file is unchanged
This suggests that when the yaml file is parsed the colour mode returned is the current mode of the device NOT the contents of the YAML File.
Thanks! Using Local Tuya was a nightmare. Disconnections every day. But Tuya Local had this problem and just deleting the Brightness setting worked!
The only thing that got me struggling is that when I switch between scenes using automations and those scenes only changes brightness of lights with a temperature setting, the brightness doesn't change. Activating the scenes manually works, but not if they are switched using automations. This works fine with Loca Tuya, but not with Tuya Local. If any of you got any ideas to try, I'll be happy to read them.