feat: FRITZ!Smart Energy 250 — energy direction detection + Grafana dashboard - #146
Open
locorida wants to merge 1 commit into
Open
feat: FRITZ!Smart Energy 250 — energy direction detection + Grafana dashboard#146locorida wants to merge 1 commit into
locorida wants to merge 1 commit into
Conversation
The Smart Energy 250 grid meter reports two channels (-1 import, -2 export) with identical instantaneous power but separate energy counters. This adds a sliding-window algorithm (300s default) that compares cumulative energy deltas to reliably detect the current energy flow direction, even at low power levels where single-interval Wh deltas round to zero. New metrics: - ha_energy_direction (string: import/export/balanced/unknown) - ha_energy_direction_numeric (int: 1/-1/0) - ha_energy_net_power (float: signed Watt, negative = export) Includes a dedicated Grafana dashboard with net power time series, direction state timeline, and hourly import/export bar chart.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The FRITZ!Smart Energy 250 reports two sub-devices (
-1= grid import,-2= grid export) with separate cumulative energy counters but identical instantaneous power readings. Without additional logic, it's impossible to determine whether the household is currently importing or exporting energy.This PR adds:
ha_energy_direction(string:import/export/balanced/unknown)ha_energy_direction_numeric(int:1/-1/0)ha_energy_net_power(float: signed Watt — negative = solar export)fritzbox_smart_energy_250_dashboard.json) with net power time series, direction state timeline, and hourly import/export bar chartMotivation
The Smart Energy 250 is increasingly used by PV system owners to monitor grid interaction. The existing
ha_powermeter_powerandha_powermeter_energymetrics are collected per channel, but there's no computed direction indicator. Users currently have to build custom Flux queries comparing channel deltas — this PR makes it work out of the box.Technical approach
The energy counters have 1 Wh resolution. At 100 W, a 30-second polling interval only produces 0.83 Wh — not enough for a counter increment. The sliding window (default 300s) accumulates ~8 Wh of delta, which reliably distinguishes the active channel. The tracker is stateless across restarts (direction detection resumes after one window period).
Changes
fritzinfluxdb/classes/fritzbox/energy_direction.py— new module withEnergyDirectionTrackerfritzinfluxdb/classes/fritzbox/service_definitions/homeauto.py— energy tracking hook + new Smart Energy 250 metricsgrafana/influx2_dashboards/fritzbox_smart_energy_250_dashboard.json— dedicated dashboardREADME.md— documentation section for Smart Energy 250Testing
Tested with FRITZ!Smart Energy 250 on FRITZ!Box 7530 AX (FRITZ!OS 8.25). Direction detection stabilizes after the initial 300s window.