SONOS - Restore State

If I’m listening to music on my SONOS system and an automation kicks in and says “It’s time to feed the cat” - it would be lovely to have the system go back to playing music. Instead everything stops dead.

Is there any way of capturing the state of the SONOS. Play the automation text, and then when it’s done Restore the state and go back to what it was doing before the automation kicked in and ruined everything?

Thx :smiley:

The answer to your question is ‘Yes’. It’s achieved with the sonos.snapshot and sonos.restore service calls.

The process I use is:

  • Create snapshot (sonos.snapshot)
  • Pause any active speakers
  • Unjoin/join speakers into the desired grouping
  • Set desired volume
  • Play announcement
  • Wait for announcement to finish playing
  • Restore snapshot (sonos.restore)

EDIT

Correct typo.

3 Likes

Oh wow that’s amazing! Thanks for letting me know.

Is this something I edit in automations.yaml?

You said you have an automation that reminds you to feed your cat. At a bare minimum, modify it so that the first thing it does is call sonos.snapshot and the last thing it does is call sonos.restore.

1 Like

could you show how you’re doing this ?

Fragment from one of my automations:

  - service: media_player.play_media
    target:
      entity_id: '{{ new_group_master }}'
    data:
      media_content_id: '{{ content }}'
      media_content_type: music
  - delay: '00:00:02'
  - wait_template: "{{ states(new_group_master) != 'playing' }}"
  - service: sonos.restore
    target:
      entity_id: '{{ original_group_master }}'

The wait_template waits for the player’s state to no longer be playing.

2 Likes