I’m hoping someone can give me some guidance on the script below. For some reason, the audio doesn’t seem to be repeating. This is being played on my “everywhere” chromecast group when my alarm is triggered. If possible, it would be nice if someone could review the whole script for junk because I’ll be honest, I don’t really know what I’m doing just yet and pretty much just doing my best with my current abilities.
The lights seem like they are turning red and repeating until I stop them but the audio seems like it stops after 1 cycle. I honestly don’t know if I am using the wait template properly, nor do I know if it is in the correct position. I put 2 seperate “repeat” blocks because the lights default flash time is different than my audio clip so I think this is probably necessary.
So I have dumbed this down to the below at this point and it still doesn’t seem to be repeating for some reason. I will post the debugging very shortly.
Thank you all for any guidance you can give me. I am very new to all of this and it’s kicking my butt.
alias: '#TestingAlarmResponse'
sequence:
- repeat:
until:
- condition: state
entity_id: alarm_control_panel.alarmo
state: disarmed
sequence:
- wait_template: >-
"{{ is_state("media_player.everywhere_inside_except_tvs", "idle") or is_state("media_player.everywhere_inside_except_tvs", "off") or is_state("media_player.everywhere_inside_except_tvs", "paused") }}"
- service: media_player.play_media
data:
media_content_id: media-source://media_source/sounds/siren.mp3
media_content_type: music
target:
entity_id: media_player.everywhere_inside_except_tvs
mode: single
Should my wait template be a condition?-- No nevermind, that would be stupid.
EDIT:
The below fixed it. In the wait template, I didn’t have it evaluating for a condition. Now I have “==true” and all is well. Thank you all for lending me a hand.
alias: '#TestingAlarmResponse'
sequence:
- repeat:
until:
- condition: state
entity_id: alarm_control_panel.alarmo
state: disarmed
sequence:
- service: media_player.play_media
data:
media_content_id: media-source://media_source/sounds/siren.mp3
media_content_type: music
target:
entity_id: media_player.everywhere_inside_except_tvs
- wait_template: >-
{{ is_state("media_player.everywhere_inside_except_tvs", "idle") or
is_state("media_player.everywhere_inside_except_tvs", "off") or
is_state("media_player.everywhere_inside_except_tvs", "paused")== 'true' }}
mode: single
Thank you for responding because I’ll be honest, I have no clue what I’m doing, I would like it to wait if any of those 3 evaluate to true, could you show me how to do that?
Also, this is a random question but if you make a change to a script in the GUI. Do you still have to go and reload the scripts within developer tools? Or does this happen automatically?–> this could’ve been my issue if it doesn’t happen automatically.
Also, I made the change you proposed and all is working perfectly Danny!! Thank you so much!!
Coud you elaborate on the bold paragraph above, I’m really wandering if that was my issue all along.
- wait_template: >-
{{ is_state("media_player.everywhere_inside_except_tvs", "idle") or
is_state("media_player.everywhere_inside_except_tvs", "off") or
is_state("media_player.everywhere_inside_except_tvs", "paused") }}
alias: '#TestingAlarmResponse'
sequence:
- repeat:
until:
- condition: state
entity_id: alarm_control_panel.alarmo
state: disarmed
sequence:
- service: media_player.play_media
data:
media_content_id: media-source://media_source/sounds/siren.mp3
media_content_type: music
target:
entity_id: media_player.everywhere_inside_except_tvs
- wait_template: |-
{{ is_state("media_player.everywhere_inside_except_tvs", "idle") or
is_state("media_player.everywhere_inside_except_tvs", "off") or
is_state("media_player.everywhere_inside_except_tvs", "paused") }}
mode: single
On your first post. The only thing that stands out is your use of double quotes both outside and inside the template. It let you save like that?
It’s one or the other.
'{{ states(''xyz'')}}'
or
"{{ states('xyz') }}"
When you click save on the GUI it will reload the scripts for you.
If you notice besides this - wait_template: ' - wait_template:
You ended your template with 3 quotes. "paused") }}''' in this case if the wait template syntax was correct it should have been a single quote at the beginning and end of template because you used a double quotes inside the template. " not sure how it let you save with any of these syntax issues.
Ok, I thought thats how it was supposed to work but I think I had so many issues with my code was the real problem.
Could you tell me what the difference is between using “| >” or “| >-” or “| -” or even just “|” at the beginning of a template?
What I finally ended up with is below. It seems like it is working properly. But you seem very knowledgeable. Would you review this version please-- it looks like I don’t have any quotes outside of the template but I’m still pretty sure it is working properly.