mirror of
https://github.com/home-assistant/core.git
synced 2025-07-10 06:47:09 +00:00
Improve Sonos error handling on slow networks (#25902)
This commit is contained in:
parent
bd8461b899
commit
cbcf49a3ba
@ -4,7 +4,7 @@
|
|||||||
"config_flow": true,
|
"config_flow": true,
|
||||||
"documentation": "https://www.home-assistant.io/components/sonos",
|
"documentation": "https://www.home-assistant.io/components/sonos",
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"pysonos==0.0.22"
|
"pysonos==0.0.23"
|
||||||
],
|
],
|
||||||
"dependencies": [],
|
"dependencies": [],
|
||||||
"ssdp": {
|
"ssdp": {
|
||||||
|
@ -102,6 +102,7 @@ class SonosData:
|
|||||||
def __init__(self, hass):
|
def __init__(self, hass):
|
||||||
"""Initialize the data."""
|
"""Initialize the data."""
|
||||||
self.entities = []
|
self.entities = []
|
||||||
|
self.discovered = []
|
||||||
self.topology_condition = asyncio.Condition()
|
self.topology_condition = asyncio.Condition()
|
||||||
|
|
||||||
|
|
||||||
@ -132,14 +133,16 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
|||||||
"""Handle a (re)discovered player."""
|
"""Handle a (re)discovered player."""
|
||||||
try:
|
try:
|
||||||
_LOGGER.debug("Reached _discovered_player, soco=%s", soco)
|
_LOGGER.debug("Reached _discovered_player, soco=%s", soco)
|
||||||
entity = _get_entity_from_soco_uid(hass, soco.uid)
|
|
||||||
|
|
||||||
if not entity:
|
if soco not in hass.data[DATA_SONOS].discovered:
|
||||||
_LOGGER.debug("Adding new entity")
|
_LOGGER.debug("Adding new entity")
|
||||||
|
hass.data[DATA_SONOS].discovered.append(soco)
|
||||||
hass.add_job(async_add_entities, [SonosEntity(soco)])
|
hass.add_job(async_add_entities, [SonosEntity(soco)])
|
||||||
else:
|
else:
|
||||||
_LOGGER.debug("Seen %s", entity)
|
entity = _get_entity_from_soco_uid(hass, soco.uid)
|
||||||
hass.add_job(entity.async_seen())
|
if entity:
|
||||||
|
_LOGGER.debug("Seen %s", entity)
|
||||||
|
hass.add_job(entity.async_seen())
|
||||||
except SoCoException as ex:
|
except SoCoException as ex:
|
||||||
_LOGGER.debug("SoCoException, ex=%s", ex)
|
_LOGGER.debug("SoCoException, ex=%s", ex)
|
||||||
|
|
||||||
@ -222,7 +225,10 @@ class _ProcessSonosEventQueue:
|
|||||||
|
|
||||||
def put(self, item, block=True, timeout=None):
|
def put(self, item, block=True, timeout=None):
|
||||||
"""Process event."""
|
"""Process event."""
|
||||||
self._handler(item)
|
try:
|
||||||
|
self._handler(item)
|
||||||
|
except SoCoException as ex:
|
||||||
|
_LOGGER.warning("Error calling %s: %s", self._handler, ex)
|
||||||
|
|
||||||
|
|
||||||
def _get_entity_from_soco_uid(hass, uid):
|
def _get_entity_from_soco_uid(hass, uid):
|
||||||
@ -318,7 +324,7 @@ class SonosEntity(MediaPlayerDevice):
|
|||||||
self._night_sound = None
|
self._night_sound = None
|
||||||
self._speech_enhance = None
|
self._speech_enhance = None
|
||||||
self._source_name = None
|
self._source_name = None
|
||||||
self._favorites = None
|
self._favorites = []
|
||||||
self._soco_snapshot = None
|
self._soco_snapshot = None
|
||||||
self._snapshot_group = None
|
self._snapshot_group = None
|
||||||
|
|
||||||
@ -748,6 +754,8 @@ class SonosEntity(MediaPlayerDevice):
|
|||||||
@property
|
@property
|
||||||
def volume_level(self):
|
def volume_level(self):
|
||||||
"""Volume level of the media player (0..1)."""
|
"""Volume level of the media player (0..1)."""
|
||||||
|
if self._player_volume is None:
|
||||||
|
return None
|
||||||
return self._player_volume / 100
|
return self._player_volume / 100
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -1404,7 +1404,7 @@ pysmarty==0.8
|
|||||||
pysnmp==4.4.9
|
pysnmp==4.4.9
|
||||||
|
|
||||||
# homeassistant.components.sonos
|
# homeassistant.components.sonos
|
||||||
pysonos==0.0.22
|
pysonos==0.0.23
|
||||||
|
|
||||||
# homeassistant.components.spc
|
# homeassistant.components.spc
|
||||||
pyspcwebgw==0.4.0
|
pyspcwebgw==0.4.0
|
||||||
|
@ -316,7 +316,7 @@ pysmartapp==0.3.2
|
|||||||
pysmartthings==0.6.9
|
pysmartthings==0.6.9
|
||||||
|
|
||||||
# homeassistant.components.sonos
|
# homeassistant.components.sonos
|
||||||
pysonos==0.0.22
|
pysonos==0.0.23
|
||||||
|
|
||||||
# homeassistant.components.spc
|
# homeassistant.components.spc
|
||||||
pyspcwebgw==0.4.0
|
pyspcwebgw==0.4.0
|
||||||
|
Loading…
x
Reference in New Issue
Block a user