Centralize storage and updating of Sonos favorites (#50581)

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
This commit is contained in:
jjlawren 2021-05-16 04:11:35 -05:00 committed by GitHub
parent 224cc779c4
commit b84cf915f3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 127 additions and 23 deletions

View file

@ -16,6 +16,7 @@ from .const import (
DOMAIN,
SONOS_ENTITY_CREATED,
SONOS_ENTITY_UPDATE,
SONOS_HOUSEHOLD_UPDATED,
SONOS_STATE_UPDATED,
)
from .speaker import SonosSpeaker
@ -48,6 +49,13 @@ class SonosEntity(Entity):
self.async_write_ha_state,
)
)
self.async_on_remove(
async_dispatcher_connect(
self.hass,
f"{SONOS_HOUSEHOLD_UPDATED}-{self.soco.household_id}",
self.async_write_ha_state,
)
)
async_dispatcher_send(
self.hass, f"{SONOS_ENTITY_CREATED}-{self.soco.uid}", self.platform.domain
)