A Home Assistant custom integration for reef aquarium husbandry — tracks water parameters, livestock inventory, and ICP-OES test results, then turns that data into per-element dosing recommendations that respect the realities of manual testing (sparse cadence, kit noise, dosing-pump drift).
Designed around one running tank (a Red Sea Reefer 425 G2) but generalises to any reef setup using ReefBeat-style RSDose 4 dosers, KH Keeper, and Hanna/Salifert chemistry kits.
Current version: 0.5.3 — see CHANGELOG.md for the per-release history.
- KH, pH, Calcium, Magnesium, Nitrate, Phosphate, Salinity, Temperature, Ammonia, Nitrite plus all major ICP-OES elements (heavy metals, macros, traces).
- Each parameter exposes
latest,latest_at,latest_method,days_since_test, anddrift(manual − auto-source) sensors. - Auto-save manual entry — type a Hanna reading into a number entity on the Test Session dashboard view, it's recorded immediately.
- Auto-source listener — when an external sensor (KH Keeper, ATO probe, etc.) fires a state change, it's recorded into history with
source=autoso the manual-vs-auto drift is visible. - Test-date-correct history — ICP test sampled three weeks ago shows up in history at the sample date, not the import date. Recent Hanna readings still beat older lab samples in "current value" lookups.
Five recommendation engines, one per macronutrient:
| Advisor | Param | Default target | Supplements (built-in patterns) |
|---|---|---|---|
| Alkalinity | KH | 8.0–9.0 dKH | Foundation B, Tropic Marin Alkalinity Plus |
| Calcium | Ca | 420–440 ppm | Foundation A |
| Magnesium | Mg | 1300–1350 ppm | Foundation C |
| Nitrate | NO3 | 1–10 ppm | NPX, NO3:PO4-X, HR/LR Nitrate Remover |
| Phosphate | PO4 | 0.03–0.10 ppm | Quantum AR Phosphate, lanthanum, NPX |
Each advisor:
- Takes daily snapshots of the parameter + the sum of programmed dose across configured RSDose heads
- Suggests a daily-dose change with a reason ("KH median 7.2 dKH below band — increase to 4.2 mL/day")
- Recommendation-only — never writes to your doser. You apply changes in ReefBeat manually and acknowledge.
- Sparse-cadence defaults for manual testing: 90-day rolling window, min 2 readings, 30-day cooldown — tuned for 1–2 readings per month rather than auto-tester daily polling.
- Auto-detect doser heads by reading each RSDose head's
_supplementlabel and matching against per-param patterns (e.g. "Foundation A" → Calcium advisor heads).
- Snowstorm guard (Calcium): refuses to recommend raising Ca dose when alk > 10 dKH or Mg < 1200 ppm — both create CaCO3 precipitation risk. Holmes-Farley + BRStv consensus is "fix Mg first, then alk + Ca settle."
- Floor guard (NO3 / PO4): refuses to recommend more removal dose when NO3 ≤ 0.5 ppm or PO4 ≤ 0.03 ppm — stripping below these is the canonical dinoflagellate-outbreak setup.
- Redfield-ratio warning: alerts when NO3:PO4 mass ratio is outside [50:1, 200:1] — soft warning for cyano risk (low ratio) or dino risk (high ratio).
- Water-change settling: snapshots within 24h of a logged water change are excluded from slope calculations — handles the dilution step without truncating the rolling window.
- Demand-change learning mode: logging "added 3 SPS frags" enters the advisor into a learning period until N post-event snapshots accumulate.
The integration registers a reef-tank-tracker dashboard on first run with 9 views:
- Test Session — auto-saving entry rows for all parameters, current habitat/problem context
- Overview — at-a-glance latest values + days-since-test
- Alk Advisor — recommendation, KH history graph (7d), action buttons (acknowledge/dismiss/log water change/log demand change), show-your-work breakdown, recent activity log
- Calcium Advisor — same shape as alk, 90-day Ca history graph
- Magnesium Advisor
- Nitrate Advisor — adds Redfield ratio + floor-guard surface
- Phosphate Advisor
- Dosing Plan — most-recent ICP test's habitat-aware dose plan (sorted by importance), with inline re-import form
- Diagnostics — per-parameter method/drift/timestamp diagnostics
After a version upgrade with new views, call reeftanktracker.regenerate_dashboard to surface them.
Every dashboard action (acknowledge, dismiss, water change, demand change, ICP import) fires a 10-second auto-dismissing toast in the bell-icon dropdown AND a logbook_entry event so the action shows up in the dashboard's "Recent activity" card. No more checking system logs to confirm a button worked.
- Track every coral / fish / invert / clam by category, with added/removed-at timestamps and notes.
tank_habitatandtank_problemselects feed Triton's habitat × problem dose-recommendation matrix when ICP tests are imported.
- Paste a public Triton showroom URL → fetches the full habitat × problem recommendation matrix → writes test-date-correct history for every ICP-OES element + renders an active dose plan sorted by importance.
- HACS → Integrations → ⋮ → Custom repositories
- Add
https://github.com/jordanduffybd/reeftanktrackeras an Integration - Search "Reef Tank Tracker", install, restart HA
- Settings → Devices & Services → Add Integration → "Reef Tank Tracker"
After install, configure via Settings → Devices & Services → Reef Tank Tracker → Configure:
- Auto-source sensors — pick the sensor whose value should populate the parameter's
_latest(e.g. KH Keeper for KH) - Target ranges — per-parameter target band overrides
- Alk dosing advisor — enable, pick alk heads, supplement profile, target band, tunables
- Calcium / Magnesium / Nitrate / Phosphate dosing advisors — same shape, per-element
The advisor's empirical-potency learner reads up to OPT_WINDOW_DAYS (default 7) of dose / KH history from HA's recorder. The per-element advisors use OPT_WINDOW_DAYS defaults up to 90 days. HA's default recorder retention is 10 days — short enough that the per-element advisors can't see their own full window. To use the full advisor windows AND retain enough trend data to answer "why has consumption changed over the last two months", bump retention in configuration.yaml:
recorder:
purge_keep_days: 90(60 also works if disk is tight. Numeric advisor data is small — a 90-day bump typically adds <100 MB.) Restart HA to apply.
- kh-keeper-bridge — Home Assistant add-on that bridges Reef Factory KH Keeper readings + cuvette empty/fill/measure procedures into MQTT auto-discovered entities
- icpimport — earlier standalone Triton ICP importer (now subsumed by this integration's built-in importer)
- docs/RELEASING.md — how to cut a release HACS picks up (TL;DR: GitHub Releases, not bare tags). Auto-cut on
mainpush when the manifest version bumps. - docs/DASHBOARD.md — auto-install behaviour, regenerating, customising
- docs/SERVICES.md — every
reeftanktracker.*service and its fields - docs/IMPORTING.md — bulk-import historical CSVs (Aquarium Log app + Triton ICP exports)
- CHANGELOG.md — what changed per release, with HA Core compatibility lines
- tests/README.md — running the 162-test suite
Tested against Home Assistant Core 2026.4.4. Every CHANGELOG entry states the HA Core (and HAOS, when relevant) version it was verified on. Upgrading HA past the listed version isn't guaranteed to work — check the next release for an updated compat line first.
Python 3.11 and 3.12 supported (CI runs both).
Production-ready for the maintainer's tank (Red Sea Reefer 425 G2 with RSDose 4, KH Keeper, ReefBeat). The dosing-advisor algorithms are conservative-by-default (recommendation-only, sparse-cadence, ±10% step caps) and have been running in prod for several months across the alk advisor and weeks across the per-element advisors.
Other tank setups should work but haven't been exhaustively validated. File an issue on GitHub if your dosing pump / KH source / supplement names don't match the built-in patterns — auto-detect can be widened.