Support media_player grouping services for Sonos (#63256)
This commit is contained in:
parent
d6c8f3965a
commit
754f4c52c2
3 changed files with 25 additions and 0 deletions
|
@ -14,6 +14,7 @@ from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
|||
from homeassistant.helpers.entity import DeviceInfo, Entity
|
||||
|
||||
from .const import (
|
||||
DATA_SONOS,
|
||||
DOMAIN,
|
||||
SONOS_FAVORITES_UPDATED,
|
||||
SONOS_POLL_UPDATE,
|
||||
|
@ -35,6 +36,7 @@ class SonosEntity(Entity):
|
|||
|
||||
async def async_added_to_hass(self) -> None:
|
||||
"""Handle common setup when added to hass."""
|
||||
self.hass.data[DATA_SONOS].entity_id_mappings[self.entity_id] = self.speaker
|
||||
self.async_on_remove(
|
||||
async_dispatcher_connect(
|
||||
self.hass,
|
||||
|
@ -57,6 +59,10 @@ class SonosEntity(Entity):
|
|||
)
|
||||
)
|
||||
|
||||
async def async_will_remove_from_hass(self) -> None:
|
||||
"""Clean up when entity is removed."""
|
||||
del self.hass.data[DATA_SONOS].entity_id_mappings[self.entity_id]
|
||||
|
||||
async def async_poll(self, now: datetime.datetime) -> None:
|
||||
"""Poll the entity if subscriptions fail."""
|
||||
if not self.speaker.subscriptions_failed:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue