Hi,
The following automation runs a script that uses an input_select as variable:
action: call-service
service: script.toggle_light
service_data:
light_brightness: 80
light_kelvin: 6000
light_scene_id: evening
And the script is the following:
alias: Toggle light
sequence:
- choose:
- conditions:
- alias: Light was off, active a light mode
condition: state
entity_id: input_select.light_mode
state: light_off
sequence:
- service: light.turn_on
target:
entity_id:
- "{{light_in_living_room}}"
- light.lights_bar
data:
brightness: "{{light_brightness}}"
kelvin: "{{light_kelvin}}"
transition: 2
- service: input_select.select_option
target:
entity_id: input_select.light_mode
data:
option: "{{light_scene_id}}"
- conditions:
- alias: light mode is selected again, light is turned off
condition: state
entity_id: input_select.light_mode
state: "{{light_scene_id}}"
sequence:
- service: light.turn_off
target:
entity_id:
- "{{light_in_living_room}}"
- light.lights_bar
- service: input_select.select_option
target:
entity_id: input_select.light_mode
data:
option: light_off
default:
- alias: Another mode is selected
service: light.turn_on
target:
entity_id:
- "{{light_in_living_room}}"
- light.lights_bar
data:
brightness: "{{light_brightness}}"
kelvin: "{{light_kelvin}}"
transition: 2
- service: input_select.select_option
target:
entity_id: input_select.light_mode
data:
option: "{{light_scene_id}}"
mode: single
icon: mdi:lightbulb
If the lights are off, then it goes to the first condition, turns the lights on and changes input_select.light_mode to “evening”, everything is ok.
Now, running the automation another time leads to the second condition, and here nothing happens, state: “{{light_scene_id}}” doesn’t seem to work. If I replace it with state: “evening” then it works. How can I solve this issue?
I hope that my my problem is clear, otherwise please let me know.
Thanks for your help!