i tried defining a variable {{ speaker_template }}
for my wait_template
. i don’t get any errors but the script doesn’t seem to follow the template conditions.
the template syntax is correct because if i place it under the wait_template directly instead of using the {{ speaker_template }}
the script will work perfectly.
is there something i’m missing?
(i initially posted this question as a follow up to my previous issue https://community.home-assistant.io/t/i-need-some-help-with-my-script-noob-warning/419748 then realized i should have created a separate topic. please forgive me for double posting)
alias: Announce Close Gate At Night
sequence:
- variables:
speaker_device: media_player.echo_show
speaker_service: notify.alexa_media
announce_volume: 0.3
announcement_msg: '{{ ("1","2","3") | random }}'
old_volume: '{{ state_attr(speaker_device,''volume_level'') | float }}'
mediaplayer_State: '{{ states(speaker_device) }}'
speaker_template: >-
{{ (speaker_device == 'media_player.echo_show' and
is_state('input_boolean.room_occupancy_study', 'on')) or (speaker_device
== 'media_player.sonos_beam' and
is_state('input_boolean.room_occupancy_living_room', 'on')) or
(speaker_device == 'media_player.kitchen_2' and
is_state('input_boolean.room_occupancy_kitchen', 'on')) or
(speaker_device == 'media_player.landing_2' and
is_state('input_boolean.room_occupancy_1st_floor', 'on')) }}
- wait_template: '{{ speaker_template }}'
timeout: '00:30:00'
continue_on_timeout: false
- condition: state
entity_id: binary_sensor.zone_gate_open
state: 'on'
- service: media_player.media_pause
target:
entity_id: '{{ speaker_device }}'
- service: media_player.volume_set
data:
volume_level: '{{ announce_volume }}'
target:
entity_id: '{{ speaker_device }}'
- service: '{{ speaker_service }}'
data:
data:
type: tts
message: '{{ announcement_msg }}'
target: '{{ speaker_device }}'
- service: media_player.volume_set
data:
volume_level: '{{ old_volume }}'
target:
entity_id: '{{ speaker_device }}'
- condition: template
value_template: '{{ mediaplayer_State == ''playing'' }}'
- delay:
hours: 0
minutes: 0
seconds: 10
milliseconds: 0
- service: media_player.media_play
target:
entity_id: '{{ speaker_device }}'
mode: parallel
max: 5
thank you
1 post - 1 participant