Energy: how to use custom sensor for solar panel energy production

Hi,
I’m interested in using the latest energy dashboard.
I have Shelly EM monitoring home consumption and production to the grid, and that’s fine.

I also have a ABB inverter for solar panel, from which I read produced energy and instant power using an AppDaemon script that send data through mqtt to 2 sensor (I know that it may be over-engineering, but that what it is for now).
Produced energy read from the inverter is 100% correct, so I’d like to use that in the energy dashboard.

I’ve added attributes last_reset and device_class to the mqtt sensor, but it does not show in the energy management page.

There is a way to make this work?

Thanks

You need all three of these attributes:

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

Also the unit of measurement must be kWh or Wh.

1 Like

It worked, I was missing the state_class attributes! Is it documented somewhere? I think this is a useful use case also for others.

I don’t think so.

Could you please tell how you did solve it? I have several sensor entities from modbus in W. Using Integration - Riemann sum integral - Home Assistant I can turn them into state_class: measurement, but it didn’t work as the device_class: energy is still missing:

Sensor entities are not allowed having device_class: energy.

state_class: measurement
last_reset: '2021-08-18T08:59:13.147768+00:00'
source: sensor.multiplus_critical_loads
unit_of_measurement: kWh
friendly_name: Multiplus Critical Power today
icon: mdi:chart-histogram

IIRC, your sensor.multiplus_critical_loads must be device_class: power so that the integration automatically adds the energy device class

1 Like

now it works THX.