Need help configuring the data for Energy Overview

Hi,

I have been trying for the past few days to correctly configure Home Assistant’s Energy Tab. What I have in my house is 3 wattage meters (one for each phase - red, blue, yellow) that are also connected to araspberrypi and measure the current consumption of each phase in watts.

I am using mqtt to sent data from the raspberry pi to another machine (which has an MQTT broker installed on it) and save this data on an influxdb. Then I am using grafana to display the power consumption data from influxdb. This setup is working great for more than a year now.

Now I am trying to sent the data (again using the mqtt ) to Home Assistant in order to use the Energy Dashboard there.

My configuration in Home Assistant is the following:

sensor energy_red:
  platform: mqtt
  state_topic: "readings/red/meter_reading"
  name: "Power_Meter_Red"
  unit_of_measurement: Wh
  last_reset_topic: "readings/red/meter_reading"
  last_reset_value_template: 1970-01-01T00:00:00+00:00
  #value_template: "{{ ((value | float) /1000)| round(2)}}"
  value_template: "{{ ((value | float))| round(2)}}"
  state_class: total_increasing
  device_class: energy

sensor energy_yellow:
  platform: mqtt
  state_topic: "readings/yellow/meter_reading"
  name: "Power_Meter_Yellow"
  unit_of_measurement: Wh
  last_reset_topic: "readings/yellow/meter_reading"
  last_reset_value_template: 1970-01-01T00:00:00+00:00
  value_template: "{{ ((value | float))| round(2) }}"
  state_class: total_increasing
  device_class: energy

sensor energy_blue:
  platform: mqtt
  state_topic: "readings/blue/meter_reading"
  name: "Power_Meter_Blue"
  unit_of_measurement: Wh
  last_reset_topic: "readings/blue/meter_reading"
  last_reset_value_template: 1970-01-01T00:00:00+00:00
  value_template: "{{  ((value | float))| round(2) }}"
  state_class: total_increasing
  device_class: energy

I have add the three phases to the Energy Dashboard and after a while I do see data coming in. But what I notice then is that the data are not consistent with what actually I consume in my house. For example for one hour I can see that a phase consumes 7-8 KWh while I know for sure that the total consumption for that phase during that time was less than 0.5 KWh.

For another phase I notice that consumption is almost 0 for one hour which is also weird since it does have some load ~ 1KWh

The most weird of all is the total consumption reported by the Energy Dashboard. Is says that for the last 24 hours I consumed more that 40 KWh which I know for sure that I did not.

I tried changing the unit of measurement of the above sensors to KWh instead of Wh and reset the database of Home Assistant so I can start fresh, but in this case I see total consumption in the range of 200-400 kwh in 24 hours.

I also tried adding the sensors in the Overview tab in order to monitor what is being received by Home Assistant through mqtt but those data are consistent to what I see in grafana. So I am guessing the problem is the way that data are being represented by the Energy Dashboard in Home Assistant.

Can someone please shed some light about what how the Energy Dashboard is actually working or even perhaps share a detail documentation about it.

Even better does anyone has done anything similar to what I am trying to do and perhaps share his/her code with me?

Regards,