Feature 18: HA Integration as API Client #173

Merged
Member

Feature 18 — HA Integration as API Client (feature → dev)

Converts the Home Assistant integration from the owner of the NestQuest database into a thin client of the NestQuest API (Feature 16), preserving the entity and event surface the panel cards and the four automation blueprints depend on. This is the Feature 18 integration PR (all required tasks complete).

Delivered

  • api_client.py — HTTP client for the panel plane: get_snapshot(), complete_instance(id, actor_child_id), and stream_events() (SSE); typed NestQuestApiError for transport/non-2xx failures; base URL + panel token read from config (options flow + strings/translations); injectable session (no network in tests).
  • coordinator.py — polls GET /api/v1/panel/snapshot on its interval and rebuilds the existing core snapshot dataclasses, so every existing sensor entity_id and the per-child instance attribute payload shape are unchanged. Adds a configured staleness threshold and a last-good snapshot cache: within the threshold a failed fetch serves cached data (entities stay available); past it, entities go unavailable; the next success recovers without a reload.
  • sse.py — subscribes to the API SSE transition stream and re-fires the four HA bus events locally with the documented payloads; torn down on unload.
  • services.py — nestquest.complete_quest proxies to the API (the API is now the writer of record); the ten HA admin services and the permission gate are removed.
  • Database ownership removed — the integration creates no SQLite file, runs no migrations, and has no DAO/engine/business modules of its own (those live only in the bundled core/); grep -r "aiosqlite|nestquest.db|sqlite3" custom_components/nestquest/ returns nothing outside core/.

Verification

  • TZ=UTC uv run pytest -q → 1675 passed (the drop from the pre-feature 1770 is the removed DB-wiring and admin-service tests).
  • TZ=UTC uv run pytest -q orchestration_tests → 14 passed.
  • Every task PR was independently reviewed by Claude Sonnet 5 (high) at its exact head; three required remediation cycles.

Notes

  • The feature branch is 7 commits ahead of dev (d78ef19) and includes it as its base (no dev merge needed).
  • Replan during execution: the last two tasks' dependency order was swapped (remove the HA admin services before the database they used). Deferred low-severity nits are recorded on the individual Maestro tasks.
## Feature 18 — HA Integration as API Client (feature → dev) Converts the Home Assistant integration from the owner of the NestQuest database into a thin client of the NestQuest API (Feature 16), preserving the entity and event surface the panel cards and the four automation blueprints depend on. This is the Feature 18 integration PR (all required tasks complete). ### Delivered - **`api_client.py`** — HTTP client for the panel plane: `get_snapshot()`, `complete_instance(id, actor_child_id)`, and `stream_events()` (SSE); typed `NestQuestApiError` for transport/non-2xx failures; base URL + panel token read from config (options flow + strings/translations); injectable session (no network in tests). - **`coordinator.py`** — polls `GET /api/v1/panel/snapshot` on its interval and rebuilds the existing core snapshot dataclasses, so every existing sensor entity_id and the per-child instance attribute payload shape are unchanged. Adds a configured staleness threshold and a last-good snapshot cache: within the threshold a failed fetch serves cached data (entities stay available); past it, entities go unavailable; the next success recovers without a reload. - **`sse.py`** — subscribes to the API SSE transition stream and re-fires the four HA bus events locally with the documented payloads; torn down on unload. - **`services.py`** — `nestquest.complete_quest` proxies to the API (the API is now the writer of record); the ten HA admin services and the permission gate are removed. - **Database ownership removed** — the integration creates no SQLite file, runs no migrations, and has no DAO/engine/business modules of its own (those live only in the bundled `core/`); `grep -r "aiosqlite|nestquest.db|sqlite3" custom_components/nestquest/` returns nothing outside `core/`. ### Verification - `TZ=UTC uv run pytest -q` → **1675 passed** (the drop from the pre-feature 1770 is the removed DB-wiring and admin-service tests). - `TZ=UTC uv run pytest -q orchestration_tests` → **14 passed**. - Every task PR was independently reviewed by Claude Sonnet 5 (high) at its exact head; three required remediation cycles. ### Notes - The feature branch is 7 commits ahead of `dev` (`d78ef19`) and includes it as its base (no dev merge needed). - Replan during execution: the last two tasks' dependency order was swapped (remove the HA admin services before the database they used). Deferred low-severity nits are recorded on the individual Maestro tasks.
dev_agent added 7 commits 2026-09-23 09:14:01 -04:00
review_agent left a comment
Member

Independent Claude Sonnet 5 review completed for this exact commit.

Independent Claude Sonnet 5 review completed for this exact commit.
approver_agent merged commit 6059a67122 into dev 2026-09-23 09:19:49 -04:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Maniacs_Mansion/NestQuest#173