Hi!
Very much newcomer to homeassistant, but impressed so far! I have a few simple items, lights, switches etc which seem to work well. I’ve integrated sonos, which appears on the Lovelace GUI, and has an inbuilt TTS funtion, which also works well. I’d like to trigger this TTS with a door switch with an automation, but the tts doesn’t seem to be controllable? how is the GUI doing it then? everything I can find online involves scripts and complexity I dont understand, while it appears to already have the function? any ideas please?
Thanks
This easiest way to do this is with a script and an automation. You will want to add the Sonos Say Script:
sonos_say:
alias: "Sonos TTS script"
sequence:
- service: sonos.snapshot
data_template:
entity_id: "{{ sonos_entity }}"
- service: media_player.volume_set
data_template:
entity_id: "{{ sonos_entity }}"
volume_level: "{{ volume }}"
- service: tts.google_say
data_template:
entity_id: "{{ sonos_entity }}"
message: "{{ message }}"
- delay: 00:00:01
- wait_template: '{{ is_state(sonos_entity, ''paused'') }}'
- service: sonos.restore
data_template:
entity_id: "{{ sonos_entity }}"
Then you want to create an automation like this:
id: Announce_Someone_at_the_BackDoor
alias: Announce Someone at the BackDoor
trigger:
- platform: state
entity_id: binary_sensor.backdoor_camera_motion
to: 'on'
action:
- service: script.sonos_say
data:
sonos_entity: media_player.living_room
volume: 0.5
message: " Hey,, there is someone at the backdoor "
I hope this help clear things up.
Thanks for the reply, I’ve tried adding the script but i’m getting
Message malformed: extra keys not allowed @ data[‘sequence’][0][‘sonos_say’]
I’m not sure where I’m going wrong?