mirror of
https://github.com/home-assistant/core.git
synced 2025-08-01 03:35:09 +02:00
Fix recorder being imported before deps are installed (#77460)
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
"""Helpers to check recorder."""
|
||||
|
||||
import asyncio
|
||||
from dataclasses import dataclass, field
|
||||
from typing import Any
|
||||
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
DOMAIN = "recorder"
|
||||
|
||||
|
||||
@dataclass
|
||||
class RecorderData:
|
||||
"""Recorder data stored in hass.data."""
|
||||
|
||||
recorder_platforms: dict[str, Any] = field(default_factory=dict)
|
||||
db_connected: asyncio.Future = field(default_factory=asyncio.Future)
|
||||
|
||||
|
||||
def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
||||
"""Check to see if a recorder migration is in progress."""
|
||||
@@ -18,10 +30,7 @@ def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
||||
@callback
|
||||
def async_initialize_recorder(hass: HomeAssistant) -> None:
|
||||
"""Initialize recorder data."""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components.recorder import const, models
|
||||
|
||||
hass.data[const.DOMAIN] = models.RecorderData()
|
||||
hass.data[DOMAIN] = RecorderData()
|
||||
|
||||
|
||||
async def async_wait_recorder(hass: HomeAssistant) -> bool:
|
||||
@@ -30,9 +39,7 @@ async def async_wait_recorder(hass: HomeAssistant) -> bool:
|
||||
Returns False immediately if the recorder is not enabled.
|
||||
"""
|
||||
# pylint: disable-next=import-outside-toplevel
|
||||
from homeassistant.components.recorder import const
|
||||
|
||||
if const.DOMAIN not in hass.data:
|
||||
if DOMAIN not in hass.data:
|
||||
return False
|
||||
db_connected: asyncio.Future[bool] = hass.data[const.DOMAIN].db_connected
|
||||
db_connected: asyncio.Future[bool] = hass.data[DOMAIN].db_connected
|
||||
return await db_connected
|
||||
|
Reference in New Issue
Block a user