• v1.3.0 90a03e7fd6

    v1.3.0: Meter epochs (M7) + energy-cost HA integration & midnight settlement fixes
    docker-image / build-and-push (push) Successful in 4m29s
    frontend / frontend (push) Successful in 2m17s
    pytest / test (push) Successful in 11m2s
    Stable

    tliu93 released this 2026-06-27 11:18:24 +02:00 | 9 commits to main since this release

    v1.3.0

    A large release covering everything since v1.2.0 — it takes the backend from
    single-user auth hardening through a full IoT + energy-metering stack with deep
    Home Assistant integration.

    Highlights

    • Home Assistant integration via MQTT Discovery — Modbus devices and energy-cost sensors auto-appear in HA.
    • Energy metering & cost engine — DSMR smart-meter ingest, manual/dynamic pricing (incl. Tibber), per-15-minute cost billing with standing charges and tax credits.
    • Meter epochs (meter-swap archival) — swapping a physical meter spins up a brand-new HA sensor and never mixes readings across meters.
    • Login hardening — TOTP two-factor auth plus exponential login back-off.

    Authentication & security (M4)

    • Two-factor authentication (TOTP): QR setup, recovery codes, and a two-step login flow.
    • Exponential back-off throttling on failed logins.
    • admin_cli escape hatches: reset password, unlock account, disable/reissue TOTP, list admins.

    IoT devices & Home Assistant (M5)

    • Generic Modbus TCP polling: device CRUD, JSON readings, YAML device profiles (e.g. SDM120), opt-in scheduled polling, cascade delete.
    • MQTT client with lifespan connect / auto-reconnect and a config "test" button.
    • Home Assistant MQTT Discovery: an entity-exposure framework with per-entity enable/disable toggles; publishes discovery configs, state, and availability under the home_automation topic prefix.
    • UI: sidebar navigation, Energy/device management views, latest-reading cards + trend charts, accordion config, and a Home Assistant expose panel.
    • DB-level foreign-key enforcement (SQLite foreign_keys pragma).

    Energy pricing, DSMR & cost engine (M6)

    • Pluggable pricing layer with manual and Tibber strategies plus profile validation.
    • Energy contracts with versioned tariffs.
    • DSMR P1 telegram ingest over MQTT.
    • Billing engine: per-15-minute period cost computation, dual-tariff buy/sell prices, standing fees folded into import cost and the energy-tax credit into export revenue; summary + retroactive recompute.
    • Tibber GraphQL client with hourly price refresh (today + tomorrow).
    • Energy API (prices / costs / summary / latest DSMR / recompute / Tibber test) plus frontend contract management, price/cost views, and a DSMR data panel.

    Meter epochs / meter-swap archival (M7)

    • New meter table modelling each physical meter's install window [started_at, ended_at); cost periods now carry a meter_id.
    • Meter-aware billing: never computes a register delta across two meters; periods straddling a swap boundary are marked degraded; added a delta sanity guard.
    • Cumulative cost sensors are anchored to the active meter's start, so a swap cleanly resets the running totals for the new meter.
    • Meter CRUD API with retroactive recompute, plus a meter-management UI (timeline, declare swap, edit).
    • Each meter has a stable UUID used as its Home Assistant identity, and the energy-cost HA device is named after the meter label — so swapping a meter produces a brand-new HA device/sensor and never contaminates old data. Discovery is re-published automatically on meter changes.

    Energy time & Home Assistant midnight handling (follow-ups)

    • All energy time math localized to the server timezone; the UI shows energy/DSMR/meter times in local time (24h).
    • Fixed fees and the energy-tax credit accrue per local calendar day; any day with recording counts its full-day credit (symmetric start/end-day handling).
    • Daily-resetting "today" cost/revenue sensors in addition to lifetime totals.
    • Midnight handling tuned for Home Assistant statistics: the daily "today" reset is shifted to just past local midnight (robust to a few seconds of clock skew between hosts), and each day's fixed fee + tax credit are settled at ~01:05 local — off the midnight hour-boundary — so HA attributes them to the correct day and the energy dashboard's daily costs stay accurate.
    • Billing robustness: ignore stale / out-of-range DSMR readings; energy-cost sensors marked always-available.

    Upgrade notes

    • Database migrations run automatically. The new meter table is created and backfilled — existing electricity history is attributed to an initial meter with a generated UUID. No data is deleted.
    • After upgrading, declare your meter (set its label) so the Home Assistant energy-cost device is named correctly. The old generic "energy-cost" HA device is superseded by a per-meter device; you may delete the stale one in HA.
    • (Optional) To include standing charges and the tax credit in the Home Assistant Energy dashboard, set the grid cost source to "Use an entity tracking the total costs" pointing at import_cost_total (and export_revenue_total for return-to-grid).
    Downloads