[HELP] Input Select for Automantion

Hello,

I want to get input select state for turn on led bulb with color_name but it doesn’t work
Sorry for my english

Here my code

input_select:
led_buld_color:
name: Led Bulb Color
options:
- White
- Tomato
- Violet
- Aquamarine
- Green
- Pink
- Red
initial: White
icon: mdi:lightbulb

automation

  • alias: Led Bulb Color
    hide_entity: False
    trigger:
    • platform: state
      entity_id: input_select.led_buld_color
      condition:
    • condition: time
      after: “07:00:00”
      action:
    • service: light.turn_on
      data:
      entity_id: group.all_lights
      brightness: 255
      color_name: ‘{{ trigger.to_state.state | string }}’
      transition: 1000

Error log

17-02-10 10:35:17 ERROR (MainThread) [homeassistant.util.color] unknown color supplied {{ trigger.to_state.state | string }} default to white

Use data_template instead of data:

- alias: Led Bulb Color
  hide_entity: False
  trigger:
    platform: state
    entity_id: input_select.led_buld_color
  condition:
    condition: time
    after: "07:00:00"
  action:
    service: light.turn_on
    data_template:
      entity_id: group.all_lights
      brightness: 255
      color_name: '{{ trigger.to_state.state | string }}'
      transition: 1000

Or you could combine the two, as long as you put your ‘color_name’ under data_template:

- alias: Led Bulb Color
  hide_entity: False
  trigger:
    platform: state
    entity_id: input_select.led_buld_color
  condition:
    condition: time
    after: "07:00:00"
  action:
    service: light.turn_on
    data:
      entity_id: group.all_lights
      brightness: 255
      transition: 1000
    data_template:
      color_name: '{{ trigger.to_state.state | string }}'

Also note that you seem to have made a typo here and there (using buld instead of bulb). I left the typo as you made the same typo in your code for the input_select.

2 Likes

Wow , many many thanks , it work perfect now.

1 Like