So i am running a mixture of a few peoples code to setup my welcome home announcement. It works fine no problems, as its just me in my house. But I have a few guests the come round now and again, and have setup a greeting for them as well, but in a situation where more than one guests come’s round at the same time, I feel like the automation isn’t going to work properly, and will just pickup whoever connects to the wifi first, and ignore, or just cut over any other TTS message.
I know there has been a feature request to be able to queue TTS messages, but until that comes around, would there be any way to have the automation run on wait templates, or something similar so that it would play one announcement, and then the next one afterwards.
I have wait template setup on the guest announcement to wait till the chromecast play mine is idle, but I presume if I put in a wait template for the guest automation to finish, before playing the next, it would just get stuck in a loop, and a wait template for the chromecast to be idle wouldn’t work for two people, as it would just try and do both at once ? and don’t really want to have separate automatons for each person.
Many many thanks in advance to anyone that can help out shed some light on what I might be able to do. My coding skills suck, but my copy, paste and modify to my liking isn’t too bad.
Code as follows,
- alias: Notification Audio - Welcome Home Me
trigger:
- platform: state
entity_id:
- input_boolean.si_occupancy
to: 'on'
condition:
action:
- wait_template: '{{ states.binary_sensor.motion_sensor_158d0002281e2f.state == ''on'' }}'
timeout: 00:05:00
- delay: 00:00:01
- service: script.turn_on
entity_id: script.say
data_template:
variables:
master: media_player.kitchen_speaker
volume: '.5'
what:
'{% set person = trigger.entity_id.split(''.'')[1].split(''_'')[0] %} {%- macro greeting_sentence(person) -%} {{ [
"Welcome back home " ~ person,
"Guess who is home. " ~ person + " is!",
person + " is now in the house.",
"Welcome Home " ~ person + ". We have missed you.",
"Our home is now complete, rest your head and relax your feet! Welcome Back " ~ person,
"Life is like a song, you’re back where you belong. Welcome home " ~ person,
"Hey there " ~ person + " Welcome Home!",
"Knock Knock. Who is there. " ~ person + " is!",
"I know a secret! " ~ person + " is home!" ] | random }}
{%- endmacro -%}
{{greeting_sentence(person)}}'
and then the guest one looks like this,
- alias: Notification Audio - Welcome Home Guest
trigger:
- platform: state
entity_id:
- device_tracker.fredsphone
- device_tracker.adamsiphone
- device_tracker.b853acaf7e80
- device_tracker.bobsiphone
- device_tracker.michaelsiphone
- device_tracker.claireiphone
to: home
for: 00:00:01
action:
- wait_template: '{{ states.binary_sensor.motion_sensor_158d0002281e2f.state == ''on'' }}'
timeout: 00:15:00
- delay: 00:00:05
- data:
entity_id: media_player.kitchen_speaker
service: media_player.turn_on
- wait_template: '{{ states.media_player.kitchen_speaker.state == ''idle'' }}'
timeout: 00:15:00
- service: script.turn_on
entity_id: script.say
data_template:
variables:
master: media_player.kitchen_speaker
volume: '.5'
what: '{% set person = trigger.to_state.attributes.friendly_name %} {%- macro greeting_sentence(person) -%} {{ [