fix(fw): rebuild electricity price sensor on epex_spot 4.x with full fee model + future-price chart #218
No reviewers
Labels
No labels
bug
enhancement
in-progress
needs-info
needs-triage
p0
ready-for-agent
ready-for-human
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Cloonar/nixos!218
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "afk/217"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes #217
What changed
hosts/fw/modules/home-assistant/electricity.nix:sensor.electricity_price(entity id unchanged) is now a moderntemplate:sensor sourced fromsensor.epex_spot_data_market_price(the epex_spot 4.x entity). State =(market_price + fees_net) × 1.20, guarded by anavailabilitytemplate so a missing source makes the entity unavailable instead of raisingTemplateErroron every render.letconstants, one per line of the June 2026 Spotty invoice (Σ ≈ 0.1010 net €/kWh), VAT 20% as the final multiplier. The 2027 Elektrizitätsabgabe revert (0.0010 → 0.015) is a one-line edit.sensor.electricity_price_forecastexposes aforecastattribute:[{start, price}, …]consumer prices for the current + all future intervals from the source'sdataattribute (start_time/end_time/price_per_kwh, resolution-agnostic — works for hourly and 15-min). The entity is excluded from the recorder viarecorder.exclude.entities.apexcharts-card(v2.2.3 from nixos-26.05, verified) installed declaratively viaservices.home-assistant.customLovelaceModules— auto-registers as a Lovelace resource.Deviation from the acceptance criteria (deliberate)
The criteria asked for the
forecastattribute onsensor.electricity_priceitself, excluded from the recorder. That is not implementable on HA 2026.5.4 — verified from the 2026.5.4 source: the recorder'sexcludeconfig is entity-level only (entities/entity_globs/domains/event_types), and the template integration has norecorder.pyplatform and no unrecorded-attributes config option. The brief said "recorder.exclude config or template attribute exclusion — whichever HA 2026.5 supports for attributes"; it supports neither.Options were: (a) put the attribute on
sensor.electricity_priceand exclude that whole entity — loses its state history and long-term statistics; (b) let the attribute be recorded — ~96 attribute rows/day × up to ~192 entries, the exact DB bloat the issue wants to avoid; or (c) a dedicatedsensor.electricity_price_forecastcarrying the attribute, wholly recorder-excluded. I picked (c): zero DB bloat andsensor.electricity_pricekeeps recording clean price history. If you prefer letter-perfect (a), it's a small diff — move theattributes.forecastblock over and swap the excluded entity id.Template validation
Both Jinja templates were validated against a simulated HA environment (HA-style strip + literal_eval, stubbed
state_attr/has_value/as_datetime/now, fake 15-mindatawith past/current/future entries): state math is exact, past intervals are dropped, current interval is kept, output is a native list of{start, price}dicts, and an unavailable source degrades to[]/ unavailable without errors.ApexCharts card YAML (paste into a dashboard via UI, storage mode)
Notes: the forecast only carries current + future intervals, so the chart starts "now" (
span.start: hour); tomorrow's bars appear after day-ahead publication (~14:00). The raw-spot overlay reads the source sensor's owndataattribute, so it also shows today's past hours.Post-merge verification (human follow-ups per the brief)
sensor.electricity_pricetracks(market + 0.101) × 1.2and theTemplateError ... float got invalid input 'unavailable'no longer recurs in the hass container journal (journalctl -D /var/lib/nixos-containers/hass/var/log/journalon fw, per ADR-0005).sensor.epex_spot_data_price/sensor.epex_spot_data_net_priceregistry entries (cosmetic).Pre-commit dry-build for fw: green.
Land-PR audit — verdict: PASS
Checked:
main.src/hash, so the gate's eval-only blind spot does not apply — the referenced nixpkgs attrhome-assistant-custom-lovelace-modules.apexcharts-cardis itself eval-checked.fix(fw):) ✓; no secrets edits, nosystem.stateVersionchange.afk/217carries a workingCloses #217✓.template:syntax, entity idsensor.electricity_pricepreserved, availability guard replaces the old TemplateError failure mode. The triage-resolved price key (price_per_kwh, ISOstart_time/end_time) matches the forecast mapping exactly. Nix float splicing verified:toStringrenders0.101000/1.200000— valid Jinja literals.Noted deviation (deliberate, accepted): the
forecastattribute lives on a dedicatedsensor.electricity_price_forecast(wholly recorder-excluded) rather than onsensor.electricity_price, because HA 2026.5 supports neither attribute-level recorder exclusion nor template unrecorded-attributes. Option (c) preserves price history with zero DB bloat and was explicitly justified in the PR body.