Skip to content

feat: FRITZ!Smart Energy 250 — energy direction detection + Grafana dashboard - #146

Open
locorida wants to merge 1 commit into
bb-Ricardo:mainfrom
locorida:feature/smart-energy-250-direction
Open

feat: FRITZ!Smart Energy 250 — energy direction detection + Grafana dashboard#146
locorida wants to merge 1 commit into
bb-Ricardo:mainfrom
locorida:feature/smart-energy-250-direction

Conversation

@locorida

Copy link
Copy Markdown

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:

  • Sliding-window direction detection (300s default) — compares energy counter deltas across both channels to reliably detect flow direction, even at low power levels where single-interval Wh deltas round to zero
  • Three 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 = solar export)
  • Dedicated Grafana dashboard (fritzbox_smart_energy_250_dashboard.json) with net power time series, direction state timeline, and hourly import/export bar chart

Motivation

The Smart Energy 250 is increasingly used by PV system owners to monitor grid interaction. The existing ha_powermeter_power and ha_powermeter_energy metrics 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 with EnergyDirectionTracker
  • fritzinfluxdb/classes/fritzbox/service_definitions/homeauto.py — energy tracking hook + new Smart Energy 250 metrics
  • grafana/influx2_dashboards/fritzbox_smart_energy_250_dashboard.json — dedicated dashboard
  • README.md — documentation section for Smart Energy 250

Testing

Tested with FRITZ!Smart Energy 250 on FRITZ!Box 7530 AX (FRITZ!OS 8.25). Direction detection stabilizes after the initial 300s window.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants