Do you mean the trigger.to_state.attributes.friendly_name part? If so, do those sensors have friendly_name attributes? You can check them on the States page to be sure. You could try changing it to trigger.to_state.name, at least temporarily. A state object’s name is either its friendly_name if it has one, or its entity_id. If the problem is that those sensors don’t have a friendly_name, then just give them ones.
That’s because you only did half of what I said. You added the lines to tts_repeat, but not at the end of tts_fire_notification. The last step in tts_fire_notification should look like this:
Basically, tts_fire_notification gets the message from the automation. Then, it has to pass the message to tts_repeat, so tts_repeat can pass it back to tts_fire_notification.
And sorry about the misunderstanding with the repeat. This template stuff is pretty confusing for us hardware guys. I’ve modded the end of the fire notification thus:
script:
tts_fire_notification:
alias: 'Fire notifications on Google Homes'
sequence:
# Put some appropriate condition here that allows
# the message to continue to be repeated
# - condition: ...
- service: media_player.volume_set
data:
entity_id:
- media_player.kitchen_home
- media_player.gaming_room_home
- media_player.ensuite_speaker
- media_player.bathroom_speaker
volume_level: '0.90'
- service: tts.google_say
entity_id:
- media_player.kitchen_home
- media_player.gaming_room_home
- media_player.ensuite_speaker
- media_player.bathroom_speaker
data_template:
message: "{{ message }}"
cache: true
- delay: 00:00:30
- service: media_player.volume_set
data:
entity_id:
- media_player.kitchen_home
- media_player.gaming_room_home
- media_player.ensuite_speaker
- media_player.bathroom_speaker
volume_level: '0.50'
- service: script.tts_repeat
data_template:
message: "{{ message }}"
Did you ever get this working properly? I’ve been following this to see the outcome as I am interested in modifying it for a standard alarm system.
On the testing, I usually test scripts using a text notification to make sure all scripts and automations work and then add the real entities once I have the text push working how I like. It makes testing easier when people are in the house :).
Hi Brendan. I had to park it as I ended up in Hospital again. All clear now but have not got back to it. Last test by simulating an active alarm in the dev panel did not speak the commands correctly nor repeat. I’m intending to actually trip a smoke alarm with real smoke to see what happens and will pop the results here. Now that you’ve sparked my interest again, I might try and do it this afternoon.
UPDATE:
If I put the following, TTS reads the entity ID and in my test case, she said “smoke sensor landing” for the sensor I changed states on which was binary_sensor.smoke_sensor_landing.
The smoke detector in the {{ trigger.to_state.name
}} is activated
If however I use {{ trigger.to_state.attributes.friendly_name }}, no name is read at all. I’ll use the template editor now to see if I can figure out why no friendly name is being detected.
Odd, if I use the template editor with {{ states.binary_sensor.smoke_sensor_landing.attributes.friendly_name}}, I get “Landing” which is correct so don’t know what the automation is not saying that.
Yes. The script works but does not repeat and HA seems to get all screwed up when I fire a smoke detector using the dev panel. It works the first time but then randomly drops either the smoke detector name or the door name on subsequent triggers. Restart HA and it works again.
I think trigger can only be used in automation (the entity that triggers the automation). I don’t think you can use trigger in a script as there is no trigger. (you can pass variables to the script)