Sonos announcement issue: not playing on all group members & restore not restoring prior groups (if any)

Perfect, thanks.
Currently, I have:

  1. Perform Action (Snap shot Kitchen Sonos)
  2. Perform Action (Join rest of Sonos speakers with Kitchen Sonos)
  3. Perform Action (Set Media Player Volume on EVERY Sonos speaker to 0.6)
  4. Perform Action (Media_Player.Play_Media the desired mp3 file)
  5. Delay 5 seconds
  6. Perform Action (restore on Kitchen Sonos)

Questions:

  1. Do I need to set volume of EVERY speaker, or as they’re now joined, or just on the master (Kitchen Sonos)?

  2. Does the restore reset the volume on all the speakers, or just the entity listed?

UPDATE: Well, that experiment was a dismal failure. The announcement only played on one speaker (the primary - Kitchen).

Bummer!

So, I tried changing the order of the Media player join/snapshot, to see if that made any difference, but alas no - it still plays only on the master (Kitchen). Below is my complete automation code for:

  1. Join all Sonos speakers to Kitchen (master)
  2. Take snapshot
  3. Increase volume of Kitchen (hopefully on all, as they should now be a group)
  4. Play audio (on Kitchen only - same rationale as above)
  5. Restore snapshot (which should reset all speakers back to their original settings)

If anyone can work out why this isn’t working as planned, I’d be very interested in hearing any suggestions.

- id: '1733089602173'
  alias: Front Door Motion New
  description: ''
  triggers:
  - trigger: state
    entity_id:
    - binary_sensor.front_door_motion_sensor_motion_sensor
    from: 'off'
    to: 'on'
  conditions:
  - condition: state
    entity_id: input_boolean.front_door_motion_detected
    state: 'off'
  - condition: state
    state: closed
    entity_id: cover.main_garage
  - condition: state
    entity_id: input_boolean.sonos_announcements
    state: 'on'
  - condition: or
    conditions:
    - condition: state
      entity_id: input_boolean.darrell_at_home
      state: 'on'
    - condition: state
      entity_id: input_boolean.barbara_at_home
      state: 'on'
  actions:
  - action: media_player.join
    data:
      group_members:
      - media_player.laundry_room_sonos
      - media_player.guest_bedroom_sonos
      - media_player.darrells_office_sonos
      - media_player.barbaras_office_sonos
      - media_player.master_bedroom_sonos
    target:
      entity_id: media_player.kitchen_sonos_1
  - action: sonos.snapshot
    data:
      with_group: true
      entity_id: media_player.kitchen_sonos_1
  - action: media_player.volume_set
    data:
      volume_level: 0.77
    target:
      entity_id: media_player.kitchen_sonos_1
  - action: media_player.play_media
    data:
      media_content_id: /local/sounds/front_door_motion.mp3
      media_content_type: music
      announce: true
    target:
      entity_id: media_player.kitchen_sonos_1
  - delay:
      hours: 0
      minutes: 0
      seconds: 5
      milliseconds: 0
  - action: sonos.restore
    data:
      with_group: true
      entity_id: media_player.kitchen_sonos_1
  mode: single

I have the same issue, but didn’t get to investigate it that much as you yet. However, what I read somewhere is this:

  • announce: true means the current playback will lower volume, announcement will be played over it, and when it finishes, playback volume is restored. However, it doesn’t respect groups and when played on multiple speakers, it’s out of sync.
  • announce: false means it plays as normal media. Therefore it stops current playback, plays the announcement, and then stops. The upside is - it respects groups and plays in sync on multiple speakers.

So it looks like we can have either current playback undisturbed (continues playing after announcement), or announcement in sync on all speakers, but not both.

EDIT: This is where I found that info: Sonos media.player TTS announcement "echos" when targeting two speakers · Issue #93136 · home-assistant/core · GitHub

Thanks, Tomas.

That announce does not respect groups is interesting and worrying, as announce is a valuable option.

One approach I’ve found that ensures that audio is played on all the speakers is to create a helper “media” group, which contains all the speakers and reference that as a single entity. However, this does not guarantee that the speakers are always played synchronized. (They are for about 80-90% of the time.)

Originally, I had:

  1. Take snapshot of one speaker (usually my kitchen Sonos)
  2. Play announcement (with Announce = true)
  3. Restore, again on the same Sonos speaker

This worked fine for a while. Any music was paused, the announcement made (at the same level of the music, as I didn’t attempt to adjust volume), then music resumed after the announcement. The reason I abandoned this was (a) I could only use it the Sonos speakers - I have a mix of both Sonos and Apple HomePods, and I could never get it to work on the HomePods, and (b) sometimes the odd Sonos speaker would go “offline” for some bizarre reason.

I then started using the Chime_TTS integration, again using the helper group of speakers. This is what I have in place today. Again, it works fine, but sometimes has synchronization issues. One advantage is that I can also include HomePods, but generally there’s a 1-2 second delay between audio coming out of the Sonos and the HomePods (apparently due to the AppleTV integration). This integration also allows you to adjust the volume for any announcements and resets it afterwards.

Just my observations.

@123, would you be willing to share the script of your own invention where you use the snapshot/restore? Currently, I have my announcements working with speaker groups using join/unjoin using @Nimrod_Dolev’s Chime TTS. Announcements at in sync, but they interrupt any existing playback since I can’t use announce=true due to aforementioned sync issues. I am hoping to make them compatible with pausing/restoring existing playback. Thanks!

The announce feature can be problematic and both the Sonos and HomePod integrations have their issues, but perhaps try using the Chime TTS parameter fade_audio parameter instead of announce.

The main reason I am reluctant to share it is because I have no time to explain how it operates or how to modify it to meet other people’s needs.

Thanks for the idea, @Nimrod_Dolev. I did try it, but without preceeding with sonos.snapshot, and following with sonos.restore, the fade_audio being set to true fades out, but does not resume playback afterwards. When I add the snapshot/restore, it does work, but there seems to be a delay beyond just the time it takes to fade out the track.

Taking fade_audio aside for a moment, this seems to be working OK to pause whatever is playing, play the announcement, and then resume whatever was playing.

alias: Announcement test
sequence:
  - action: sonos.snapshot
    metadata: {}
    data:
      with_group: true
      entity_id: all
  - action: chime_tts.say
    data:
      message: hi there!
      tts_platform: microsoft
      chime_path: twenty_four
      join_players: true
      unjoin_players: true
    target:
      entity_id:
        - media_player.sonos_1
        - media_player.sonos_2
        - media_player.sonos_3
        - media_player.sonos_4
        - media_player.sonos_5
        - media_player.sonos_6
  - action: sonos.restore
    metadata: {}
    data:
      with_group: true
      entity_id: all
mode: single