Skip to content

support the kegboard v4 protocol - #456

Merged
mik3y merged 8 commits into
mainfrom
mikey/kegboard-protocol
Aug 6, 2026
Merged

support the kegboard v4 protocol#456
mik3y merged 8 commits into
mainfrom
mikey/kegboard-protocol

Conversation

@mik3y

@mik3y mik3y commented Aug 5, 2026

Copy link
Copy Markdown
Member

Part of #452, and the server-side peer of Kegbot/kegboard#21.

mik3y added 8 commits August 5, 2026 09:51
Groundwork for the kegboard event protocol: a paired controller holds
its bearer token; drinks carry the device-assigned pour_id (unique,
the dedup and correlation key).
POST /kegboard-event implements the kegboard event protocol: bearer
auth, dashboard-driven pairing over 401 responses (one-shot token
delivery via a consumable redis slot), per-boot dedup cursor, and a
command queue that re-sends authorize/deny until acked.

- pour -> Drink.record_drink (device-authoritative volume, age_ms
  timing, pour_id dedup); unknown users fall back to guest
- pour_update -> short-ttl redis stash for the future realtime ui
- temperature -> ThermoSensor.log_sensor_reading
- token attached -> authorize (all meters) or deny, same round trip
- status -> roster health + flow meter sync from device calibration
- unknown types accepted and ignored per spec

All transient state (roster, cursor, commands, live pours) lives in
redis; the only durable artifacts are the controller token and drink
pour ids.
GET /api/admin/kegboards lists unpaired boards streaming in (redis
roster) merged with paired controllers; allow mints the token and
creates the controller, deny/revoke/forget round out the lifecycle.

Pins SCHEMA_PATH_PREFIX: operation-id prefix auto-detection breaks
once a non-/api route exists.
Controllers page is two tables: kegboards (pairing candidates and
paired boards, 5s poll) and legacy manual controllers. Pending boards
carry allow/deny inline, with first-seen time and source address;
paired rows show liveness, firmware, wi-fi (bars + dBm, color coded),
and dropped events.

Clicking a row expands the controller's meters and toggles with
inline tap assignment. Kegboard ports and calibration are
device-managed and read-only here; deleting a kegboard's controller
revokes its access and the board re-enters pairing.
A board whose batches all 400 looked stuck at "pairing…" while
plainly hitting the server. Rejections now pin last_error to the
roster entry (cleared by the next good request) and the dashboard
shows a "rejected requests" chip with the reason on hover; rejects
are also logged with the device name.
Protocol rename upstream: meter_number/relay_number in objects,
meter_numbers in authorize/deauthorize, relays instead of toggles.
Controllers page now says Relays; the FlowToggle model keeps its name
(internal, and shared with the legacy v1 api).
The protocol moved authorization into server-issued grants: authorize
now carries a grant_id, meter_numbers/relay_numbers sets (the
meter-relay association is ours, from tap bindings), and limits (we
set a 30s idle limit; the device clamp bounds lifetime). Identity
left the wire — pours echo grant_id and the server resolves the user
from its grant record (redis, 7-day ttl, so queued pours delivered
late still attribute; no grant means guest). token events are always
a question now, and grant_end events report every ending with a
reason (logged; pours remain the volume record).
@mik3y
mik3y merged commit ef983e6 into main Aug 6, 2026
6 checks passed
@mik3y
mik3y deleted the mikey/kegboard-protocol branch August 6, 2026 04:52
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.

1 participant