Move async_deinitialize to google_assistant AbstractConfig (#109736)
parent
3294506190
commit
9d42455955
|
@ -23,7 +23,6 @@ from homeassistant.components.homeassistant.exposed_entities import (
|
|||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
||||
from homeassistant.core import (
|
||||
CALLBACK_TYPE,
|
||||
CoreState,
|
||||
Event,
|
||||
HomeAssistant,
|
||||
|
@ -145,7 +144,6 @@ class CloudGoogleConfig(AbstractConfig):
|
|||
self._prefs = prefs
|
||||
self._cloud = cloud
|
||||
self._sync_entities_lock = asyncio.Lock()
|
||||
self._on_deinitialize: list[CALLBACK_TYPE] = []
|
||||
|
||||
@property
|
||||
def enabled(self) -> bool:
|
||||
|
@ -283,13 +281,6 @@ class CloudGoogleConfig(AbstractConfig):
|
|||
)
|
||||
)
|
||||
|
||||
@callback
|
||||
def async_deinitialize(self) -> None:
|
||||
"""Remove listeners."""
|
||||
_LOGGER.debug("async_deinitialize")
|
||||
while self._on_deinitialize:
|
||||
self._on_deinitialize.pop()()
|
||||
|
||||
def should_expose(self, state: State) -> bool:
|
||||
"""If a state object should be exposed."""
|
||||
return self._should_expose_entity_id(state.entity_id)
|
||||
|
|
|
@ -105,6 +105,7 @@ class AbstractConfig(ABC):
|
|||
self._local_last_active: datetime | None = None
|
||||
self._local_sdk_version_warn = False
|
||||
self.is_supported_cache: dict[str, tuple[int | None, bool]] = {}
|
||||
self._on_deinitialize: list[CALLBACK_TYPE] = []
|
||||
|
||||
async def async_initialize(self) -> None:
|
||||
"""Perform async initialization of config."""
|
||||
|
@ -118,7 +119,14 @@ class AbstractConfig(ABC):
|
|||
"""Sync entities to Google."""
|
||||
await self.async_sync_entities_all()
|
||||
|
||||
start.async_at_start(self.hass, sync_google)
|
||||
self._on_deinitialize.append(start.async_at_start(self.hass, sync_google))
|
||||
|
||||
@callback
|
||||
def async_deinitialize(self) -> None:
|
||||
"""Remove listeners."""
|
||||
_LOGGER.debug("async_deinitialize")
|
||||
while self._on_deinitialize:
|
||||
self._on_deinitialize.pop()()
|
||||
|
||||
@property
|
||||
def enabled(self):
|
||||
|
|
Loading…
Reference in New Issue