I have a switch and depending on the time of the day I want to switch on and control different lights. To make my life easier, I want to define a target_lights
variable that is filled by only one of three inputs. The idea so far I came up with looks like this:
blueprint:
name: my automation
domain: automation
input:
target_lights_day_mode_on:
name: Lights ON Day
description: The lights to turn on.
selector:
target:
entity:
domain: light
target_lights_night_mode_on:
name: Lights ON Night
description: The lights to turn on.
selector:
target:
entity:
domain: light
target_lights_evening_mode_on:
name: Lights ON Evening
description: The lights to turn on.
selector:
target:
entity:
domain: light
defining the variables, this is the tricky part I don’t understand if even possible:
action:
- variables:
target_lights: >-
{% if states('input_text.day_mode')== 'day' %} !input target_lights_day_mode_on
{% elif states('input_text.day_mode')== 'night' %} !input target_lights_night_mode_on
{% elif states('input_text.day_mode')== 'evening' %} !input target_lights_evening_mode_on
{% endif %}
this goes then into different sequences that look like this:
sequence:
- service: light.turn_on
data:
brightness_pct: 80
color_temp_kelvin: 2700
target: "{{target_lights}}"
but as you can see it would be super handy if I could concentrat the three different inputs into 1 variable because that would spare me of writing the same seqeunce 3 times each for the different times of a day