Light turn on - sending the right color

Hi - I wonder if anyone here could help me map the light colors in the HA interface to a YAML data I can use into a “light turn on” automation.

Top-left is the color I want:

… however when I try this in YAML, the light’s brightness is faded, nowhere near as bright:

alias: Turn toilet lights white when day
description: ""
triggers:
  - entity_id:
      - light.0x_lkfnlsknfoirefoiernf
    from: null
    to: "on"
    trigger: state
conditions:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
actions:
  - action: light.turn_on
    metadata: {}
    data:
      brightness_pct: 100
      rgb_color:
        - 253
        - 136
        - 21
    target:
      device_id: bc06ejrnfpernfprein3poinfrionf

I’ve tried the “brightness step” and “color temperature” toggles but when used the light color does not even change anymore.

FYI the light in question is a Tuya Zigbee LED bulb (CK-BL702-AL-01) bulb connected via Z2M.

Thanks in advance for any comments or help.

One way is to use a scene. Scenes allow you to set a light to what you want and capture that. If you look at the yaml for the scene you can see the values.

Another way is to set the color you want and look at the developer tools, status tab. The entity should show the values that should give you the same color. For me it says:

1 Like

Thank you Edwin, I learned a couple of things there.

I tried adding the light parameters from the scene back into the data part of the above light.turn_on action but that did not work. Maybe scene.on and light.turn_on have different capabilities at the moment.

Anyway, I just activated the scene instead and it works well now, thanks again !

If this is the case that the parameters for light.turn_on do not produce whe same output that is weird. If so there is something going wrong with the integration. The current values for the light should be reproducible when set again. Maybe you should put in an issue with the integration owner explaining your case.

The only reason I can think of for too low brighness is confusing brightness (0-255) and brightness_pct (0-100) but you used the right one in your code example.

You don’t need to use a scene.

  1. Set the light how you want it via the GUI
  2. Observe the settings (including attributes) in the developer tools
  3. Use those settings in your automation/script.

Yes, that is what I tried to say above (I even put in a developer tools screenshot), and what the OP says did not produce the right output. That is weird.

I think we are agreed. What we need to see is

  1. The attributes of the settings he wants
  2. the automation/script that he is using.

Ok, happy to oblige.

This is the automation that works:

alias: Turn toilet lights white when day
description: ""
triggers:
  - entity_id:
      - light.0xloremipsum
    from: null
    to: "on"
    trigger: state
conditions:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
actions:
  - action: scene.turn_on
    metadata: {}
    data: {}
    target:
      entity_id: scene.new_scene

which is calling this scene:

id: "loremipsum2"
name: New scene
entities:
  light.toilette_lights:
    min_color_temp_kelvin: 2000
    max_color_temp_kelvin: 7042
    min_mireds: 142
    max_mireds: 500
    effect_list:
      - blink
      - breathe
      - okay
      - channel_change
      - finish_effect
      - stop_effect
      - colorloop
      - stop_colorloop
    supported_color_modes:
      - color_temp
      - xy
    effect: null
    color_mode: color_temp
    brightness: 255
    color_temp_kelvin: 2000
    color_temp: 500
    hs_color:
      - 30.601
      - 94.547
    rgb_color:
      - 255
      - 137
      - 14
    xy_color:
      - 0.598
      - 0.383
    friendly_name: toilette_lights
    supported_features: 44
    state: "on"
metadata: {}

And this is the automation that does not work:

alias: Turn toilet lights white when day
description: ""
triggers:
  - entity_id:
      - light.0x_lkfnlsknfoirefoiernf
    from: null
    to: "on"
    trigger: state
conditions:
  - condition: state
    entity_id: sun.sun
    state: above_horizon
actions:
  - action: light.turn_on
    metadata: {}
    data:
      color_mode: color_temp
      brightness: 255
      color_temp_kelvin: 2000
      color_temp: 500
      hs_color:
        - 30.601
        - 94.547
      rgb_color:
        - 255
        - 137
        - 14
      xy_color:
        - 0.598
        - 0.383
    target:
      device_id: bc06ejrnfpernfprein3poinfrionf

P.S. Entity references have been scrambled. Using HA core version 2024.12.5 on python 3.13.1