Use RGB color selector as input parameter in Blueprint - help needed

I would like to create a blueprint that allows the user to enter RGB colors for a lighting automation. I would then like to use these input parameters in the automation. Unfortunately, this does not work.

I have created the RGB color selector:

rgb_color_1:
  name: Color 1
  description: The start-color of the sunrise simulation
  default: [112,21,0]
  selector:
    color_rgb:

And declared these as input variables:

variables:
  rgb_color_1: !input rgb_color_1

Now I want to call the variables in the code:

sequence:
- service: light.turn_on
  data:
    entity_id: '{{light_entity}}'
    rgb_color: '{{rgb_color_1}}'

Unfortunately, this does not work.
I am still relatively new to .yaml, so I would be very grateful for simple solutions!

“This does not work” doesn’t help us or you. How does it not work? Error messages in traces? Error messages in the logs? Type of light and integration? And post the complete code.

Oh, sorry!

With ‘Unfortunately, that doesn’t work.’ I meant the following:
If I execute the code as I have written it above, the selected light simply remains off. However, no error messages are displayed.
If I manually enter values for the rgb_color variable in the sequence, the automation works.

The complete code:

blueprint:
  name: Wake-up light alarm with color sunrise effect
  description: 'A wake-up light alarm with a brightness and color temperature sunrise
    effect. Note: Requires date_time_iso sensor in configuration, not manually executable!'
  domain: automation
  input:
    light_entity:
      name: Wake-up light entity
      description: The light to control. Turning it off during the sunrise will keep
        it off. Color temperature range is auto-detected.
      selector:
        entity:
          domain:
          - light
          multiple: false
    timestamp_sensor:
      name: Alarm timestamp sensor
      description: 'Sensor with timestamp of next alarm with device_class: timestamp
        (set to ''none'' for manual alarm time)'
      default: none
      selector:
        entity:
          device_class:
          - timestamp
          multiple: false
    manual_time:
      name: Manual alarm time
      description: Time to trigger alarm every day if timestamp sensor is not set.
        Settings at or shortly after midnight will not work as expected!
      default: '7:00:00'
      selector:
        time: {}
    check_entity:
      name: Additional entity to check before sunrise is triggered
      description: If set, checks if entity is 'on' or 'home' before triggering. Use
        e.g. a (workday) sensor, device_tracker or person entity.
      default: none
      selector:
        entity:
          multiple: false
    sunrise_duration:
      name: Sunrise duration
      description: The sunrise will start the configured number of minutes before
        the timestamp.
      default: 25
      selector:
        number:
          min: 1.0
          max: 60.0
          step: 1.0
          unit_of_measurement: min
          mode: slider
    start_brightness:
      name: Minimum brightness
      description: The brightness to start with. Some lights ignore very low values
        and may turn on with full brightness instead!
      default: 1
      selector:
        number:
          min: 1.0
          max: 255.0
          step: 1.0
          mode: slider
    end_brightness:
      name: Maximum brightness
      description: The brightness will be transitioned from the minimum to the configured
        value.
      default: 178
      selector:
        number:
          min: 1.0
          max: 255.0
          step: 1.0
          mode: slider
    rgb_color_1:
      name: Color 1
      description: The start-color of the sunrise simulation
      default: [112,21,0]
      selector:
        color_rgb:
    rgb_color_2:
      name: Color 2
      description: The second color of the sunrise simulation
      default: [160,71,31]
      selector:
        color_rgb:
    rgb_color_3:
      name: Color 3
      description: The third color of the sunrise simulation
      default: [207,120,62]
      selector:
        color_rgb:
    rgb_color_4:
      name: Color 4
      description: The end color of the sunrise simulation
      default: [255,171,97]
      selector:
        color_rgb:      
    pre_sunrise_actions:
      name: Pre-sunrise actions
      description: Optional actions to run before sunrise starts.
      default: []
      selector:
        action: {}
    post_sunrise_actions:
      name: Post-sunrise actions
      description: Optional actions to run after sunrise ends (around the alarm time).
      default: []
      selector:
        action: {}
  source_url: https://gist.github.com/sbyx/96c43b13b90ae1c35b872313ba1d2d2d
variables:
  light_entity: !input light_entity
  sensor: !input timestamp_sensor
  sunrise_duration: !input sunrise_duration
  start_brightness: !input start_brightness
  end_brightness: !input end_brightness
  range_brightness: '{{float(end_brightness)-float(start_brightness)}}'
  manual_time: !input manual_time
  seconds: '{{float(sunrise_duration) * 60}}'
  tick_time: '{{float(seconds) / float(range_brightness)}}'
  check_entity: !input check_entity
  rgb_color_1: !input rgb_color_1
  rgb_color_2: !input rgb_color_2
  rgb_color_3: !input rgb_color_3
  rgb_color_4: !input rgb_color_4
trigger:
- platform: time_pattern
  minutes: '*'
condition: []
action:
- wait_template: '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
- wait_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(states(''sensor.date_time_iso'')) <= float(seconds)
    and states(check_entity) in [''unknown'', ''on'', ''home'']}}'
- choose: []
  default: !input pre_sunrise_actions
- condition: template
  value_template: '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
- condition: template
  value_template: '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
    ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds) and states(check_entity)
    in [''unknown'', ''on'', ''home'']}}'
- choose:
  - conditions:
    - '{{state_attr(light_entity, ''min_mireds'') != None}}'
    sequence:
    - service: light.turn_on
      data:
        brightness: '{{start_brightness}}'
      entity_id: !input light_entity
  default:
  - service: light.turn_on
    data:
      brightness: '{{start_brightness}}'
    entity_id: !input light_entity
- repeat:
    while:
    - '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
    - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
      ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
    sequence:
    - delay: '{{tick_time}}'
    - choose:
      - conditions:
        - '{{0 < state_attr(light_entity, ''brightness'') | int(0) < end_brightness
          | int}}'
        - '{{sensor == ''none'' or as_timestamp(states(sensor), None) != None}}'
        - '{{0 < as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
          ~ '' '' ~ manual_time) - as_timestamp(now()) <= float(seconds)}}'
        sequence:
        - choose:
          - conditions:
            - '{{state_attr(light_entity, ''min_mireds'') != None}}'
            sequence:
            - service: light.turn_on
              data:
                entity_id: '{{light_entity}}'
                rgb_color: '{{rgb_color_1}}'
                brightness: '{{(float(end_brightness) - (float(range_brightness) *
                  (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
                  ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds)))
                  | int(0)}}'
                transition: '{{seconds / 2}}'  
            - delay:
                seconds: '{{seconds / 2}}'
            - service: light.turn_on
              data:
                entity_id: '{{light_entity}}'
                rgb_color: '{{rgb_color_2}}'
                brightness: '{{(float(end_brightness) - (float(range_brightness) *
                  (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
                  ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds)))
                  | int(0)}}'
                transition: '{{seconds / 2}}'
            - delay:
                seconds: '{{seconds / 2}}'
            - service: light.turn_on
              data:
                entity_id: '{{light_entity}}'
                rgb_color: '{{rgb_color_3}}'
                brightness: '{{(float(end_brightness) - (float(range_brightness) *
                  (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
                  ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds)))
                  | int(0)}}'
                transition: '{{seconds / 2}}'
            - delay:
                seconds: '{{seconds / 2}}'
            - service: light.turn_on
              data:
                entity_id: '{{light_entity}}'
                rgb_color: '{{rgb_color_4}}'
                brightness: '{{(float(end_brightness) - (float(range_brightness) *
                  (as_timestamp(states(sensor) if sensor != ''none'' else states(''sensor.date'')
                  ~ '' '' ~ manual_time) - as_timestamp(now())) / float(seconds)))
                  | int(0)}}'
                transition: '{{seconds / 2}}'
          default:
          - service: light.turn_on
            data:
              brightness: '{{(float(end_brightness) - (float(range_brightness) * (as_timestamp(states(sensor)
                if sensor != ''none'' else states(''sensor.date'') ~ '' '' ~ manual_time)
                - as_timestamp(now())) / float(seconds))) | int(0)}}'
            entity_id: !input light_entity
- choose: []
  default: !input post_sunrise_actions
mode: single
max_exceeded: silent

There’s a lot of code in your brightness template. Does it produce a value guaranteed to be at least 1? If the light is off and you only try to set a color without also specifying brightness or brightness_pct, or you specify it as 0, nothing will happen.

Maybe it’s text that looks like a list, try casting it as a list.

`'{{rgb_color_1 | list}}'`

Also I have this if it helps you at all…
Color-Multi-Tool

Thank you very much! The trick was to format the variable as a list. Now the automation works as it should.

1 Like