Skip to content

App API for HivePal: hive links, relay status, remote AP mode, export and range delete - #199

Merged
MacNite merged 4 commits into
mainfrom
ccr-bbc590f9-7g6yed
Sep 30, 2026
Merged

MacNite merged 4 commits into
mainfrom
ccr-bbc590f9-7g6yed

Conversation

@MacNite

@MacNite MacNite commented Sep 30, 2026 •

Copy link
Copy Markdown
Owner

This adds the server-side pieces HivePal needs to catch up with the dashboard. The HivePal counterpart is MacNite/hive-pal#38.

Version: the server goes 0.5.3 → 0.6.0 (new app endpoints plus a migration). HivePal's docs name 0.6.0 as the minimum for these features. The firmware is unchanged and stays at 0.30.5.

Server (/api/v1/app/*)

  • Hive links: channels now accept and return hive_ids ("1".."18" → HivePal hive id) next to names.
    • This is migration 031_device_channel_hive_links.sql, mirrored in init_db. GET /app/devices carries both maps.
    • A slot stays linked to its HivePal hive when the hive is renamed. "" or null clears a link; names keep their existing semantics.
  • firmware/status: now includes hiveinside_latest_version, hiveinside_relays, beecounter_latest_version and beecounter_relays, the same data as the local dashboard.
  • New endpoints, thin wrappers over the local dashboard handlers with a role check:
    • POST /app/devices/{id}/provisioning/start (owner/admin) opens the setup access point remotely.
    • GET /app/devices/{id}/export/measurements and /export/measurements/summary (owner/admin) give an NDJSON backup of one device.
    • POST /app/devices/{id}/measurements/delete (owner only) deletes a range of readings, gated by the claim code.

Mock server

  • Accepts HivePal's Authorization: Bearer <jwt>. Before this, it only read X-User-Id, so HivePal could not run against it at all. The token is verified when HIVEPAL_JWT_SECRET is set.
  • Honours max_points.
  • Added: names/hive_ids, relay status, provisioning, in-memory inspections matching the real response shapes, an empty recordings list, and relay slots 1..18.

Docs

  • docs/api.md: the new endpoints, and the 16 → 18 hive limits.
  • docs/insights.md: corrected the insights route.

Testing

  • New test-data/test_channel_links.py (pytest), added to CI. It passes together with test_relay_ota_gate.py.
  • The server app imports and every new route is registered.
  • Ran HivePal end to end against the mock: claim, save names and links, inspection start/stop, firmware status, AP mode. Screenshots were checked by hand.
  • Not run against a real database: migration 031 and the three new endpoints.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL

…elete for HivePal

- channels: accept and return per-hive names and HivePal hive ids
  (hive_ids, migration 031) so a slot stays linked to its HivePal hive
  across renames; GET /app/devices carries both maps
- firmware/status: include hiveinside/beecounter latest versions and the
  per-slot relay status the local dashboard already shows
- POST /app/devices/{id}/provisioning/start (remote setup AP)
- GET /app/devices/{id}/export/measurements[/summary] (NDJSON backup)
- POST /app/devices/{id}/measurements/delete (owner, claim-code gated)
- mock server: names/hive_ids, relay status, provisioning, in-memory
  inspections, empty recordings; relays accept slots 1..18
- docs: new endpoints, 18-hive limits, correct insights route

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL
HivePal forwards Authorization: Bearer <jwt>, which the mock rejected
(it only read X-User-Id), so HivePal could not run against it at all.
The token's sub is used (verified when HIVEPAL_JWT_SECRET is set);
X-User-Id still works for curl. Measurements now thin to max_points
like the real server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL
@MacNite
MacNite merged commit c93a51b into main Sep 30, 2026
5 checks passed
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.

2 participants