SONOS TTS Script

Am I blind? I cannot find the solution, where is it please?? as I am having the same issue, it reads the text not the sensory values.

ahh thank you… I am blind!!

Been using this script for a couple of months (thank you!), everything has been working well. Upgraded to newest HA some days ago, after which the Sonos no longer resumes playing after TTS. Just to be clear: nothing changed with regards to any of the scripts that have something to do with TTS and playback.

Was there something in any of the recent updates that could’ve broken resume from snapshot? :-S

1 Like

Same with me, no changes other than using and now the Sonos script doesn’t work for resume and is playing the tts on all grouped speakers whereas before (I’m pretty sure?) it only played on the specified one?

1 Like

@krissen @greybags

Take a look at this thread:

3 Likes

@krissen @greybags There is a current bug with ungrouping players in scripts. Fixed in next release.

Adding a small delay after the unjoin should make it work even without the fix (not tested).

3 Likes

Thanks for the tip @amelchio it works (mostly) for me now. Definitely not as smooth as it was before though! Hopefully the next release fixes it up properly.

This should now be properly fixed with the just released version 0.65.6.

1 Like

Indeed it is, I updated and it was back to working perfectly again. Thanks for the great work!

1 Like

Upgrading to 0.65.6 did not resolve the issue for me.

(Have not tried, yet, if adding a delay makes a difference.)

In that case please file a GitHub issue with your exact script and a description of the problem that you see. I cannot keep track of bug reports in monster threads such as this one.

Done! Issue #13397.

Seems it depends on what kind of media was playing, prior to the TTS script being called. Details in the Github issue. (Also, removing unjoin didn’t help, nor did adding a delay.)

ignore please

Agreed, works fine with TuneIn and Google music but not Amazon music (haven’t tried Spotify)

At least using Spotify through the Sonos app, and then using the TTS script, works. There does seem to be some difference relating to how the stream started playing though, see the bug report above. Also, there’s a fix [ https://github.com/home-assistant/home-assistant/pull/13401 ] but don’t know if that would solve the problem for the services you mention.

Hey guys, I’ve been dealing with this problem lately…

As soon as my automation runs, if the speakers are playing a song (25%), the volume goes up abruptly for like 2-3 seconds (65%), then I can listen to the announcement and then the volume goes down again (25%). That scares the crap out of me…. So basically the audio jumps to 65% for a brief moment, before I could listen to the announcement.

I’ve noticed that the problem with the audio happens when my speakers are playing a song and when the volume is 50% or less, but if the volume is 60% or more than that, the announcement works without any problem at all… And the problem gets worse the lower I put the volume, because the music jumps to >60% for a brief moment before the announcement,

I’ve tried changing the code, but I haven’t had any luck yet to make it work properly.


sonos_say:
    alias: "Sonos TTS script"
    sequence:
      - service: media_player.sonos_snapshot
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"
      - service: media_player.volume_set
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"
          volume_level: "{{ volume|default(0.5) }}"
      - service: tts.amazon_polly_say
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"
          message: "{{ message }}"
      - delay: "{{ delay|default('00:00:00') }}"
      - wait_template: "{{ is_state(sonos_entity|default('media_player.dormitorio_ppal'), 'playing') }}"
        timeout: '00:00:05'
      - wait_template: "{{ not is_state(sonos_entity|default('media_player.dormitorio_ppal'), 'playing') }}"
        timeout: '00:02:00'
      - service: media_player.sonos_restore
        data_template:
          entity_id: "{{ sonos_entity|default('media_player.dormitorio_ppal') }}"

Try calling the media_player.media_stop service before you call media_player.volume_set.

1 Like

Thank you!!! I think it’s working now!.. =D

Am I blind or what? :roll_eyes: Hassio reports something wrong with this automations, but I cant see where :joy: I had the TTS work on another test, but I’ve done something wrong here…

required key not provided @ data[‘trigger’][0][‘platform’]

#Tvättmaskin pratar när den är klar
    - action:
      - entity_id: input_boolean.tvattmaskin
    service: input_boolean.turn_on
      - entity_id: timer.tvattmaskin
    service: timer.cancel
      alias: Tvättmaskinen startar
      condition: []
      id: 'Tvattmaskin1'
      trigger:
      - platform: template
    value_template: '{{ states.switch.tvattmaskinen_3.attributes.current_power_w < 5 }}'
    - action:
      - entity_id: timer.tvattmaskin
    service: timer.start
      alias: Tvättmaskinen stannar
      condition: []
      id: 'Tvattmaskin2'
      trigger:
      - platform: template
    value_template: '{{ states.switch.tvattmaskinen_3.attributes.current_power_w < 5 }}'
    - action:
      - entity_id: input_boolean.tvattmaskin
    service: input_boolean.turn_off
      alias: Tvättmaskinen stannar
      condition: []
      id: 'Tvattmaskin3'
      trigger:
      - entity_id: timer.tvattmaskin
    service: timer.finish
    - action:
      - service: script.turn_on
    entity_id: script.say
    data:
      message: 'Tvättmaskinen är klar.'
      alias: Tvättmaskinen talar
      condition: []
      id: 'Tvattmaskin4'
      trigger:
      - entity_id: input_boolean.tvattmaskin
    platform: state
    to: 'off'