I’d like to add a delay between two actions in an intent script, but cannot get it to work.
Two actions below (turn on TV, switch to HDMI2) work in this pattern:
TVControl:
action:
- service_template: >
{% if is_state('media_player.front_room_tv', 'off') %}
media_player.turn_on
{% endif %}
data_template:
entity_id: >
{% if is_state('media_player.front_room_tv', 'off') %}
media_player.front_room_tv
{% endif %}
- service_template: >
media_player.play_media
data_template:
entity_id: >
media_player.front_room_tv
media_content_type: >
send_key
media_content_id: >
ST_HDMI2
I want a 5 second delay before executing the second action, so I assume adding a delay: 5 would work, like this:
TVControl:
action:
- service_template: >
{% if is_state('media_player.front_room_tv', 'off') %}
media_player.turn_on
{% endif %}
data_template:
entity_id: >
{% if is_state('media_player.front_room_tv', 'off') %}
media_player.front_room_tv
{% endif %}
- delay: 5
service_template: >
media_player.play_media
data_template:
entity_id: >
media_player.front_room_tv
media_content_type: >
send_key
media_content_id: >
ST_HDMI2
But the second script fails to load in home assistant due to the delay line. Could someone point out the way to simple delay an action in this scenario?
I know, as an alternative, I could trigger a timer and have an automation finish the delayed action, but that is more messy, so I’d like to know if there is a way to do the simple delay above instead.