from . import Recorder as Recorder
from .const import DOMAIN as DOMAIN
from .models import StatisticMetaData as StatisticMetaData, Statistics as Statistics, StatisticsMeta as StatisticsMeta, process_timestamp_to_utc_isoformat as process_timestamp_to_utc_isoformat
from .util import execute as execute, retryable_database_job as retryable_database_job, session_scope as session_scope
from datetime import datetime
from homeassistant.const import PRESSURE_PA as PRESSURE_PA, TEMP_CELSIUS as TEMP_CELSIUS
from homeassistant.core import Event as Event, HomeAssistant as HomeAssistant, callback as callback
from homeassistant.helpers import entity_registry as entity_registry
from homeassistant.util.unit_system import UnitSystem as UnitSystem
from sqlalchemy.orm.scoping import scoped_session as scoped_session
from typing import Any

QUERY_STATISTICS: Any
QUERY_STATISTIC_META: Any
STATISTICS_BAKERY: str
STATISTICS_META_BAKERY: str
UNIT_CONVERSIONS: Any
_LOGGER: Any

def async_setup(hass: HomeAssistant) -> None: ...
def get_start_time() -> datetime: ...
def _get_metadata_ids(hass: HomeAssistant, session: scoped_session, statistic_ids: list[str]) -> list[str]: ...
def _get_or_add_metadata_id(hass: HomeAssistant, session: scoped_session, statistic_id: str, metadata: StatisticMetaData) -> str: ...
def compile_statistics(instance: Recorder, start: datetime) -> bool: ...
def _get_metadata(hass: HomeAssistant, session: scoped_session, statistic_ids: Union[list[str], None], statistic_type: Union[str, None]) -> dict[str, dict[str, str]]: ...
def _configured_unit(unit: str, units: UnitSystem) -> str: ...
def list_statistic_ids(hass: HomeAssistant, statistic_type: Union[str, None] = ...) -> list[Union[dict[str, str], None]]: ...
def statistics_during_period(hass: HomeAssistant, start_time: datetime, end_time: Union[datetime, None] = ..., statistic_ids: Union[list[str], None] = ...) -> dict[str, list[dict[str, str]]]: ...
def get_last_statistics(hass: HomeAssistant, number_of_stats: int, statistic_id: str) -> dict[str, list[dict]]: ...
def _sorted_statistics_to_dict(hass: HomeAssistant, stats: list, statistic_ids: Union[list[str], None], metadata: dict[str, dict[str, str]]) -> dict[str, list[dict]]: ...
