Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plexus — a local-first hub for edge telemetry

CI

plexus is where a fleet of edge controllers converges. It ingests their MQTT telemetry, stores every metric in a Gorilla-compressed time-series, watches each stream for drift and stuck sensors, and serves one dashboard — from a single package with no database, no broker service, and nothing to sign into.

It's the layer that ties the edge controllers together — the greenhouse and the coop — into one place you can actually reason about.

  greenhouse ─┐                        ┌── Gorilla time-series store
  coop ───────┤─ MQTT ─▶  plexus  ─────┼── drift / stuck detection
  (any device)┘                        └── built-in web dashboard

The built-in dashboard is for the hub itself — raw series, compression ratios, drift verdicts. For a branded, multi-site view with crop tracking, cameras and cultivation alerts layered on top, see Serra, which reads this hub's /api/overview server-side rather than duplicating any of the above.


Quick start (no hardware, no broker)

pip install plexus-hub        # or: git clone && python -m plexus
python -m plexus              # http://127.0.0.1:8092

The demo streams synthetic greenhouse + coop telemetry into the hub, including two injected faults, so the dashboard tells a story immediately:

  • coop/motor_current → drift — a slowly rising current, flagged 14σ off the startup baseline: a door-motor bearing wearing out.
  • coop/climate/humidity_pct → stuck — a flatline of identical samples: a frozen sensor.

Everything else reads ok. Each card shows the live value, a sparkline, the drift verdict, and the Gorilla compression ratio for that stream.

To point it at a real broker instead of the demo feeder:

python -m plexus --mqtt 192.168.1.20 --topic '#'

How it works

Piece File What it does
Ingest ingest.py Decodes the MQTT-contract JSON. Numeric fields become series "<topic>/<field>"; states and alert lists become events, not metrics.
Store store.py A bounded hot buffer per metric, compressed through the Gorilla codec — delta-of-delta timestamps + XOR floats. The dashboard shows the live compression ratio.
Drift drift.py Compares recent samples to the baseline each stream established at startup (not a sliding window), so a slow drift stays flagged instead of quietly becoming the new normal. Plus flatline detection for stuck sensors.
Server server.py Standard-library http.server: a small JSON API (/api/overview, /api/series, …) and the static dashboard.
MQTT mqtt.py A tiny MQTT 3.1.1 subscriber in pure standard library — no paho, no mosquitto client, just a socket.

The Gorilla codec in plexus/tsc/ is vendored verbatim from the author's own gorilla-tsc (MIT), so the hub stays a single zero-dependency package with nothing to pull at runtime.


Testing

python run_tests.py

Pure standard library, no services. It covers the store (with a lossless Gorilla round-trip and the retention ring), the ingest decoder (numeric fields in, states/alerts/booleans out), and the drift detector (insufficient data, stuck sensor, steady stream, and a real baseline shift). CI runs the suite on 3.11 and 3.12 plus ruff on every push.


Design notes

  • Local-first. No cloud, no account, no external time-series database. One pip install, one process, state you can inspect.
  • Few dependencies. Standard library only at runtime, including the MQTT client and the Gorilla codec — the supply chain you don't pull can't bite you.
  • Failure must be legible. Every drift verdict carries a reason ("14.7 sigma off the startup baseline", "flatline: 20 identical samples") so a human can tell why a stream was flagged.

MIT-licensed. Gorilla codec © the same author via gorilla-tsc.


Part of the HiddenGrid edge stack

Eight small repos, one chain: control → transport → hub → supervision. Each one stands alone and runs offline; together they are a working local-first stack with no cloud account anywhere in it.

Repo What it does
Control greenhouse ESP32/MicroPython greenhouse controller — light, aeration, heat and pulse irrigation. Safety lives in firmware.
Control coopilot ESP32/MicroPython coop controller — pop-hole door with anti-pinch, overcurrent and timeout interlocks.
Transport gorilla-tsc Lossless Gorilla time-series compression — the codec the edge→hub link stores with.
Hub → plexus MQTT ingest → compressed store → drift & stuck-sensor detection → one dashboard. Stdlib only.
Product serra Multi-site supervision for greenhouses & aquaponics, built on plexus.
Industry industrial-retrofit Real Modbus-TCP off a legacy PLC → clean telemetry, anomalies, live OEE.
Industry line-twin Measured cycle times → the bottleneck → the ROI of fixing it.
Industry kiln-retrofit Type-K thermocouple → PID ramp/soak → heatwork & pyrometric cones.

You are here: plexus.

About

Local-first hub that ingests edge telemetry over MQTT into a Gorilla-compressed time-series, detects drift and stuck sensors, and serves a dashboard — standard library only, no database or broker service.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages