Repository navigation
v1.19.7 — Hardening
🔧 v1.19.7 — Hardening: Trustworthy Alerts, Accurate Cycles
This is a hardening release. No new integrations to configure, no breaking option changes — just the kind of fixes that make the numbers on your dashboard tell the truth. Fourteen commits, seven bug families resolved, and one new diagnostic alert that quietly watches for a pattern the integration previously missed.
If you've ever seen a daily total above 24 hours, a 6-hour gap in a 24/7 heat pump run, or a short-cycle alert when you knew the compressor wasn't running — this release is for you.
🔍 Understanding the Issue
During a full end-to-end audit of Prod 1's database, three independent bugs turned out to produce the same symptom: numbers that don't add up. Each one alone damages COP, SPF, stooklijn-advies, and the ML baseline. Together they compound.
- Cross-midnight cycles were counted 100% on the end-day. A 16-hour heating run from Oct 26 13:31 → Oct 27 05:46 appeared entirely as Oct 27 = 16h heating, and Oct 26 = 0h. On real data this produced days with 28.81 hours of heating in a 24-hour day — physically impossible.
- Long low-modulation runs were completely invisible. On Nov 2 16:55–22:57 (6h02m), the compressor was actively heating — 69 COP samples, COP 5–7, flow 17 l/min, LWT climbing 28°C → 35°C → 31°C — yet the cycle detector recorded zero cycles in that window. Reason:
INV frequency (rps)reports"Invalid"during low modulation after a defrost, and the detector only accepted RPS or a live-power fallback. - Two detection trackers could run at once. During BUH / defrost transitions, two open cycle trackers occasionally produced overlapping cycles with the same
end_ts(e.g. id=175 6h and id=176 2h, both ending at 07:11). Every aggregation double-counted them. - Stale cycles from before a HA restart could fire alerts. After a reinstall or DB delete, HA hydrates the last completed cycle from
.storage. If it had a smalloff_sstored,short_offfired even thoughsensor.cycles_todayshowed 0. Reported as #259, and directly triggered this whole audit.
✅ What We Changed
Alert correctness — 6 alert bugs aligned across both layers
short_offno longer fires on transient predecessors. A 30–120 second pump-only LWT sampling pulse before a real cycle no longer counts as a "short off".short_offrequires at least one short run in the pair. A 264-min → 60s → 84-min sequence is normal hysteresis restart, not short-cycling. Fires only when the run before or after is itself short.- Coordinator mirrors
binary_sensorsemantics. The dispatch path had drifted from the entity layer since v1.12.0 — three of these bugs were only fixed in one layer. All now match. pendulum_hourlycounts heating-only. Cooling and defrost no longer inflate the count in the coordinator path (matching the fix already in the entity layer since v1.19.6).- Corrupt
is_transient="0"no longer disablesshort_run. Numeric parsing instead of a truthy check — a string"0"from a manual SQL edit or old backup is correctly treated as non-transient. - Stale cycles are ignored by
short_run+short_off(#259). A cycle ending more than 1 hour ago is not treated as a live run or off-time. Fixes the false alerts after a HA restart that hydrates from a previous session.
Cycle-duration accuracy — three root causes fixed
- Pro-rata cross-midnight attribution (#260).
daily_summarynow splits a cycle's duration across the days it actually ran. A 16h run from Oct 26 13:31 → Oct 27 05:46 reports ~10.5h on Oct 26 + ~5.75h on Oct 27, not 16h/0h. thermal_kw_avgsample floor (#12). A 30s cycle with only 1 flow sample used to report its peak value as the average (33.79 kW observed on Prod 1 — physically impossible but under the magnitude cap). Cycles with fewer than 3 samples now storeNULL.- Compressor detected via flow + COP (#261). When
INV frequency (rps)reports"Invalid"— common during low modulation after a defrost — the compressor is still detected if flow > 5 L/min AND COP > 1.5 (better than resistive heat). Guarded against defrost-recovery (COP < 1.5) and pump-sampling-only (flow < 5). On real prod data this captures 68 of 69 missed samples in the Nov 2 gap.
New diagnostic alert — short_cycling_pattern
- Structural pendeling detection. New
binary_sensor.daikin_cycle_ml_short_cycling_patternfires when 3+ short runs occur within a rolling 60-minute window. Distinct from single-cycleshort_run: catches the behavioural pattern that single-cycle alerts miss. - Five diagnostic attributes so dashboards retain context even after the sensor returns to OFF:
window_min,min_cycles_threshold,short_run_threshold_min,pattern_count_60min,recent_short_runs(last 10 short runs with timestamps and durations — newest first). Correlate past patterns with weather, LWT, or mode changes. - Native notification fires automatically. No user automation required. Dedup window: 60 minutes (same as
pendulum_hourly). Group:short_cycle(bundles withshort_runandshort_offfor grouped notifications). - Two new OptionsFlow fields:
short_cycling_window_min(5–360, default 60) andshort_cycling_min_cycles(1–20, default 3). Present in both setup wizard and options flow.
Silent bugs fixed that were hidden in plain sight
alertsDB table was dead code (#14). Thealertstable existed since the very first commit but had zero call sites — nothing was ever inserted. Nowdb.async_insert_alertis wired into_async_dispatch_alerts. Existing rows stay empty on Prod 1/2/3; new alerts land immediately after upgrade.- Migration v27 — historical cleanup (#260, #261). An idempotent one-time migration on first HA restart after upgrade: finds overlapping root cycles produced by the dual-tracker bug, shortens the parent to
child.start_ts, and rebuildsdaily_summaryfor every affected day. On real Prod 1 data: 3 overlapping pairs fixed, 5 days rebuilt. Second run is a no-op (marker:data_migration_v27_completed).
Test coverage & CI hardening
- +334 new tests across 14 new test files — E2E HVAC flow, edge cases, config-flow E2E, dispatch E2E, migration v27 with real fixture replay, cross-midnight attribution, compressor detection with 69-sample replay.
- R596 gate now parses JUnit XML. Pytest 9.0.3 suppresses the
N passedsummary line on stdout, breaking the previous parser. The test-count check is now source-independent. - Ruff clean, mypy strict clean, markdown clean — full pre-push parity preserved.
📊 Impact for Your Heat Pump
What changes (visible):
sensor.daily_summary_recentwill read lower for historical days. This is not a regression — it's the removal of double-counting. A day that used to show 19.4h because it absorbed the incoming half of a cross-midnight cycle now shows 18.3h, because the other 1.1h correctly belongs to the previous day.sensor.cycles_duration_todayon cold 24/7 days will now approach 21–23h heating + 1.5–2h DHW (was showing 16h or 28h depending on the bug).- Fewer
short_offalerts — no more false positives on single cycles, transient predecessors, or stale hydrated cycles after a restart. - Fewer invisible 6h gaps — low-modulation heating is now detected via flow+COP.
- New
short_cycling_patternbinary sensor appears in HA and lights up during structural pendeling. - Notifications show actual counts —
pendulum_dailymessage used to show 40 when the trigger counted 30 (transients excluded from trigger, not from message). Now consistent. alertstable starts populating — after upgrade,SELECT COUNT(*) FROM alertswill reflect real alert history. Useful for diagnostics and ML correlation.
What stays the same:
- All 17 previous alerts continue —
short_run,short_off,pendulum_*,dhw_pendulum,high_cycle_rate,ml_anomaly,setpoint_osc,cop_low,cop_degradation,cop_vs_datasheet_low,defrost_excessive,buh_excessive,source_stale,missing_attributes,db_retention_warning,kmeans_retrain_stale,energy_daily_anomaly,stooklijn_advies. - Your configured thresholds are unchanged —
short_run_threshold_min,pendulum_cycles_per_hour,dhw_pendulum_cycles_per_hour, dedup windows, quiet hours. - All 50 sensors and 13 services are unchanged — no reconfiguration needed.
- The 5 Lovelace cards continue to work — no dashboard edits required.
- Your database schema is preserved — v27 is additive (marker-only + targeted
UPDATEs), no data loss.
What runs once on upgrade:
- Migration v27 runs in the first HA restart after updating. On a database with months of history, this takes a few seconds (batched writes, per-day rollup). You may see these log lines once:
v27 overlap cleanup: 3 pairs fixed, 5 days rebuilt data_migration_v27_completed: completed=True
🧪 Tests & Verification
- Red → Green discipline preserved. Every fix was proven to fail on the old code first, then proven to pass on the new code. No green tests without a corresponding red test.
- Production data replay. Compressor detection validated against 68 of 69 real COP samples from the Nov 2 gap on Prod 1. v27 migration validated against the 193-cycle Prod 1 fixture — 3 overlapping pairs found and fixed, exactly as expected.
- Cross-midnight attribution proven with three separate scenarios: 16.25h cycle → ~10.5h + ~5.75h; single-day 8h cycle stays 8h; mixed sum preserved.
- 24/7 week tests with synthetic data: cold week (5°C avg) → 20–24h/day heating; mild week (14°C avg) → 10–12h/day when the compressor genuinely modulates.
- Resilience tests — v27 completes even if
async_rollup_dayor_rebuild_daily_summary_for_affected_daysraises (defensive except blocks, but never silent:_LOGGER.exceptionfires). - +334 new tests across 14 new files — E2E, edge cases, migration fixture replay, dispatch E2E, config-flow E2E.
- 4492 tests passing (was 4158 in v1.19.6) — full suite green, 100% line + branch coverage preserved, zero regressions.
- Ruff + Mypy Strict + Markdown CI: all four gates pass.
- R596 hardened — test-count verification now reads JUnit XML instead of stdout, resilient to pytest version changes.
⚙️ Upgrade Instructions
- HACS Users: The update appears automatically within ~10 minutes. Or go to HACS → Daikin Cycle ML → Update.
- Manual Install: Replace the
custom_components/daikin_cycle_ml/folder and restart Home Assistant. - Migration runs once on first restart. You do not need to trigger it manually. If you have a large history, expect 3–10 seconds of one-time DB activity. During the migration the integration continues to report data.
- Action Required: If you disabled
pendulum_hourly,pendulum_daily,dhw_pendulum, orhigh_cycle_ratenotifications as a workaround, you can safely re-enable them now. See v1.19.6 notes for details. - No Configuration Changes: Your existing options, thresholds, and entity IDs are fully compatible.
📂 Dashboard Cards
Did you know we have 5 Lovelace cards for this integration? The COP & Energie card gives you a live efficiency overview at a glance — useful for spotting the same cross-midnight and gap patterns this release addresses.
- 📂 View all Dashboard Cards — install instructions included.
🔗 Links & Support
Documentation:
- 🏠 Integration README — features, setup, and usage.
- 📋 CHANGELOG — full release history.
- 📊 Full diff v1.19.6...v1.19.7 — every commit in this release.
Support:
- 💬 Discussions — ask questions, share setups.
- 🐛 Report an issue — bugs and feature requests.
Issues related to this release:
- #258 — v1.19.7 hardening tracking
- #259 — Stale cycle false positives (fixed)
- #260 — Cross-midnight misattribution (fixed)
- #261 — RPS-invalid detection gap (fixed)
☕ Support the Project
Daikin Cycle ML is free, local-only, and open-source — no cloud, no accounts, no telemetry. Your heat pump data stays on your Home Assistant instance. If this integration has helped you reduce short cycling, understand your cycles, or improve your COP, consider buying me a coffee. It goes a long way in funding future features and bug fixes.
