Skip to content

feat: read-only device list endpoint + PWA section (#52) - #59

Open
mdj2812-hephaestus[bot] wants to merge 1 commit into
mainfrom
feat/pwa-device-list
Open

feat: read-only device list endpoint + PWA section (#52)#59
mdj2812-hephaestus[bot] wants to merge 1 commit into
mainfrom
feat/pwa-device-list

Conversation

@mdj2812-hephaestus

Copy link
Copy Markdown
Contributor

What

Closes #52. Registered ESP32 buttons are now visible in the PWA as a read-only section, backed by a new read endpoint.

EndpointGET /api/home_intercom/devices (HA) and GET /devices + the HA-style alias (Docker) return the registry snapshot keyed by MAC:

{
  "AA:BB:CC:DD:EE:FF": {
    "name": "Kitchen Button",
    "room": "living",
    "last_seen": "2026-07-24T08:00:00",
    "firmware_version": "1.0.0",
    "revoked": false
  }
}

PWA — an "Intercom Buttons" section under the room grid: name, bound room, firmware · last-seen per row; revoked buttons struck through. Hidden when the registry is empty or the endpoint is unavailable.

Design notes

  • Auth follows the existing split: the HA view is gated by the PWA shared token (same as RecordView) — unlike /rooms, this listing exposes device names and MACs, which are the registry's only auth material. The Docker route stays LAN-open, same trust model as /record.
  • Payload built by shared devices_payload() in shared.py so both deployment targets stay identical.
  • Read-only by design: rename / rebind / revoke live in the HA options flow (Device management UI: list / rename / rebind / revoke registered devices #48), which is where HA users expect management.
  • Renders via textContent only (no innerHTML); re-renders on language switch through a renderDevices hook in i18n.js.

Verification

  • 190 tests pass, coverage 93.72%; ruff check + ruff format clean
  • Unit: TestDevicesView (token gate → 401, payload with valid token, {} without store) + Docker route tests (empty / registered / HA alias, isolated store)
  • Smoke, both targets: Docker asserts the hello-registered MAC appears in /devices and the alias matches; HA extracts the PWA token from .storage and asserts 401-without-token + listing with token
  • Local Docker smoke: green (incl. new checks)

GET /devices (Docker) and GET /api/home_intercom/devices (both targets)
return the device registry snapshot: name, bound room, last_seen,
firmware_version, revoked — keyed by MAC.

Auth follows the existing split: the HA view is gated by the PWA shared
token (same as RecordView — device names/MACs are the registry's only
auth material, so unlike /rooms this isn't public); the Docker route
stays LAN-open, same trust model as /record. Payload built by shared
devices_payload() so both sides stay identical.

PWA: a read-only 'Intercom Buttons' section under the room grid lists
each button (name, room, firmware · last seen; revoked rows struck
through). It stays hidden when the registry is empty or the endpoint
is unavailable, renders via textContent only, and re-renders on
language switch through a renderDevices hook in i18n.js.

Tests: DevicesView unit tests (token gate, payload, no-store), Docker
route tests (empty/registered/HA alias, isolated store), and smoke
checks on both targets — Docker asserts the hello-registered MAC shows
up; HA extracts the token from .storage and asserts 401-without +
200-with.
@mdj2812-hephaestus
mdj2812-hephaestus Bot force-pushed the feat/pwa-device-list branch from 5d13791 to cdf5d56 Compare July 24, 2026 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PWA: read-only list of registered intercom buttons

1 participant