mirror of
https://github.com/home-assistant/core.git
synced 2025-11-09 02:49:40 +00:00
Cancel config entry retry, platform retry, and polling at the stop event (#49138)
This commit is contained in:
@@ -12,8 +12,12 @@ import voluptuous as vol
|
||||
|
||||
from homeassistant import config as conf_util
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.const import CONF_ENTITY_NAMESPACE, CONF_SCAN_INTERVAL
|
||||
from homeassistant.core import HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.const import (
|
||||
CONF_ENTITY_NAMESPACE,
|
||||
CONF_SCAN_INTERVAL,
|
||||
EVENT_HOMEASSISTANT_STOP,
|
||||
)
|
||||
from homeassistant.core import Event, HomeAssistant, ServiceCall, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import (
|
||||
config_per_platform,
|
||||
@@ -118,6 +122,8 @@ class EntityComponent:
|
||||
|
||||
This method must be run in the event loop.
|
||||
"""
|
||||
self.hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._async_shutdown)
|
||||
|
||||
self.config = config
|
||||
|
||||
# Look in config for Domain, Domain 2, Domain 3 etc and load them
|
||||
@@ -322,3 +328,9 @@ class EntityComponent:
|
||||
scan_interval=scan_interval,
|
||||
entity_namespace=entity_namespace,
|
||||
)
|
||||
|
||||
async def _async_shutdown(self, event: Event) -> None:
|
||||
"""Call when Home Assistant is stopping."""
|
||||
await asyncio.gather(
|
||||
*[platform.async_shutdown() for platform in chain(self._platforms.values())]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user