The HA integration is now purely a client of the NestQuest API service (Feature 18): the API owns the SQLite file, the migrations, and every business rule, so keeping a second copy of that ownership inside the integration meant two sources of truth for household state, dead wiring (the startup backfill, the day-rollover materialization and sweep listeners, the corrupt-DB handling, the admin-allowlist seeding) and settings keys nothing consumes any more. Removed the integration's re-export/DB shim modules (db, store, migrations, schema, the five DAOs, completion, children, quest_definitions, admin_allowlist, presence, presence_management, materialize, recurrence, events, sweep); the bundled domain package at custom_components/nestquest/core/ is untouched and remains the single home of those engines. Setup now builds only the API client, the snapshot coordinator, and the SSE subscription, registers the one complete_quest proxy, and forwards the platforms. The options flow keeps only the keys the client itself consumes (API base URL + panel token, update interval, staleness, panel idle timeout); the horizon, rollover, notification and admin-allowlist settings moved out with the database (the API's settings store owns horizon/rollover, and the automations take their behaviour from blueprint inputs). The integration-plane tests now script the panel route's payloads and SSE frames instead of seeding a local database; the core-plane tests keep their coverage with imports pointed at core directly.
46 lines
1.5 KiB
Python
46 lines
1.5 KiB
Python
"""Config flow for NestQuest."""
|
|
from __future__ import annotations
|
|
|
|
from typing import Any
|
|
|
|
from homeassistant import config_entries
|
|
from homeassistant.core import callback
|
|
from homeassistant.data_entry_flow import FlowResult
|
|
|
|
from .const import DOMAIN
|
|
|
|
|
|
class NestQuestConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
|
"""Handle a config flow for NestQuest."""
|
|
|
|
VERSION = 1
|
|
|
|
@staticmethod
|
|
@callback
|
|
def async_get_options_flow(
|
|
config_entry: config_entries.ConfigEntry,
|
|
) -> Any:
|
|
"""Create the options flow handler for NestQuest."""
|
|
from .options_flow import NestQuestOptionsFlow
|
|
|
|
return NestQuestOptionsFlow(config_entry=config_entry)
|
|
|
|
async def async_step_user(
|
|
self, user_input: dict[str, Any] | None = None
|
|
) -> FlowResult:
|
|
"""Handle the user step of the config flow.
|
|
|
|
The integration needs no configuration to start (the API
|
|
connection is set in the options flow), so the user input is
|
|
stored as-is. The former admin-allowlist copy is gone: with
|
|
the database removed the allowlist lives in the API service's
|
|
own store, not on the entry.
|
|
"""
|
|
await self.async_set_unique_id(DOMAIN, raise_on_progress=False)
|
|
if self._async_in_progress() or self._async_current_entries():
|
|
return self.async_abort(reason="single_instance_allowed")
|
|
|
|
if user_input is None:
|
|
return self.async_show_form(step_id="user")
|
|
|
|
return self.async_create_entry(title="NestQuest", data=dict(user_input)) |