Skip to content

Fix recorder/import_statistics metadata deprecation (HA Core 2026.11) - #191

Open
antoinevalentinHA wants to merge 1 commit into
bokub:masterfrom
antoinevalentinHA:fix/recorder-statistics-metadata-ha-2026-11
Open

Fix recorder/import_statistics metadata deprecation (HA Core 2026.11)#191
antoinevalentinHA wants to merge 1 commit into
bokub:masterfrom
antoinevalentinHA:fix/recorder-statistics-metadata-ha-2026-11

Conversation

@antoinevalentinHA

@antoinevalentinHA antoinevalentinHA commented Jul 2, 2026

Copy link
Copy Markdown

Home Assistant now warns when recorder/import_statistics is called without mean_type and unit_class in metadata.

Fixes #161.
Fixes #182.

The imported Linky statistics are cumulative sums, not averages, so this PR adds:

  • mean_type: 0
  • unit_class: 'energy' for Wh-based energy statistics
  • unit_class: null for cost statistics in €

The existing has_mean: false field is kept for backward compatibility with older Home Assistant versions.

This does not change:

  • Linky data retrieval logic
  • entity names
  • statistic IDs
  • existing units

Validation:

  • Static review of the WebSocket payload sent to recorder/import_statistics
  • Verified that mean_type and unit_class are now included in the metadata
  • Local Node/npm checks were not run on the patch machine because Node/npm were unavailable

Context:

Home Assistant deprecated metadata without mean_type and unit_class; the current behavior triggers daily Recorder warnings and is expected to stop working in HA Core 2026.11.

Home Assistant deprecated calling recorder/import_statistics without
mean_type and unit_class in metadata since HA Core 2025.11; these fields
become mandatory in HA Core 2026.11.

Add both fields to the imported statistics metadata:
- mean_type: 0 (StatisticMeanType.NONE) since Linky statistics are
  cumulative sums (energy / costs) with no averaging. Complements the
  now-deprecated has_mean: false, which is kept for backward compatibility.
- unit_class: 'energy' for Wh consumption/production stats; null for
  monetary cost stats (€), which have no HA unit conversion class.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
antoinevalentinHA added a commit to antoinevalentinHA/ha-linky that referenced this pull request Jul 2, 2026
Document fork-specific changes in CHANGELOG.md under a dedicated
"Fork changes — Antoine Valentin" section, clearly separated from upstream
releases: the upstream-candidate Recorder metadata fix (PR bokub#191), the
fork-only add-on identification and local-build adaptations, runtime
validation, and rollback notes.

Documentation only; no functional files changed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@andreaippo

Copy link
Copy Markdown

I am running this and it works - stats are still present and the WARN message is gone.

Merci!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants