i have a script that handles how my alexa speakers makes announcements.
i call the script from my automations and can supply variables to the script so it knows which alexa device to play the notification and sets the speaker volume for the notification.
in my automation i call the service to run the script like so:
i’m trying to improve the script further by adding a room occupancy variable so that the announcement plays if someone is in that room. if there was nobody it waits until someone enters the room unless the alarm was already cleared.
so i added a condition in the script that checks the state of the particular speaker’s room occupancy boolean.
the script works fine if I use the actual boolean name ie input_boolean.room_occupancy_study, but I need that to be ‘{{ speaker_room }}’. However I get the error Message malformed: Entity {{ speaker_room }} is neither a valid entity ID nor a valid UUID for dictionary value @ data[‘sequence’][1][‘if’][0][‘entity_id’]
for a start i was going to have speaker_room as another data variable that the automation passes to the script, but i eventually want to make it more advanced by deriving the correct speaker_room value based on the speaker that is being called. maybe that could be done using a bunch of if/else statements? i haven’t figured out that part yet. i’m taking baby steps.
i’m really not programmer so whatever i’ve done is from googling and copy-pasting. but i’m quite happy with what i could achieve.
here’s the script that i’ve come up with. any pointers would be very much appreciated!
wow you’re amazing! i read that page but i never understood what it meant until you pointed to it.
i updated my script and added OR condition to the templates so that the sequence runs as long as the {{ speaker_device }} AND the room it is in is occupied. i didn’t have to use the {{ speaker_room }} variable and that saved me a ton of time!
i didn’t know how to do a template trigger, but your wait_template suggestion was such a good one!
here’s my new script. it works! i’m so pleased! thank you so much!
now i’m going to find out how to make Alexa pause if something else was playing and resume after the announcement.
Please consider marking my post above with the Solution tag. It will automatically place a check-mark next to the topic’s title which signals to other users that this topic has been resolved. This helps users find answers to similar questions. For more information refer to guideline 21 in the FAQ.
hi! hope you don’t mind, i tried defining a variable for my condition template and wait_template (since they are exactly the same) but it doesn’t seem to work for the wait_template. it works fine for the condition template. is there something i’m missing?
i think that i can actually remove the entire if block. it is actually exactly the same as the else block aside from the wait_template. so the new script is only half the length. it should work, right?
anyway still trying to figure out how to make the wait_template work with my speaker_template variable