Energy: Electricity grid consumption from an MQTT power entity?

Hello. I’m trying to use the “Energy” feature. I’m trying to configure Grid consumption (Configuration / Energy / ADD CONSUMPTION). Power is obtained from an mqtt sensor relaying power. I keep getting “No Matching statistics found” in the Consumed Energy (kWh) drop down. My confg:

- platform: mqtt
  state_topic: emonpi/power
  name: Power Use
  unique_id: emonpi_power
  state_class: measurement
  device_class: power
  # unit_of_measurement: "W"

- platform: integration
  source: sensor.emonpi_power
  name: energy_use
  unit_prefix: k
  round: 6

This is the arrangement that I’ve seen reported elsewhere as working, but it’s not working for me.

Can anyone shed any light? Thank you.

sensor.power_use

Many thanks. There is no entity sensor.power_use on my system. I changed it in case there was some magic behind the scenes, but it still shows “No matching statistics found”.

Check state at Developer Tools

Check the state of what? Both sensor.power_use and sensor.energy_use are available and registering data. Neither are available as a source of statistical data for grid consumption configuration. I appreciate your time, and admire brevity as much as anyone, but your comments are a little too cryptic for me to follow. Thank you again, though

1 Like

This:

- platform: mqtt
  state_topic: emonpi/power
  name: Power Use
  unique_id: power_use
  state_class: measurement
  device_class: power
  unit_of_measurement: W

- platform: integration
  source: sensor.power_use
  name: energy_use
  unit_prefix: k
  round: 6

is, in Developer Tools / State Attributes, generating this for sensor.energy_use:

state_class: total
source: sensor.power_use
unit_of_measurement: kh
friendly_name: energy_use
icon: mdi:chart-histogram
device_class: energy

I’ve no idea why unit_of_measurement is kh, not kWh as in your example, but I’m guessing that’s why it can’t find an energy statistic. Do you know what I’m doing wrong?

If a restart dont help. change to


- platform: mqtt
  state_topic: emonpi/power
  name: Power Use A
  unique_id: power_use_a
  state_class: measurement
  device_class: power
  unit_of_measurement: W

- platform: integration
  source: sensor.power_use_a
  name: energy_use_a
  unit_prefix: k
  round: 6

Another solution it’s to edit database. Cannot help on that.

1 Like
state_class: total
source: sensor.power_use_a
unit_of_measurement: kWh     <------ :)
friendly_name: energy_use_a
icon: mdi:chart-histogram
device_class: energy

I think that fixed it. I could select sensor.energy_use_a. It’s currently reporting that “statistics_not_defined”, but I assume it’s currently aggregating and this will become available.

Thank you for your help!

1 Like