My first automation: How do I use a variable?

I find it very difficult to find some information on how to use the helper variables. And the UI is no help either.

How do I read the value behind an input_select variable and combine it to use it as a new value?

My automation: I have some automation which do time based select different scene names into the variable input_select.sun_cycle - which works great.

I like to use those changes as trigger, when the conditions are right, to switch the scenes. This also works great - with trigger.to_state.state as variable.

But I like to switch on the automated scene as well when I come home or I turn the automation on. So I have to use multiple triggers and read the value of input_select.sun_cycle directly.

How do I do this?

I tried the following (and some other stuff) unsuccessfully.

alias: activate suncycle scenes
description: ''
trigger:
  - platform: state
    entity_id: input_select.sun_cycle
  - platform: state
    entity_id: person.ruben
    to: home
  - platform: state
    entity_id: input_boolean.virtual_sun_cycle
    to: 'on'
condition:
  - condition: state
    entity_id: person.ruben
    state: home
  - condition: state
    entity_id: input_boolean.virtual_sun_cycle
    state: 'on'
action:
  - service: scene.turn_on
    data_template:
      entity_id: 'scene.{{ states(input_select.sun_cycle) }}'
mode: restart

entity_id: "scene.{{ states('input_select.sun_cycle') }}"

1 Like

So close!

Thanks for the help, Tom.

Where is this documented? I have some trouble finding those stuff :confused: