๐Ÿ”ฌ Preview โ€” the rules exist; evaluation & tuning are work in progress

From raw sensors
to colony insights.

The Insights module turns the time-series your HiveHub already records โ€” weight, hive temperature, ambient conditions, in-hive sound, entrance traffic and comb vibration โ€” into a ranked list of plain-language alerts. Twelve rule-based detectors, each watching one colony behaviour, computed independently for every hive (up to 16 per ESP32).

How it works

Insights are computed in server/insights.py โ€” pure Python, no database access โ€” and served from /api/v1/devices/{id}/insights. HivePal renders them in the HiveScale โ†’ Insights card and caches them for five minutes.

๐Ÿงฎ

Rule-based & transparent

Every alert traces back to one detector function and one documented threshold โ€” no black box. You can read exactly why it fired.

๐Ÿ“…

Up to 14 days lookback

Each call compares recent readings against a rolling baseline. The window is configurable with the lookback_days query parameter.

โš–๏ธ

Per channel

Every detector runs separately for scale 1 and scale 2, so two colonies on one device are assessed independently.

๐Ÿ“Š

Ranked output

A flat list of alerts sorted by severity then time. Each carries a category, a confidence score and a human-readable description.

Four severities

Every alert is tagged with one of four levels. HivePal uses them to colour-code the alert rows and the per-hive badge on the latest-value panel โ€” which always shows the highest active severity (critical > warning > watch > info).

info

Informational classification โ€” no action required.

watch

A trend worth monitoring โ€” inspect on your next routine visit.

warning

Something is happening now โ€” investigate within hours.

critical

An acute event โ€” immediate attention recommended.

A single detector can change level with context โ€” a swarm departure is critical during the day but warning at night.

The detector catalogue

Twelve detectors, each a single function in insights.py with one documented rule. They are grouped here by what they watch for; the number matches the reference doc.

๐Ÿ

Swarming

1

Pre-swarm watch

watch
Fires when the 24 h hive-temperature std-dev is โ‰ฅ 1.5ร— the 7-day baseline std-dev.

Thermoregulation loosens hours-to-days before a swarm. Tells you: inspect for queen cells in the next 24โ€“48 h.

Input: hive temperature ยท Source: spec Phase 1, MSPB ๐Ÿ”Š๐Ÿ“ณ Boosted by the mic piping band (300โ€“550 Hz) and the ~20 Hz night vibration band when present.
2

Imminent swarm

warning
Fires when all three hold: temp โˆ’ 4 h baseline โ‰ฅ 1.5 ยฐC, still rising at โ‰ฅ 0.5 ยฐC/h, and absolute temp > 36.5 ยฐC.

In the final ~10โ€“30 minutes the cluster gathers near the entrance and the upper hive spikes. Tells you: a swarm may leave within the half hour โ€” ready a swarm box.

Input: hive temperature ยท Source: spec Phase 2, Stalidzans & Berzonis (2013)
3

Swarm event

criticalwarning
Fires when weight drops โ‰ฅ 1.5 kg within โ‰ค 30 min. critical in daylight (09:00โ€“17:00), otherwise warning.

A departing swarm takes 50โ€“70% of the adult bees in minutes โ€” a near-step drop on the scale. Tells you: a swarm has very likely just left; check the hive.

Input: weight ยท Source: spec Phase 3 ๐Ÿ BeeCounter: matching asymmetric outflow raises confidence and promotes a night-time warning to critical.
11

Pre-swarm vibration rising

watch
Fires when the recent (2-day) night-time mean of the 8โ€“30 Hz swarm band is โ‰ฅ 2.0ร— its ~8-day night baseline, both above the noise floor.

A ~20 Hz comb vibration builds in the days-to-weeks before swarming and is clearest at night โ€” below what hive microphones can hear. Tells you: plan swarm control.

Input: accelerometer swarm band, night, active season ยท Source: Ramsey (2020), Bencsik (2011), Uthoff (2023) ๐Ÿ“ณ Degrades to nothing without an accelerometer; also boosts detector 1.
12

Pre-swarm movement rising

watch
Fires when the recent night-time mean of a passive BLE beacon's broadband magnitude is โ‰ฅ 1.8ร— its baseline. Defers to detector 11 where real FFT bands exist.

A low-rate beacon (HolyIot / RuuviTag) can't compute the FFT band, so this trends its coarse night-time movement instead โ€” deliberately lower confidence.

Input: low-rate accelerometer magnitude, night, active season ยท Source: Bencsik (2011), Ramsey (2020) โ€” low-rate proxy
๐Ÿ‘‘

Queen & brood health

4

Queenlessness

warning
Fires when (active season, Marโ€“Sep) the 7-day hive-temp std-dev is > 1.0 ยฐC and the 7-day net weight change is โ‰ค 0.2 kg (stagnant).

Without a queen, brood rearing stops, thermoregulation loosens and the weight curve stalls in season. Tells you: inspect for eggs and brood; plan a queen introduction.

Inputs: hive temperature + weight ยท Source: spec (2-of-3, no audio) ๐Ÿ BeeCounter: a sustained โ‰ฅ 5%/day forager decline adds confidence (corroborative only).
7

Brood cycle / colony state

watchinfo
Fires when the 24 h std-dev is < 0.5 ยฐC with a mean of 34โ€“36.5 ยฐC โ†’ active brood info; or > 2.0 ยฐC โ†’ broodless / weak watch.

Brood needs tight thermoregulation, so a narrow band around 34โ€“35 ยฐC confirms active rearing. Tells you: a quick health check โ€” a watch warrants an inspection.

Input: hive temperature ยท Source: project spec
๐Ÿ“ˆ

Activity, foraging & harvest

5

Robbing

warningwatch
Fires when weight loss is โ‰ฅ 0.4 kg/h sustained over โ‰ฅ 30 min and does not match the swarm signature. warning in the late-afternoon peak (15:00โ€“19:00), otherwise watch.

A robbed hive loses honey far faster than normal foraging swings. Tells you: reduce the entrance, or close / move the colony if it is sustained.

Input: weight ยท Source: project spec ๐Ÿ BeeCounter: an incoming spike with low outflow (โ‰ฅ 200 bees/h, asymmetry โ‰ฅ 0.4) upgrades watch โ†’ warning.
6

Foraging intensity

watchinfo
Fires when the 24 h weight delta is โ‰ฅ +1.0 kg (strong) or โ‰ฅ +0.2 kg (moderate) โ†’ info; or โ‰ค โˆ’0.2 kg โ†’ watch.

Daily weight delta is the classic nectar-flow proxy. Tells you: strong flow โ†’ consider a super; a negative delta โ†’ check for dearth, disease, robbing or queen problems.

Input: weight ยท Source: spec, Meikle et al. (2008) ๐Ÿ BeeCounter cross-check: gain without outbound traffic lowers confidence (a suspect reading); active traffic raises it.
10

Harvest window

info
Fires when the 7-day weight delta falls from > 2.0 kg/week to < 0.3 kg/week and the plateau lasts โ‰ฅ 4 days.

Honey flows climb fast then plateau; harvesting at the top of the plateau maximises yield. Tells you: the flow looks finished โ€” supers may be ready. Confirm by inspection.

Input: weight ยท Source: project spec
โ„๏ธ

Decline & overwintering

8

Absconding / collapse trend

watch
Fires when both hold over 14 days: weight loss > 100 g/day sustained and a positive regression slope on the daily std-dev (variance widening).

A colony in slow decline bleeds weight while its thermoregulation deteriorates. Tells you: inspect within the next routine cycle for disease, queen status and stressors.

Inputs: hive temperature + weight ยท Source: spec (2-of-3) ๐Ÿ BeeCounter: a โ‰ฅ 3%/day forager decline makes it 3-of-3 and auto-promotes watch โ†’ warning.
9

Winter survival risk

warningwatch
Fires when (Octโ€“Feb) at least one holds: min hive temp 7d < mean ambient 7d + 2.0 ยฐC (weak cluster), or weight loss > 300 g/week (high consumption). Both โ†’ warning.

A strong cluster stays well above ambient and burns stores predictably. Tells you: verify food on the next mild day; consider emergency fondant.

Inputs: hive temp, ambient temp, weight ยท Source: project spec ๐Ÿ BeeCounter: a cleansing flight (โ‰ฅ 50 bees out) is positive evidence the cluster is alive and softens the alert.

Sensor fusion, with graceful degradation

Weight and hive temperature are the always-present base signals. Every other input is optional โ€” when a sensor is fitted it raises confidence or promotes severity; when it is absent the detector quietly falls back to its weight/temperature rule. No detector ever requires an optional sensor.

๐Ÿ”Š

Microphone (FFT bands)

Piping / tooting confirms pre-swarm, an agitated spectrum supports robbing, and the acoustic signature supports queenlessness. Integrated.

๐Ÿ

Entrance counter (BeeCounter)

Asymmetric outflow confirms swarming, incoming spikes flag robbing, and forager decline supports queenlessness, absconding and winter checks. Integrated.

๐Ÿ“ณ

In-hive vibration

The ~20 Hz night-time comb signal microphones can't reach โ€” fires the standalone pre-swarm detectors and boosts the temperature watch. Integrated.

Example: a night-time swarm warning from the weight drop is promoted to critical once the BeeCounter shows the matching asymmetric outflow โ€” the entrance traffic rules out a measurement artefact.

Grounded in the literature

The thresholds are starting values calibrated against a project spec and the public research below. A one-paragraph TL;DR of each lives in insights-sources-tldr.md.

Seeley (2010)

Honeybee Democracy. The behavioural basis โ€” swarming is a deliberate, days-long preparation, not a sudden event.

Stalidzans & Berzonis (2013)

A persistent temperature rise above the brood nest precedes swarming โ€” the basis for the pre-swarm temperature detectors.

Meikle et al. (2008)

Within-day hive-weight variation as a measure of colony activity โ€” the day/night weight-delta foraging method.

Kulkarni & Murphy

A multi-sensor benchmark (weight + in-hive temp + entrance traffic) โ€” the closest match to the HiveHub stack for validation.

MSPB dataset (2023)

53 hives, one year of audio + temperature + humidity โ€” validation for the temperature-only queenlessness fallback.

Ramsey et al. (2020)

A rising ~20 Hz night-time comb vibration predicted > 90% of swarms and never misfired โ€” the basis for the vibration detector.

Bencsik et al. (2011)

Comb vibration diverges from baseline days ahead of swarming โ€” justifies a trend / baseline comparison over a fixed threshold.

Uthoff et al. (2023)

A review recommending a low-frequency accelerometer to capture the ~20 Hz signal microphones miss โ€” why HiveHub added one.

What the research agrees on

Tune it to your apiary

All thresholds are constants near the top of server/insights.py. The defaults are sensible starting points โ€” re-tune them against your own history, especially the swarm-drop weight, the winter consumption rate and the foraging deltas, which all depend on box size, climate and regional flow strength.

SWARM_WEIGHT_DROP_KG            = 1.5
SWARM_WEIGHT_WINDOW_MIN         = 30
PRE_SWARM_STD_MULTIPLIER        = 1.5
ROBBING_WEIGHT_LOSS_KG_PER_HOUR = 0.4
QUEENLESS_TEMP_STDDEV_C         = 1.0
WINTER_WEIGHT_LOSS_G_PER_WEEK   = 300
HARVEST_FLOW_KG_PER_WEEK        = 2.0
# โ€ฆ plus the per-sensor fusion thresholds

Planned: expose these per device via /api/v1/devices/{id}/config so you can tune without redeploying the backend.

Read more

๐Ÿ“„ Insights reference

The authoritative detector catalogue with every threshold and source.

docs/insights.md โ†’

๐Ÿ“š Sources TL;DR

One-paragraph summaries of every paper behind the rules.

insights-sources-tldr.md โ†’

๐Ÿ“ณ Accelerometer

The ~20 Hz pre-swarm vibration signal and the hardware behind detectors 11 & 12.

docs/accelerometer.md โ†’

๐Ÿ insights.py

The implementation โ€” pure Python, one function per detector.

server/insights.py โ†’