mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use start helper in recorder (#79559)
This commit is contained in:
parent
02b0b19dd4
commit
beeee8b60e
@ -26,18 +26,18 @@ from homeassistant.components import persistent_notification
|
|||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_ENTITY_ID,
|
ATTR_ENTITY_ID,
|
||||||
EVENT_HOMEASSISTANT_FINAL_WRITE,
|
EVENT_HOMEASSISTANT_FINAL_WRITE,
|
||||||
EVENT_HOMEASSISTANT_STARTED,
|
|
||||||
EVENT_HOMEASSISTANT_STOP,
|
EVENT_HOMEASSISTANT_STOP,
|
||||||
EVENT_STATE_CHANGED,
|
EVENT_STATE_CHANGED,
|
||||||
MATCH_ALL,
|
MATCH_ALL,
|
||||||
)
|
)
|
||||||
from homeassistant.core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback
|
from homeassistant.core import CALLBACK_TYPE, Event, HomeAssistant, callback
|
||||||
from homeassistant.helpers.event import (
|
from homeassistant.helpers.event import (
|
||||||
async_track_time_change,
|
async_track_time_change,
|
||||||
async_track_time_interval,
|
async_track_time_interval,
|
||||||
async_track_utc_time_change,
|
async_track_utc_time_change,
|
||||||
)
|
)
|
||||||
from homeassistant.helpers.json import JSON_ENCODE_EXCEPTIONS
|
from homeassistant.helpers.json import JSON_ENCODE_EXCEPTIONS
|
||||||
|
from homeassistant.helpers.start import async_at_started
|
||||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||||
import homeassistant.util.dt as dt_util
|
import homeassistant.util.dt as dt_util
|
||||||
|
|
||||||
@ -407,7 +407,7 @@ class Recorder(threading.Thread):
|
|||||||
await self.hass.async_add_executor_job(self.join)
|
await self.hass.async_add_executor_job(self.join)
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def _async_hass_started(self, event: Event) -> None:
|
def _async_hass_started(self, hass: HomeAssistant) -> None:
|
||||||
"""Notify that hass has started."""
|
"""Notify that hass has started."""
|
||||||
self._hass_started.set_result(None)
|
self._hass_started.set_result(None)
|
||||||
|
|
||||||
@ -417,10 +417,7 @@ class Recorder(threading.Thread):
|
|||||||
bus = self.hass.bus
|
bus = self.hass.bus
|
||||||
bus.async_listen_once(EVENT_HOMEASSISTANT_FINAL_WRITE, self._empty_queue)
|
bus.async_listen_once(EVENT_HOMEASSISTANT_FINAL_WRITE, self._empty_queue)
|
||||||
bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._async_shutdown)
|
bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._async_shutdown)
|
||||||
if self.hass.state == CoreState.running:
|
async_at_started(self.hass, self._async_hass_started)
|
||||||
self._hass_started.set_result(None)
|
|
||||||
return
|
|
||||||
bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, self._async_hass_started)
|
|
||||||
|
|
||||||
@callback
|
@callback
|
||||||
def async_connection_failed(self) -> None:
|
def async_connection_failed(self) -> None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user