Skip to content

HiveHub integration: 18-hive support, inspection mode, audio, health, insight alert emails - #38

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

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

Conversation

@MacNite

@MacNite MacNite commented Sep 30, 2026

Copy link
Copy Markdown
Owner

This brings HivePal's HiveHub integration up to date with HiveHub, covering items 1–6 of the gap analysis. It needs MacNite/HiveHub#199 for hive links, relay status, AP mode, export and range delete. On an older HiveHub those features return 404; everything else works with current HiveHub main.

1. Fixes for things broken today

  • Hive names for slots 3–18 were never saved. HivePal sent hives[], which HiveHub silently dropped. It now sends names and hive_ids. Names and links are stored in HiveHub instead of only in the browser, and a slot links to a HivePal hive by id, not by name.
  • Swarm alerts could not work. The job sent the user id as a bearer token, read fields that don't exist, and never applied its cooldown. It is replaced by an insight-based email job:
    • It runs every 15 minutes and emails new or escalating HiveHub alerts (swarm, robbing, queenless, winter, …) for all 18 hives.
    • It sends one digest mail per run and tracks what was sent in a new HiveHubAlertNotification table.
    • It is opt-in per user (Setup → Alert emails) with a minimum severity. Users who had swarmAlert on stay on.
  • Firmware upload: the hivehub target is accepted, a board is forwarded, and uploads are capped at 16 MB. Relays work for any hive 1..18, with an optional force.
  • Wide chart ranges were truncated. HiveHub caps each request at 10k rows, so a "year" chart showed only about the last 35 days. Ranges beyond 7 days now use server-side max_points.
  • Request bodies are validated with zod schemas in shared-schemas.

2. Inspection mode

  • Start/stop with hive scope and a note, pending and active status, timeout, and history with editable notes.
  • The HivePal inspection form suggests starting it for a linked hive. It never starts automatically.
  • The hive detail page gets a HiveHub card for linked slots.
  • Inspection windows are shaded on the charts.

3. Configuration

  • Calibration wizard and temperature compensation for every hive, 1–18.
  • HiveTraffic night mode, time zone and emitter banks.
  • Inspection timeout setting.
  • HiveTraffic relay buttons, and "relay anyway" (force).
  • The page uses the insights summary.

4. Visibility

  • Health tab: hub status (signal, time source, battery, solar, last check-in) and sensor health, with HiveHub's fault explanations. It names each HiveInside node and HiveTraffic counter.
  • Overview: per-hive cards for every hive, with compensated weight, 24 h change and alerts.
  • Dashboard: new HiveHeart spectrum and daily max weight widgets, a custom date range, and full i18n.

5. Audio

  • Record 1–60 s from a HiveInside, play or download the WAV (streamed through the backend), see quality figures, delete.

6. HiveHub API additions and cleanup

  • Per-node relay status, remote setup access point, NDJSON export, and a range delete gated by the claim code.
  • SD import refuses a card recorded by another hub unless you confirm.
  • The claim form takes the hive 1/2 names again.
  • Removed the unused sound and bee-counter panels.
  • All nine languages translated; added the missing navigation.hivehub key.
  • Docs, README env vars, TODO and v0.20.0 release notes updated.

Testing

  • Backend: 150 unit tests pass, including 19 new ones for alert rules, relay slots, SD device detection and the shared schemas.
  • Checks: tsc is clean for the frontend and backend, eslint has 0 errors, and the frontend builds.
  • The new migration was applied to Postgres and prisma migrate diff against the schema is empty.
  • End to end, HivePal backend and frontend were run against the HiveHub mock server (with the mock fixes from Feature Request: Improve the Inspections table — customisable columns, a Notes column, and a meaningful "Actions" column martinhrvn/hive-pal#199):
    • Every new proxy route was exercised.
    • Screenshots of all tabs were checked by hand.
    • This found one more bug, now fixed: an older HiveHub or the mock sends no hives[], so the frontend now rebuilds it from the flat fields.
  • Not tested: against a real hub or a real HiveHub server; alert emails with a real mail provider; the audio recording flow (the mock can't record).

Notes for review

  • Commits are grouped by layer (backend, frontend, docs, translations) rather than by item, so each commit builds on its own.
  • The release-notes entry in v0.20.0.md has no PR number yet.
  • Translations were machine-drafted by Claude, not a native speaker; worth a skim, especially ru/sk/sr.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL


Generated by Claude Code

…sight emails

- channels: forward per-hive names and HivePal hive ids (names/hive_ids)
  instead of the hives[] array HiveHub silently dropped
- swarm alerts: remove the broken weight-drop job (it sent the user id as
  a bearer token, read device.id/recorded_at that do not exist and never
  applied its cooldown); a new job emails new or escalating HiveHub insight
  alerts, tracked per user in HiveHubAlertNotification
- firmware: accept the hivehub target and a board, cap uploads at 16 MB,
  relay to any hive 1..18 with an optional force, auto-queue HiveInside
  relays only for hives that report a HiveInside node
- new proxy routes: channels read, inspection mode, hive audio recordings
  (WAV streamed), remote AP mode, NDJSON export and summary, claim-code
  gated range delete; measurements accept max_points
- SD import refuses a card recorded by another hub unless forced
- validate every request body with zod schemas in shared-schemas
- unit tests for the alert rules, relay slots, SD device detection and
  the shared schemas

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL
…etup

Restructures the HiveHub page into Overview / Inspections / Audio /
Health / Setup tabs and brings HivePal up to what HiveHub now offers:

- hive slots: name and link each of the 18 slots to a HivePal hive; both
  are stored in HiveHub (names/hive_ids) instead of the browser, so the
  link survives renames and reaches alert emails
- overview: per-hive cards for every hive (compensated weight, 24 h
  change, climate, traffic, alerts, inspection badge); dashboard gains a
  HiveHeart spectrum and daily-max-weight widget, shaded inspection
  windows, a custom date range and full i18n; wide ranges are
  down-sampled server side (a year used to be cut to its last ~35 days
  by HiveHub's 10k row cap)
- inspection mode: start/stop, per-hive scope, notes and history; the
  HivePal inspection form suggests it for a linked hive (never
  automatic) and the hive page shows a HiveHub card for linked slots
- audio: record, play and download HiveInside recordings with quality
  figures
- health: hub status (signal, time source, battery, solar, last
  check-in) and sensor health with HiveHub's fault explanations for the
  hub, scales, in-hive nodes, HiveTraffic counters and HiveHeart
- setup: calibration wizard and temperature compensation for hives
  1..18, HiveTraffic night mode and emitter banks, remote setup AP and
  inspection timeout, firmware with per-node relay status and relay
  buttons, upload board/target detection, SD import device check, NDJSON
  export and claim-code gated range delete, alert email settings
- claim form takes the hive 1/2 names again; device status shows the
  last check-in
- removes the unused sound/bee-counter panels and insights card

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL
Older HiveHub servers and the HiveHub mock send only the flat
scale_N_/hive_N_/ble_N_ fields. The new per-hive cards, health view,
calibration picker and node detection read hives[], so they showed no
data there; synthesize it once in the measurements hook.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V4BwZGxKox5nD1Nw8fP9NL
Adds da, de, es, fr, it, nl, ru, sk and sr strings for every new HiveHub
key, the missing navigation.hivehub label, and drops keys of the removed
diagram, sound and bee-counter panels.

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