mirror of
https://github.com/home-assistant/core.git
synced 2026-12-04 12:50:45 -04:00
Import names from their source modules in recorder (#187469)
This commit is contained in:
@@ -16,7 +16,7 @@ from homeassistant.helpers.entityfilter import (
|
||||
from homeassistant.helpers.integration_platform import (
|
||||
async_process_integration_platforms,
|
||||
)
|
||||
from homeassistant.helpers.recorder import DATA_INSTANCE
|
||||
from homeassistant.helpers.recorder import DATA_INSTANCE, get_instance
|
||||
from homeassistant.helpers.typing import ConfigType
|
||||
from homeassistant.util.event_type import EventType
|
||||
|
||||
@@ -40,7 +40,6 @@ from .core import Recorder
|
||||
from .entity_options import is_entity_recorded
|
||||
from .services import async_setup_services
|
||||
from .tasks import AddRecorderPlatformTask
|
||||
from .util import get_instance
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -9,9 +9,10 @@ from sqlalchemy.exc import OperationalError
|
||||
from sqlalchemy.orm import DeclarativeBase
|
||||
from sqlalchemy.orm.attributes import InstrumentedAttribute
|
||||
|
||||
from homeassistant.helpers.recorder import session_scope
|
||||
|
||||
from ..const import SupportedDialect
|
||||
from ..db_schema import DOUBLE_PRECISION_TYPE_SQL, DOUBLE_TYPE, MYSQL_COLLATE
|
||||
from ..util import session_scope
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .. import Recorder
|
||||
|
||||
@@ -4,8 +4,9 @@ from logging import getLogger
|
||||
|
||||
from homeassistant.core import CoreState, HomeAssistant
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.recorder import get_instance
|
||||
|
||||
from .util import async_migration_in_progress, get_instance
|
||||
from .util import async_migration_in_progress
|
||||
|
||||
_LOGGER = getLogger(__name__)
|
||||
|
||||
|
||||
@@ -7,9 +7,9 @@ import probatio
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import recorder as recorder_helper
|
||||
from homeassistant.helpers.recorder import get_instance
|
||||
|
||||
from . import get_default_url
|
||||
from .util import get_instance
|
||||
|
||||
|
||||
@callback
|
||||
|
||||
@@ -41,7 +41,7 @@ from homeassistant.helpers.event import (
|
||||
async_track_time_interval,
|
||||
async_track_utc_time_change,
|
||||
)
|
||||
from homeassistant.helpers.recorder import DATA_RECORDER
|
||||
from homeassistant.helpers.recorder import DATA_RECORDER, session_scope
|
||||
from homeassistant.helpers.start import async_at_started
|
||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -112,7 +112,6 @@ from .util import (
|
||||
end_incomplete_runs,
|
||||
is_second_sunday,
|
||||
move_away_broken_database,
|
||||
session_scope,
|
||||
setup_connection_for_dialect,
|
||||
validate_or_move_away_sqlite_database,
|
||||
write_lock_db_sqlite,
|
||||
|
||||
@@ -9,8 +9,7 @@ import probatio
|
||||
from homeassistant.components import websocket_api
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
|
||||
from .util import get_instance
|
||||
from homeassistant.helpers.recorder import get_instance
|
||||
|
||||
|
||||
def is_entity_recorded(hass: HomeAssistant, entity_id: str) -> bool:
|
||||
|
||||
@@ -7,10 +7,11 @@ from homeassistant.core import Event, HomeAssistant, callback
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
from homeassistant.helpers.event import async_has_entity_registry_updated_listeners
|
||||
from homeassistant.helpers.recorder import get_instance, session_scope
|
||||
|
||||
from .core import Recorder
|
||||
from .statistics import async_update_statistics_metadata
|
||||
from .util import filter_unique_constraint_integrity_error, get_instance, session_scope
|
||||
from .util import filter_unique_constraint_integrity_error
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ from sqlalchemy.orm.session import Session
|
||||
|
||||
from homeassistant.const import COMPRESSED_STATE_LAST_UPDATED, COMPRESSED_STATE_STATE
|
||||
from homeassistant.core import HomeAssistant, State, split_entity_id
|
||||
from homeassistant.helpers.recorder import get_instance
|
||||
from homeassistant.helpers.recorder import get_instance, session_scope
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.collection import chunked_or_all
|
||||
|
||||
@@ -41,7 +41,7 @@ from ..models import (
|
||||
extract_metadata_ids,
|
||||
row_to_compressed_state,
|
||||
)
|
||||
from ..util import execute_stmt_lambda_element, session_scope
|
||||
from ..util import execute_stmt_lambda_element
|
||||
from .const import (
|
||||
LAST_CHANGED_KEY,
|
||||
NEED_ATTRIBUTE_DOMAINS,
|
||||
|
||||
@@ -37,6 +37,7 @@ from sqlalchemy.sql.lambdas import StatementLambdaElement
|
||||
from sqlalchemy.types import BINARY
|
||||
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.recorder import session_scope
|
||||
from homeassistant.util.enum import try_parse_enum
|
||||
from homeassistant.util.ulid import ulid_at_time, ulid_to_bytes
|
||||
|
||||
@@ -122,7 +123,6 @@ from .util import (
|
||||
execute_stmt_lambda_element,
|
||||
get_index_by_name,
|
||||
retryable_database_job_method,
|
||||
session_scope,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
"""Models for Recorder."""
|
||||
|
||||
from .context import (
|
||||
bytes_to_ulid_or_none,
|
||||
bytes_to_uuid_hex_or_none,
|
||||
ulid_to_bytes_or_none,
|
||||
uuid_hex_to_bytes_or_none,
|
||||
)
|
||||
from homeassistant.util.ulid import bytes_to_ulid_or_none, ulid_to_bytes_or_none
|
||||
|
||||
from .context import bytes_to_uuid_hex_or_none, uuid_hex_to_bytes_or_none
|
||||
from .database import DatabaseEngine, DatabaseOptimizer, UnsupportedDialect
|
||||
from .event import extract_event_type_ids
|
||||
from .state import LazyState, extract_metadata_ids, row_to_compressed_state
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from sqlalchemy.orm.session import Session
|
||||
|
||||
from homeassistant.helpers.recorder import session_scope
|
||||
from homeassistant.util.collection import chunked_or_all
|
||||
|
||||
from .db_schema import Events, States, StatesMeta
|
||||
@@ -39,7 +40,7 @@ from .queries import (
|
||||
find_statistics_runs_to_purge,
|
||||
)
|
||||
from .repack import repack_database
|
||||
from .util import retryable_database_job, session_scope
|
||||
from .util import retryable_database_job
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from . import Recorder
|
||||
|
||||
@@ -30,11 +30,15 @@ from sqlalchemy.exc import SQLAlchemyError
|
||||
from sqlalchemy.orm.session import Session
|
||||
from sqlalchemy.sql.lambdas import StatementLambdaElement
|
||||
|
||||
from homeassistant.const import EntityStateAttribute
|
||||
from homeassistant.const import (
|
||||
EVENT_RECORDER_5MIN_STATISTICS_GENERATED,
|
||||
EVENT_RECORDER_HOURLY_STATISTICS_GENERATED,
|
||||
EntityStateAttribute,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback, valid_entity_id
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers.frame import report_usage
|
||||
from homeassistant.helpers.recorder import DATA_RECORDER
|
||||
from homeassistant.helpers.recorder import DATA_RECORDER, get_instance, session_scope
|
||||
from homeassistant.helpers.singleton import singleton
|
||||
from homeassistant.helpers.typing import UNDEFINED, UndefinedType
|
||||
from homeassistant.util import dt as dt_util
|
||||
@@ -78,8 +82,6 @@ from homeassistant.util.unit_conversion import (
|
||||
|
||||
from .const import (
|
||||
DOMAIN,
|
||||
EVENT_RECORDER_5MIN_STATISTICS_GENERATED,
|
||||
EVENT_RECORDER_HOURLY_STATISTICS_GENERATED,
|
||||
INTEGRATION_PLATFORM_COMPILE_STATISTICS,
|
||||
INTEGRATION_PLATFORM_CUSTOM_EQUIVALENT_UNITS,
|
||||
INTEGRATION_PLATFORM_LIST_STATISTIC_IDS,
|
||||
@@ -109,9 +111,7 @@ from .util import (
|
||||
execute,
|
||||
execute_stmt_lambda_element,
|
||||
filter_unique_constraint_integrity_error,
|
||||
get_instance,
|
||||
retryable_database_job,
|
||||
session_scope,
|
||||
)
|
||||
|
||||
if TYPE_CHECKING:
|
||||
|
||||
@@ -6,11 +6,11 @@ from sqlalchemy.engine.url import make_url
|
||||
|
||||
from homeassistant.components import system_health
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
from homeassistant.helpers.recorder import session_scope
|
||||
|
||||
from .. import get_instance
|
||||
from ..const import SupportedDialect
|
||||
from ..core import Recorder
|
||||
from ..util import session_scope
|
||||
from .mysql import db_size_bytes as mysql_db_size_bytes
|
||||
from .postgresql import db_size_bytes as postgresql_db_size_bytes
|
||||
from .sqlite import db_size_bytes as sqlite_db_size_bytes
|
||||
|
||||
@@ -9,14 +9,14 @@ import logging
|
||||
import threading
|
||||
from typing import TYPE_CHECKING, Any, override
|
||||
|
||||
from homeassistant.helpers.recorder import DATA_RECORDER
|
||||
from homeassistant.helpers.recorder import DATA_RECORDER, session_scope
|
||||
from homeassistant.helpers.typing import UndefinedType
|
||||
from homeassistant.util.event_type import EventType
|
||||
|
||||
from . import entity_registry, purge, statistics
|
||||
from .db_schema import Statistics, StatisticsShortTerm
|
||||
from .models import StatisticData, StatisticMetaData
|
||||
from .util import periodic_db_cleanups, session_scope
|
||||
from .util import periodic_db_cleanups
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ from homeassistant.core import HomeAssistant, callback, valid_entity_id
|
||||
from homeassistant.exceptions import HomeAssistantError
|
||||
from homeassistant.helpers import config_validation as cv
|
||||
from homeassistant.helpers.json import json_bytes
|
||||
from homeassistant.helpers.recorder import get_instance
|
||||
from homeassistant.helpers.typing import UNDEFINED
|
||||
from homeassistant.util import dt as dt_util
|
||||
from homeassistant.util.unit_conversion import (
|
||||
@@ -63,7 +64,7 @@ from .statistics import (
|
||||
update_statistics_issues,
|
||||
validate_statistics,
|
||||
)
|
||||
from .util import PERIOD_SCHEMA, get_instance, resolve_period
|
||||
from .util import PERIOD_SCHEMA, resolve_period
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user