Energy sensor with correct device class results in error

I only noticed this yesterday.

This is my source (power) sensor:

    sensor:
      - name: "Geyser Power"
        icon: mdi:water-boiler
        unit_of_measurement: W
        device_class: power
        state: >-
          {# the geyser is the only device on the non-essential circuit #}
          {% set geyser = states('sensor.load_power_non_essential') | int(0) %}
          {{ geyser if geyser > 0 else 0 }}

This is the energy sensor:

  - platform: integration
    name: "Geyser Energy"
    source: sensor.geyser_power
    unit_prefix: k
    unit_time: h
    method: left
    round: 3

The Riemann integration docs state:

This configuration will provide you with sensor.energy_spent which will have your energy in kWh, as a device_class of energy .

Indeed it does:

Yet:

What am I missing?

Your source power sensor is missing a state class.

    sensor:
      - name: "Geyser Power"
        icon: mdi:water-boiler
        unit_of_measurement: W
        device_class: power
        state_class: measurement  ### <---- This
        state: >
          {# the geyser is the only device on the non-essential circuit #}
          {% set geyser = states('sensor.load_power_non_essential') | int(0) %}
          {{ geyser if geyser > 0 else 0 }}

After restarting you may have to go to Developer Tools → Statistics to fix an issue.

Bugger, I was wondering whether it could have to do with the state class — of the energy sensor, not the power sensor, but the energy sensor has one.

The error message is a little misleading.

Do you know why the underlying source sensor’s state class affects it in this way, because the energy sensor has everything it needs? Unless, it doesn’t like the state class of total or sees some mismatch of sorts.

I’ll implement your suggestion over the weekend and report back. (I’m going to be out of commission for a few days.)

Tom, this is odd, but it auto resolved.

I made another change earlier that required a restart and wanted to tackle this issue next. After the restart I don’t see the warning anymore.