Riemann sum integration result not returning expected unit of measure

Hi all,

I’m trying to make use of an MQTT sensor value (which represents a power meter to 2DP) and have it represented in the Energy Dashboard as a consumer as kWh consumed.

As an example, the MQTT topic has an example value of 41.097
This is updated by NodeRed when ever the value changes on the source smart plug.

I have then added to my configuration file the following config options;

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

sensor:
  - platform: mqtt
    name: "Home Energy Meter"
    state_topic: "lab/fan_test/power"
    unit_of_measurement: 'W'
    qos: 1

  - platform: integration
    source: sensor.home_energy_meter
    name: "New Energy Meter"
    unit_prefix: 'k'
    unit: 'W'
    unit_time: 'h'
    method: left
    round: 2

While I can see that the sensor “sensor.home_energy_meter” has the correct properties;

unit_of_measurement: W
friendly_name: Home Energy Meter
last_reset: 1970-01-01T00:00:00+00:00
device_class: energy
state_class: measurement

The sensor coming from the Reimann sum isn’t coming through correctly - see the UOM “kkWhh”;

state_class: measurement
last_reset: 1970-01-01T00:00:00+00:00
source: sensor.home_energy_meter
unit_of_measurement: kkWhh
friendly_name: New Energy Meter
icon: mdi:chart-histogram
device_class: energy

I’m not sure what is causing this and as far as I can tell, the documentation I’m reading seems to align with my configuration.

Here’s a visual of the cards while I was experimenting with them;


Where it flattens out is where I added further config properties.

Can someone see if I’ve made a stupid mistake or when I can do to correct the issue and get the converted Watts from my smart plug to the energy dashboard as kWh consumed?

Try removing unit and unit_time from the riemann sensor config.

I’ve removed both and it doesn’t appear to have changed anything. :frowning:

image

sensor:    
  - platform: mqtt
    name: "Home Energy Meter"
    state_topic: "lab/fan_test/power"
    unit_of_measurement: 'W'
    qos: 1

  - platform: integration
    source: sensor.home_energy_meter
    name: "New Energy Meter"
    unit_prefix: 'k'
    method: left
    round: 2

Don’t hate me for saying this, but did you do a restart of HA after removing the two lines? :grin:

Haha, yes, several times as I was tweaking both the MQTT sensor and the Riemann sum