2026-09-21 14:48:01 -04:00
|
|
|
"""Re-export of :mod:`custom_components.nestquest.core.db` for the integration package.
|
|
|
|
|
|
|
|
|
|
The async SQLite wrapper lives in :mod:`custom_components.nestquest.core.db` (extracted in task
|
|
|
|
|
d0b691d8) and is Home-Assistant-free: :class:`NestQuestDatabase` takes
|
|
|
|
|
an executor callable rather than a ``hass`` object. This module
|
|
|
|
|
re-exports it and provides :func:`make_database`, a thin adapter that
|
|
|
|
|
constructs a wrapper backed by ``hass.async_add_executor_job``, so the
|
|
|
|
|
integration constructs the database the same way it always did.
|
|
|
|
|
"""
|
2026-09-14 15:19:28 -04:00
|
|
|
from __future__ import annotations
|
|
|
|
|
|
2026-09-21 14:48:01 -04:00
|
|
|
from typing import Any, TypeVar
|
2026-09-14 15:19:28 -04:00
|
|
|
|
|
|
|
|
from homeassistant.core import HomeAssistant
|
|
|
|
|
|
2026-09-21 14:48:01 -04:00
|
|
|
from .core.db import ExecutionResult, NestQuestDatabase
|
2026-09-14 15:19:28 -04:00
|
|
|
|
2026-09-21 14:48:01 -04:00
|
|
|
__all__ = ["ExecutionResult", "NestQuestDatabase", "make_database"]
|
2026-09-14 15:19:28 -04:00
|
|
|
|
2026-09-21 14:48:01 -04:00
|
|
|
T = TypeVar("T")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def make_database(hass: HomeAssistant) -> NestQuestDatabase:
|
|
|
|
|
"""Construct a :class:`NestQuestDatabase` wired to ``hass``'s executor.
|
|
|
|
|
|
|
|
|
|
Mirrors the pre-extraction ``NestQuestDatabase(hass)`` call: the
|
|
|
|
|
wrapper's executor is ``hass.async_add_executor_job``, so every
|
|
|
|
|
sqlite3 call runs on the HA executor thread and the event loop
|
|
|
|
|
never blocks.
|
2026-09-14 15:19:28 -04:00
|
|
|
"""
|
2026-09-21 14:48:01 -04:00
|
|
|
return NestQuestDatabase(hass.async_add_executor_job)
|