Skip to content

Commit

Permalink
Use start helper in recorder (#79559)
Browse files Browse the repository at this point in the history
  • Loading branch information
emontnemery authored Oct 25, 2022
1 parent 02b0b19 commit beeee8b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions homeassistant/components/recorder/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@
from homeassistant.const import (
ATTR_ENTITY_ID,
EVENT_HOMEASSISTANT_FINAL_WRITE,
EVENT_HOMEASSISTANT_STARTED,
EVENT_HOMEASSISTANT_STOP,
EVENT_STATE_CHANGED,
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 (
async_track_time_change,
async_track_time_interval,
async_track_utc_time_change,
)
from homeassistant.helpers.json import JSON_ENCODE_EXCEPTIONS
from homeassistant.helpers.start import async_at_started
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
import homeassistant.util.dt as dt_util

Expand Down Expand Up @@ -407,7 +407,7 @@ async def _async_shutdown(self, event: Event) -> None:
await self.hass.async_add_executor_job(self.join)

@callback
def _async_hass_started(self, event: Event) -> None:
def _async_hass_started(self, hass: HomeAssistant) -> None:
"""Notify that hass has started."""
self._hass_started.set_result(None)

Expand All @@ -417,10 +417,7 @@ def async_register(self) -> None:
bus = self.hass.bus
bus.async_listen_once(EVENT_HOMEASSISTANT_FINAL_WRITE, self._empty_queue)
bus.async_listen_once(EVENT_HOMEASSISTANT_STOP, self._async_shutdown)
if self.hass.state == CoreState.running:
self._hass_started.set_result(None)
return
bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, self._async_hass_started)
async_at_started(self.hass, self._async_hass_started)

@callback
def async_connection_failed(self) -> None:
Expand Down

0 comments on commit beeee8b

Please sign in to comment.