mirror of
https://github.com/home-assistant/core.git
synced 2025-07-24 21:57:51 +00:00
Move async_deinitialize to google_assistant AbstractConfig (#109736)
This commit is contained in:
parent
3294506190
commit
9d42455955
@ -23,7 +23,6 @@ from homeassistant.components.homeassistant.exposed_entities import (
|
|||||||
from homeassistant.components.sensor import SensorDeviceClass
|
from homeassistant.components.sensor import SensorDeviceClass
|
||||||
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
||||||
from homeassistant.core import (
|
from homeassistant.core import (
|
||||||
CALLBACK_TYPE,
|
|
||||||
CoreState,
|
CoreState,
|
||||||
Event,
|
Event,
|
||||||
HomeAssistant,
|
HomeAssistant,
|
||||||
@ -145,7 +144,6 @@ class CloudGoogleConfig(AbstractConfig):
|
|||||||
self._prefs = prefs
|
self._prefs = prefs
|
||||||
self._cloud = cloud
|
self._cloud = cloud
|
||||||
self._sync_entities_lock = asyncio.Lock()
|
self._sync_entities_lock = asyncio.Lock()
|
||||||
self._on_deinitialize: list[CALLBACK_TYPE] = []
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enabled(self) -> bool:
|
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:
|
def should_expose(self, state: State) -> bool:
|
||||||
"""If a state object should be exposed."""
|
"""If a state object should be exposed."""
|
||||||
return self._should_expose_entity_id(state.entity_id)
|
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_last_active: datetime | None = None
|
||||||
self._local_sdk_version_warn = False
|
self._local_sdk_version_warn = False
|
||||||
self.is_supported_cache: dict[str, tuple[int | None, bool]] = {}
|
self.is_supported_cache: dict[str, tuple[int | None, bool]] = {}
|
||||||
|
self._on_deinitialize: list[CALLBACK_TYPE] = []
|
||||||
|
|
||||||
async def async_initialize(self) -> None:
|
async def async_initialize(self) -> None:
|
||||||
"""Perform async initialization of config."""
|
"""Perform async initialization of config."""
|
||||||
@ -118,7 +119,14 @@ class AbstractConfig(ABC):
|
|||||||
"""Sync entities to Google."""
|
"""Sync entities to Google."""
|
||||||
await self.async_sync_entities_all()
|
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
|
@property
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user