mirror of
https://github.com/home-assistant/core.git
synced 2025-07-08 13:57:10 +00:00
Bugfix sonos group coordinator (#5691)
* Bugfix sonos group coordinator * Fix tests
This commit is contained in:
parent
cabc4dff03
commit
32f8622bba
@ -342,18 +342,20 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
|
|
||||||
if is_available:
|
if is_available:
|
||||||
|
|
||||||
if self._player.group.coordinator != self._player:
|
# set group coordinator
|
||||||
|
if self._player.is_coordinator:
|
||||||
|
self._coordinator = None
|
||||||
|
else:
|
||||||
try:
|
try:
|
||||||
self._coordinator = _get_entity_from_soco(
|
self._coordinator = _get_entity_from_soco(
|
||||||
self.hass, self._player.group.coordinator)
|
self.hass, self._player.group.coordinator)
|
||||||
|
|
||||||
|
# protect for loop
|
||||||
|
if not self._coordinator.is_coordinator:
|
||||||
|
# pylint: disable=protected-access
|
||||||
|
self._coordinator._coordinator = None
|
||||||
except ValueError:
|
except ValueError:
|
||||||
self._coordinator = None
|
self._coordinator = None
|
||||||
else:
|
|
||||||
self._coordinator = None
|
|
||||||
|
|
||||||
if self._coordinator == self:
|
|
||||||
_LOGGER.warning("Coordinator loop on: %s", self.unique_id)
|
|
||||||
self._coordinator = None
|
|
||||||
|
|
||||||
track_info = None
|
track_info = None
|
||||||
if self._last_avtransport_event:
|
if self._last_avtransport_event:
|
||||||
@ -957,7 +959,7 @@ class SonosDevice(MediaPlayerDevice):
|
|||||||
try:
|
try:
|
||||||
# need catch exception if a coordinator is going to slave.
|
# need catch exception if a coordinator is going to slave.
|
||||||
# this state will recover with group part.
|
# this state will recover with group part.
|
||||||
self.soco_snapshot.restore(True)
|
self.soco_snapshot.restore(False)
|
||||||
except (TypeError, SoCoException):
|
except (TypeError, SoCoException):
|
||||||
_LOGGER.debug("Error on restore %s", self.entity_id)
|
_LOGGER.debug("Error on restore %s", self.entity_id)
|
||||||
|
|
||||||
|
@ -314,4 +314,4 @@ class TestSonosMediaPlayer(unittest.TestCase):
|
|||||||
device._snapshot_coordinator.soco_device = SoCoMock('192.0.2.17')
|
device._snapshot_coordinator.soco_device = SoCoMock('192.0.2.17')
|
||||||
device.restore()
|
device.restore()
|
||||||
self.assertEqual(restoreMock.call_count, 1)
|
self.assertEqual(restoreMock.call_count, 1)
|
||||||
self.assertEqual(restoreMock.call_args, mock.call(True))
|
self.assertEqual(restoreMock.call_args, mock.call(False))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user