Energy sensor not in energy dashboard drop-down menu

Hello,
I feel a little bit confused about energy sensor.
I’m trying to use some energy data coming from a sensor put directly on my utility meter.
It delivers data via mqtt. It is already an energy measurement so I don’t need to integrate it.
So first I configured the sensor:

sensor:
  - platform: mqtt
    name: "total_energy"
    state_topic: "1694498882.KWh"
    unit_of_measurement: "KWh"
    force_update: true
    icon: mdi:transmission-tower

then, if I understood well, it need a last_reset and some other attributes which I assigned using customize_glob

customize_glob:
  "sensor.*_energy":
    last_reset: '1970-01-01T00:00:00+00:00'
    device_class: energy
    state_class: measurement

Then I have asked HA to record the entity:

recorder:
  auto_purge: true
  purge_keep_days: 366
  include:
    entities:
      - sensor.total_energy

Despite this I cannot see the entity in the drop-down menu of the energy dashboard to be picked up.
What am I missing?

Thanks a lot for your help

No don’t do that. All you need is to add the following device and state classes to your sensor:

sensor:
  - platform: mqtt
    name: "total_energy"
    state_topic: "1694498882.KWh"
    unit_of_measurement: "kWh"
    force_update: true
    icon: mdi:transmission-tower
    device_class: energy
    state_class: total_increasing

Your unit of measurement must be kWh not KWh.

oh! thaks it works!

So state_class: total_increasing replaces both

state_class: measurement
last_reset: '1970-01-01T00:00:00+00:00'

because it tells HA that it’s a measure that is being increasing forever.
and the capital K in kWh gave wrong units so it couldn’t be correctly showed

Right?

Correct.

1 Like