Guys, id need your help.
I’m trying to trigger 3 individual light scenes in an automation based on a motion sensor and an input_select. I’d like to have 2 modes. One where scenes are triggered automatically and another where scenes are set manually. The scenes have following names:
- scene.flur_hell
- scene.flur_gedimmt
- scene.flur_nachtlicht
I have set up an input_select:
flurlicht_modus:
name: Modus Flurlicht bei Bewegung
initial: "Automatisch"
icon: mdi:brightness-4
options:
- "Automatisch"
- "Hell"
- "Gedimmt"
- "Nachtlicht"
and i have a working template sensor that sets the mode for automatic scening:
- platform: template
sensors:
flur_status_autoscene:
value_template: >
{% if (states.sensor.time.state > "00:00") and (states.sensor.time.state < "06:00") %}
Nachtlicht
{% elif (states.sensor.time.state > "06:00") and (states.sensor.time.state < "20:00") %}
Hell
{% else %}
Gedimmt
{% endif %}
friendly_name: 'Flur Status Auto-Scening'
The automation I want to use looks like this:
- id: Bewegungssensor Flur Licht an
alias: Flurlicht bei Bewegungssensor
trigger:
- platform: state
entity_id: sensor.flur_motion_bewegungssensor
to: 'on'
condition:
- condition: template
value_template: '{{ states.sensor.flur_motion_bewegungssensor.attributes.lux < 10 }}'
action:
- service: scene.turn_on
data_template: >
{% if is_state('input_select.flurlicht_modus','Hell') %} scene.flur_hell
{% elif is_state('input_select.flurlicht_modus','Gedimmt') %} scene.flur_gedimmt
{% elif is_state('input_select.flurlicht_modus','Nachtlicht') %} scene.flur_nachtlicht
{% elif is_state('input_select.flurlicht_modus','Automatisch') %} scene.flur_{{states.sensor.flur_status_autoscene.state}} <== PROBLEM
{% endif %}
My problem occours in the last elif where I want to apply the state of the input_select as a variable to the name of the scene. Can anyone help?