Skip to content

Fix invalid state_class for session energy sensors - #3

Open
xtux77 wants to merge 1 commit into
botts7:mainfrom
xtux77:fix/energy-session-state-class
Open

Fix invalid state_class for session energy sensors#3
xtux77 wants to merge 1 commit into
botts7:mainfrom
xtux77:fix/energy-session-state-class

Conversation

@xtux77

@xtux77 xtux77 commented Jul 5, 2026

Copy link
Copy Markdown

Summary

green_energy_session and grid_energy_session are defined with
state_class = MEASUREMENT while using device_class = ENERGY. Home Assistant
rejects this combination and logs a warning at startup, because an ENERGY
device_class expects TOTAL or TOTAL_INCREASING, not MEASUREMENT.

This PR switches both sensors to TOTAL_INCREASING, matching the sibling
session_energy sensor (which already carries a comment explaining exactly
this). total_increasing still models the per-session reset correctly — HA
detects the reset — so the per-session semantics are preserved. The now-stale
comment above the two sensors is updated accordingly.

Testing

  • python3 -m py_compile custom_components/wallbox_gateway/sensor.py passes.

Fixes #2

🤖 Generated with Claude Code

green_energy_session and grid_energy_session used
state_class=MEASUREMENT with device_class=ENERGY, which Home Assistant
rejects (logs a warning at startup), since an ENERGY device_class
expects TOTAL or TOTAL_INCREASING.

Switch both to TOTAL_INCREASING, matching the sibling session_energy
sensor. total_increasing correctly models the per-session reset (HA
detects the reset), so the per-session semantics are preserved.

Fixes botts7#2

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.

Invalid state_class MEASUREMENT with device_class ENERGY on session energy sensors

1 participant