mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 06:07:17 +00:00
Fix recorder being imported before deps are installed (#77460)
This commit is contained in:
parent
f41ba39a5e
commit
4333d9a7d1
@ -1,8 +1,6 @@
|
|||||||
"""Models for Recorder."""
|
"""Models for Recorder."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
import asyncio
|
|
||||||
from dataclasses import dataclass, field
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, TypedDict, overload
|
from typing import Any, TypedDict, overload
|
||||||
@ -32,14 +30,6 @@ class UnsupportedDialect(Exception):
|
|||||||
"""The dialect or its version is not supported."""
|
"""The dialect or its version is not supported."""
|
||||||
|
|
||||||
|
|
||||||
@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)
|
|
||||||
|
|
||||||
|
|
||||||
class StatisticResult(TypedDict):
|
class StatisticResult(TypedDict):
|
||||||
"""Statistic result data class.
|
"""Statistic result data class.
|
||||||
|
|
||||||
|
@ -1,9 +1,21 @@
|
|||||||
"""Helpers to check recorder."""
|
"""Helpers to check recorder."""
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
from dataclasses import dataclass, field
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
from homeassistant.core import HomeAssistant, callback
|
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:
|
def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
||||||
"""Check to see if a recorder migration is in progress."""
|
"""Check to see if a recorder migration is in progress."""
|
||||||
@ -18,10 +30,7 @@ def async_migration_in_progress(hass: HomeAssistant) -> bool:
|
|||||||
@callback
|
@callback
|
||||||
def async_initialize_recorder(hass: HomeAssistant) -> None:
|
def async_initialize_recorder(hass: HomeAssistant) -> None:
|
||||||
"""Initialize recorder data."""
|
"""Initialize recorder data."""
|
||||||
# pylint: disable-next=import-outside-toplevel
|
hass.data[DOMAIN] = RecorderData()
|
||||||
from homeassistant.components.recorder import const, models
|
|
||||||
|
|
||||||
hass.data[const.DOMAIN] = models.RecorderData()
|
|
||||||
|
|
||||||
|
|
||||||
async def async_wait_recorder(hass: HomeAssistant) -> bool:
|
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.
|
Returns False immediately if the recorder is not enabled.
|
||||||
"""
|
"""
|
||||||
# pylint: disable-next=import-outside-toplevel
|
# pylint: disable-next=import-outside-toplevel
|
||||||
from homeassistant.components.recorder import const
|
if DOMAIN not in hass.data:
|
||||||
|
|
||||||
if const.DOMAIN not in hass.data:
|
|
||||||
return False
|
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
|
return await db_connected
|
||||||
|
Loading…
x
Reference in New Issue
Block a user