Helle there,
I am struggling to get the following running properly.
I wish to build an automation, which will be triggert when a FoH Switch will be double pressed for 2 seconds. The condition checks whether the state of my harmony hub is “PowerOff”. So far so good and is working like I wish. Then in the Action part, I will start an Action (Streaming) from the harmony hub, but before there should be an if else clause which checks whether the switch.energie_medien is in the state “off” and if yes, then switch it on, because this is needed, that the harmony Action could be startet successfully.
My Code looks like this:
alias: FoH Start Streaming Action with double_upper_press
description: ""
trigger:
- platform: state
entity_id: sensor.sensor_hue_foh_wohnzimmer
to: double_upper_press
for: "2"
condition:
- condition: state
entity_id: remote.harmony_hub
state: PowerOff
attribute: current_activity
action:
- service: switch.turn_on
data_template:
entity_id: >
{% if is_state('states.switch.energie_medien.state', 'off') %}- switch.energie_medien{% else %}None{% endif %}
- delay: 00:00:01
- service: remote.turn_on
data:
activity: Streaming
entity_id: remote.harmony_hub
- delay: 00:00:03
- service: media_player.turn_on
data:
entity_id: media_player.samsung_tv
So the yaml editor will not generate any error, but the part which should start the switch.energie_medien won’t be executed. When I put the Template part in the Template Engine, then there is also a problem. When I change “off” in “on” nothing changes, so I think there must be an problem with the statement.
Could someone bring some light into the darkness for me?
Any tipp or hint is much appericated.
Greetings