Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid playing queue pollution when restoring Sonos snapshots #21963

merged 1 commit into from Mar 12, 2019


None yet
3 participants
Copy link

amelchio commented Mar 12, 2019


A follow-up to #21411, improving restore in some cases. Details in the commit message.

Since this is quite tricky and I am working on further refinements before the beta, I will assume lazy consensus if I get no objections within 12 hours.

Example entry for configuration.yaml (if applicable):

      - service: media_player.sonos_unjoin
          - media_player.a
          - media_player.b
          - media_player.c
      - delay: 5
      - service: media_player.sonos_join
          master: media_player.a
          entity_id: media_player.b
      - delay: 5
      - service: media_player.sonos_snapshot
      - service: media_player.sonos_unjoin
          - media_player.b
      - delay: 5
      - service: media_player.sonos_join
          master: media_player.b
          entity_id: media_player.c
      - delay: 5
      - service: media_player.sonos_restore
      # media_player.c is now playing a new queue


  • The code change is tested and works locally.
  • Local tests pass with tox.
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.
Avoid playing queue pollution when restoring Sonos snapshots
Assume a snapshot state with three speakers in two groups, AB and C. They will
be playing the A and C queues, respectively. The B queue exists but is hidden
in this topology.

Unjoin B and form a new group BC, playing the B queue (now with the C queue

To restore the snapshot we would join B back to A. The BC group would now only
contain the C speaker, still playing the B queue. The C queue has been lost :-(

The problem is that unjoining a coordinator will elect a new coordinator that
inherits the group queue and thus has its hidden queue overwritten.

This commit avoids the situation by having restore unjoin all slaves. Above, C
would be unjoined before joining B to A. This restores the C queue and since B
is then alone, it can be joined to A without having to transfer its playing
queue to remaining speakers.
Copy link

pvizeli left a comment

Is not all time easy :) I written the first version of that restore/snapshot feature

@pvizeli pvizeli merged commit dd11f8d into home-assistant:dev Mar 12, 2019

4 checks passed

Hound No violations found. Woof!
cla-bot Everyone involved has signed the CLA
continuous-integration/travis-ci/pr The Travis CI build passed
coverage/coveralls Coverage increased (+0.002%) to 92.827%

@wafflebot wafflebot bot removed the in progress label Mar 12, 2019

@balloob balloob referenced this pull request Mar 20, 2019


0.90.0 #22216

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.