What is the Smart home MVP? #62

Closed
opened 2026-11-23 16:05:26 -05:00 by bobby · 2 comments
Owner

Part of #44

Question

What does the smart home domain need at MVP: which controls or automations hAPI exposes, the shape of a job sent to Home Assistant, how results/state come back, and what is explicitly deferred?

Part of #44 ## Question What does the smart home domain need at MVP: which controls or automations hAPI exposes, the shape of a job sent to Home Assistant, how results/state come back, and what is explicitly deferred?
bobby added the wayfinder:grilling label 2026-11-23 16:05:26 -05:00
bobby added a new dependency 2026-11-23 16:05:35 -05:00
bobby added a new dependency 2026-11-23 16:05:35 -05:00
Author
Owner

Unblocked by Which bridge carries jobs to Home Assistant? (ADR-0006). The Smart home domain owns Jobs (/v1/smart_home/jobs): Household data that name an HA hapi_* script plus variables, which HA polls for. HA → hAPI data is not part of the bridge: it goes to ordinary Smart home endpoints with HA acting as a Bot. The MVP decides which of those endpoints and records exist beyond Jobs. The hapi_* scripts live in a separate HA config repo.

Unblocked by [Which bridge carries jobs to Home Assistant?](https://git.bobbypalko.com/bobby/hapi/issues/55) (ADR-0006). The Smart home domain owns **Jobs** (`/v1/smart_home/jobs`): Household data that name an HA `hapi_*` script plus variables, which HA polls for. HA → hAPI data is *not* part of the bridge: it goes to ordinary Smart home endpoints with HA acting as a Bot. The MVP decides which of those endpoints and records exist beyond Jobs. The `hapi_*` scripts live in a separate HA config repo.
bobby self-assigned this 2026-11-25 14:09:17 -05:00
Author
Owner

Resolution

The Smart home MVP is Jobs only, built on ADR-0006. Bridge health (ha_bridge, job_backlog, metrics) is already settled by ADR-0009.

  • No house-state store, and no hAPI-defined automations or scenes. Home Assistant remains the source of truth for the house's state. When HA data matters to another domain (e.g. furnace runtime → a Maintenance Reading), it goes to that domain's endpoints, with HA acting as a Bot. Storing HA-pushed state and hAPI-side automations is Smart home v2.
  • Generic Jobs only (script + variables). There are no typed control endpoints (e.g. /thermostat), and hAPI keeps no script catalogue. Any documentation of the hapi_* scripts lives in the HA config repo.
  • Jobs are one-shot only, scheduled with not_before. Recurring Jobs are out of scope, because HA automations already do that.
  • State read-back works through a query Job's response (e.g. a hapi_report_locks script), with about 30 s of latency. There's no live state endpoint; real-time state stays in HA's app.
  • Idempotent creation: POST /v1/smart_home/jobs takes an optional external_id, unique per creating Principal. A repeat POST returns the existing Job with 200 instead of creating one with 201. This matches the Fitness and Maintenance convention.
  • Read and cancel API:
    • GET /v1/smart_home/jobs uses cursor pagination, newest first, with filters on status, script, recorded_by and a created-at range.
    • GET /jobs/{id} returns the full Job, including its result and attempt count.
    • POST /jobs/{id}/cancel works on pending Jobs.
    • There's no PATCH: a pending Job is cancelled and re-created, never edited.
    • Every Household member sees every Job (Jobs are Household data). A Bot needs smart_home:read to read them.
  • POST /jobs/{id}/result is the single way to finish a Job, whoever finishes it. It accepts a result from any Household member (e.g. closing a Job by hand after doing the action manually) or from any Bot with smart_home:write. It's allowed while the Job is pending, whether or not it's currently leased. Recorded by shows who resolved it. A terminal Job returns 409, so a late HA report on a hand-closed Job is harmlessly rejected. Results are not restricted to the leasing Bot in v1, since there's one consumer; revisit if a second appears.
  • In v1, Jobs come only from Persons and Bots through the API. The module exposes an internal create_job, but no domain code calls it yet; domain-triggered Jobs wait on scheduling.

Glossary: added a Smart home scope line. No new terms, and no ADR (nothing here is hard to reverse beyond ADR-0006).

## Resolution **The Smart home MVP is Jobs only**, built on [ADR-0006](https://git.bobbypalko.com/bobby/hapi/src/branch/main/docs/adr/0006-home-assistant-job-polling.md). Bridge health (`ha_bridge`, `job_backlog`, metrics) is already settled by ADR-0009. - **No house-state store, and no hAPI-defined automations or scenes.** Home Assistant remains the source of truth for the house's state. When HA data matters to another domain (e.g. furnace runtime → a Maintenance Reading), it goes to *that* domain's endpoints, with HA acting as a Bot. Storing HA-pushed state and hAPI-side automations is **Smart home v2**. - **Generic Jobs only** (`script` + `variables`). There are no typed control endpoints (e.g. `/thermostat`), and hAPI keeps no script catalogue. Any documentation of the `hapi_*` scripts lives in the HA config repo. - **Jobs are one-shot only**, scheduled with `not_before`. Recurring Jobs are **out of scope**, because HA automations already do that. - **State read-back works through a query Job's `response`** (e.g. a `hapi_report_locks` script), with about 30 s of latency. There's no live state endpoint; real-time state stays in HA's app. - **Idempotent creation:** `POST /v1/smart_home/jobs` takes an optional `external_id`, unique per creating Principal. A repeat POST returns the existing Job with `200` instead of creating one with `201`. This matches the Fitness and Maintenance convention. - **Read and cancel API:** - `GET /v1/smart_home/jobs` uses cursor pagination, newest first, with filters on `status`, `script`, `recorded_by` and a created-at range. - `GET /jobs/{id}` returns the full Job, including its result and attempt count. - `POST /jobs/{id}/cancel` works on `pending` Jobs. - There's **no PATCH**: a pending Job is cancelled and re-created, never edited. - Every Household member sees every Job (Jobs are Household data). A Bot needs `smart_home:read` to read them. - **`POST /jobs/{id}/result` is the single way to finish a Job,** whoever finishes it. It accepts a result from any Household member (e.g. closing a Job by hand after doing the action manually) or from any Bot with `smart_home:write`. It's allowed while the Job is `pending`, whether or not it's currently leased. **Recorded by** shows who resolved it. A terminal Job returns `409`, so a late HA report on a hand-closed Job is harmlessly rejected. Results are **not** restricted to the leasing Bot in v1, since there's one consumer; revisit if a second appears. - **In v1, Jobs come only from Persons and Bots through the API.** The module exposes an internal `create_job`, but no domain code calls it yet; domain-triggered Jobs wait on scheduling. Glossary: added a Smart home scope line. No new terms, and no ADR (nothing here is hard to reverse beyond ADR-0006).
bobby closed this issue 2026-11-25 14:21:44 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: bobby/hapi#62