support the kegboard v4 protocol - #456
Merged
Merged
Conversation
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #452, and the server-side peer of Kegbot/kegboard#21.