TLDR; How can i set bulb color in an automation using a template based on the state of an input select?
I wanted to create a list of options for my garage lights to change them colors for holidays. My wife likes the idea of having them green for St. Pattys day and Pink for valentines day ect.
So an input select with some options seemed to be the easiest route to me. So far I have …
garage_bulb_color:
name: Garage Bulb Color
options:
- "Normal"
- "Red"
- "Orange"
- "Yellow"
- "Green"
- "Blue"
- "Indigo"
- "Violet"
- "Purple"
icon: mdi:lightbulb
initial: Normal
That part is working fine and the select is triggering my automations. The normal autoamtion works fine, the colored one however, is not seeing the color as valid (bad template) and just defaults to white for the bulb color.
- alias: Set Garage Bulb Color
trigger:
platform: state
entity_id: input_select.garage_bulb_color
condition:
condition: template
value_template: "{{ states('input_select.garage_bulb_color') != 'Normal' }}"
action:
service: light.turn_on
data:
entity_id: group.garage_lights
color_name: "{{ states.input_select.garage_bulb_color.state }}"
- alias: Set Garage Bulb Color to Normal
trigger:
platform: state
entity_id: input_select.garage_bulb_color
condition:
condition: template
value_template: "{{ is_state('input_select.garage_bulb_color', 'Normal') }}"
action:
- service: light.turn_on
data:
entity_id: group.garage_lights
color_temp: 245
brightness: 64
- service: light.turn_on
data:
entity_id: light.front_porch_light
brightness: 64
- service: light.turn_on
data:
entity_id: light.back_porch_light
brightness: 64