Energy consumed and produced - from the MQTT sensors - how?

hi
I have some trouble setting up my energy dashboard. I have MEW-01 device which gives me total energy forward and reverse in watts, and I have it configured through MQTT sensors:

- platform: mqtt
  name: total_reverse_active_energy
  device_class: power
  state_class: total_increasing
  unit_of_measurement: W
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_reverse_active_energy"

- platform: mqtt
  name: total_forward_active_energy
  state_class: total_increasing
  unit_of_measurement: W
  device_class: power
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_forward_active_energy"

I cannot figure out, how I can make these two configured as energy consumed and produced sources in the Energy dashboard.

I think it needs to be configured with Riemann sum:

- platform: integration
  source: sensor.total_reverse_active_energy
  name: energia_total_reverse_active_energy
  round: 2
  unit_prefix: k

- platform: integration
  source: sensor.total_forward_active_energy
  name: energia_total_forward_active_energy
  round: 2
  unit_prefix: k

but it still doesn’t show in the dropdown of the Energy configuration screen.
Desperately looking for help :slight_smile:

The state classes of your power sensors are incorrect. Should be:

- platform: mqtt
  name: total_reverse_active_energy
  device_class: power
  state_class: measurement 
  unit_of_measurement: W
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_reverse_active_energy"

- platform: mqtt
  name: total_forward_active_energy
  state_class: measurement 
  unit_of_measurement: W
  device_class: power
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_forward_active_energy"

ah all right. But these MQTT topics give me a total, increasing value. Still the ‘measurement’ is the correct state_class?

Well in that case you have unit and device class incorrect and you don’t need the Riemann sum helpers, try this:

- platform: mqtt
  name: total_reverse_active_energy
  device_class: energy
  state_class: total_increasing
  unit_of_measurement: kWh
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_reverse_active_energy"

- platform: mqtt
  name: total_forward_active_energy
  state_class: total_increasing
  unit_of_measurement: kWh
  device_class: energy
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_forward_active_energy"

ok, so I have now:

- platform: mqtt
  name: total_reverse_active_energy
  device_class: energy
  state_class: total_increasing
  unit_of_measurement: kWh
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_reverse_active_energy"

- platform: mqtt
  name: total_forward_active_energy
  state_class: total_increasing
  unit_of_measurement: kWh
  device_class: energy
  state_topic: "supla/devices/zamel-mew-01-3a25da/channels/0/state/total_forward_active_energy"

The sensors work fine when I look at them in the Developers Tools, but somehow they still don’t show up in the dropdown:

Not sure what else I’m doing wrong…

Try restarting home assistant.

Also go to Developer Tools → Statistics and press all the FIX ISSUE buttons.

It seems I have some MQTT issues, this maybe the reason they don’t show in the Energy configuration dropdown:

I did it, still don’t see them in the energy configuration dropdown.