Hi All
Can someone please tell me why this won’t work?
- trigger:
platform: state
entity_id: sensor.hifi_input_function_raw
action:
- service: switch.turn_off
entity_id:
- switch.denon_setfunc_dstv
- switch.denon_setfunc_tuner
- switch.denon_setfunc_spotify
- service: switch.turn_on
data:
entity_id: >
switch.denon_setfunc_{{ sensor.hifi_input_function.state }}
But this works:
- trigger:
platform: state
entity_id: sensor.hifi_input_function_raw
action:
- service: switch.turn_off
entity_id:
- switch.denon_setfunc_dstv
- switch.denon_setfunc_tuner
- switch.denon_setfunc_spotify
- service: switch.turn_on
data:
entity_id: >
{% if states.sensor.hifi_input_function.state == 'tuner' %}
switch.denon_setfunc_tuner
{% elif states.sensor.hifi_input_function.state == 'dstv' %}
switch.denon_setfunc_dstv
{% elif states.sensor.hifi_input_function.state == 'spotify' %}
switch.denon_setfunc_spotify
{% endif %}
Thank you