Skip to content

Invalid state_class MEASUREMENT with device_class ENERGY on session energy sensors #2

Description

@xtux77

Problem

The sensors green_energy_session and grid_energy_session are defined with
state_class = SensorStateClass.MEASUREMENT while using device_class = SensorDeviceClass.ENERGY.

Home Assistant considers this combination invalid and logs a warning at startup,
because an ENERGY device_class expects TOTAL or TOTAL_INCREASING, not MEASUREMENT.

Environment

  • Integration: wallbox_gateway (installed via HACS, v0.22.0)
  • Gateway firmware: v3.2.0-beta.13 (botts7/esp32-wallbox)
  • Home Assistant Core (container)

Location

custom_components/wallbox_gateway/sensor.py — the green_energy_session and
grid_energy_session sensor definitions.

Suggested fix

Use SensorStateClass.TOTAL_INCREASING for both sensors, matching the sibling
session_energy sensor which is already correct.

Log

Entity ... has state class measurement and unit ... but device class energy ...
which is impossible. Please update ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions