tuya / tuya-home-assistant

Home Assistant integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, maintained by the Home Assistant Community and Tuya Developer Team.
MIT License
870 stars 206 forks source link

Lights don't change color mode correctly when a scene is applied #695

Open quantumfrost opened 2 years ago

quantumfrost commented 2 years ago

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:

  1. Create new scene with the light. Choose a color, e.g. blue
  2. Manually switch light to white mode from home assistant
  3. Activate scene, nothing happens
  4. Manually switch light to red from home assistant
  5. 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

jonm802 commented 2 years ago

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

quantumfrost commented 2 years ago

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.

chiments commented 2 years ago

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
quantumfrost commented 2 years ago

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.

rDini commented 2 years ago

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'
ebmarquez commented 2 years ago

@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
MolloPaul commented 1 year ago

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 ().

  1. Setup and save a scene using the color mode.
  2. Check that the yaml file shows color_mode: hs
  3. Set the light manually to a colour
  4. Edit the scene and check the color mode is selected
  5. Do not save the edited scene
  6. Set the light manually to a temperature
  7. Again edit the scene and in this case check that temperature mode is selected.
  8. Do not save the edited scene
  9. 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.

lgander commented 11 months ago

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.