Energy Dashboard shows false consumption every day right after midnight

Hi community,

My Energy Dashboard shows false consumption every day right after midnight in total amount of 0,94 kWh.

Data to sensor are pushed via mosquitto broker and client is Tasmota with PZEM module. Here is the evidence that such consumption is never seen in JSON data pushed to Home Assistant.

{"Time":"2024-07-16T23:58:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.903,2841.010,2435.305],"Yesterday":[1.040,0.123,0.402],"Today":[1.192,0.124,0.399],"Period":[1,1,0],"Power":[61,5,17],"ApparentPower":[117,12,29],"ReactivePower":[99,10,23],"Factor":[0.52,0.45,0.58],"Frequency":[50,50,49],"Voltage":[234.9,233.9,234.2],"Current":[0.497,0.050,0.122]}}
{"Time":"2024-07-16T23:58:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.903,2841.010,2435.305],"Yesterday":[1.040,0.123,0.402],"Today":[1.192,0.124,0.399],"Period":[0,0,0],"Power":[61,6,17],"ApparentPower":[117,12,29],"ReactivePower":[99,11,24],"Factor":[0.53,0.47,0.56],"Frequency":[50,50,49],"Voltage":[234.8,233.7,234.0],"Current":[0.497,0.051,0.126]}}
{"Time":"2024-07-16T23:59:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.903,2841.010,2435.306],"Yesterday":[1.040,0.123,0.402],"Today":[1.192,0.124,0.400],"Period":[0,0,1],"Power":[62,5,17],"ApparentPower":[117,12,29],"ReactivePower":[100,10,24],"Factor":[0.53,0.46,0.57],"Frequency":[50,50,49],"Voltage":[235.2,234.1,234.4],"Current":[0.499,0.050,0.124]}}
{"Time":"2024-07-16T23:59:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.904,2841.010,2435.306],"Yesterday":[1.040,0.123,0.402],"Today":[1.193,0.124,0.400],"Period":[1,0,0],"Power":[62,5,17],"ApparentPower":[117,12,29],"ReactivePower":[100,10,24],"Factor":[0.53,0.46,0.57],"Frequency":[50,50,49],"Voltage":[235.8,234.6,234.8],"Current":[0.496,0.050,0.123]}}
{"Time":"2024-07-17T00:00:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.905,2841.010,2435.306],"Yesterday":[1.193,0.124,0.400],"Today":[0.001,0.000,0.000],"Period":[1,0,0],"Power":[62,5,17],"ApparentPower":[119,12,30],"ReactivePower":[102,11,25],"Factor":[0.52,0.45,0.56],"Frequency":[50,50,48],"Voltage":[235.7,234.4,234.5],"Current":[0.506,0.051,0.127]}}
{"Time":"2024-07-17T00:00:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.905,2841.010,2435.306],"Yesterday":[1.193,0.124,0.400],"Today":[0.001,0.000,0.000],"Period":[0,0,0],"Power":[61,5,17],"ApparentPower":[118,12,29],"ReactivePower":[101,10,24],"Factor":[0.52,0.46,0.58],"Frequency":[50,50,48],"Voltage":[235.6,234.2,234.5],"Current":[0.500,0.050,0.123]}}
{"Time":"2024-07-17T00:01:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.905,2841.010,2435.306],"Yesterday":[1.193,0.124,0.400],"Today":[0.001,0.000,0.000],"Period":[0,0,0],"Power":[61,5,17],"ApparentPower":[118,12,30],"ReactivePower":[101,11,25],"Factor":[0.52,0.44,0.56],"Frequency":[50,50,48],"Voltage":[235.6,234.4,234.6],"Current":[0.500,0.050,0.127]}}
{"Time":"2024-07-17T00:01:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.906,2841.010,2435.306],"Yesterday":[1.193,0.124,0.400],"Today":[0.002,0.000,0.000],"Period":[1,0,0],"Power":[61,5,17],"ApparentPower":[117,12,30],"ReactivePower":[100,11,25],"Factor":[0.52,0.44,0.55],"Frequency":[50,50,48],"Voltage":[235.6,234.5,234.6],"Current":[0.498,0.050,0.129]}}
{"Time":"2024-07-17T00:02:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.906,2841.010,2435.306],"Yesterday":[1.193,0.124,0.400],"Today":[0.002,0.000,0.000],"Period":[0,0,0],"Power":[62,6,17],"ApparentPower":[117,12,29],"ReactivePower":[99,11,23],"Factor":[0.53,0.46,0.58],"Frequency":[50,50,48],"Voltage":[235.1,233.9,234.0],"Current":[0.497,0.051,0.122]}}
{"Time":"2024-07-17T00:02:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.907,2841.010,2435.306],"Yesterday":[1.193,0.124,0.400],"Today":[0.003,0.000,0.000],"Period":[1,0,0],"Power":[62,6,17],"ApparentPower":[117,12,29],"ReactivePower":[99,11,24],"Factor":[0.53,0.47,0.57],"Frequency":[50,50,48],"Voltage":[235.0,233.8,233.8],"Current":[0.496,0.051,0.124]}}
{"Time":"2024-07-17T00:03:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.907,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.003,0.000,0.001],"Period":[0,0,1],"Power":[61,5,17],"ApparentPower":[116,11,28],"ReactivePower":[99,10,23],"Factor":[0.53,0.44,0.58],"Frequency":[50,50,48],"Voltage":[234.7,233.8,233.8],"Current":[0.495,0.049,0.121]}}
{"Time":"2024-07-17T00:03:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.908,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.004,0.000,0.001],"Period":[1,0,0],"Power":[62,5,17],"ApparentPower":[117,12,28],"ReactivePower":[99,10,23],"Factor":[0.53,0.45,0.58],"Frequency":[50,50,48],"Voltage":[234.9,233.8,234.1],"Current":[0.497,0.050,0.121]}}
{"Time":"2024-07-17T00:04:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.909,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.005,0.000,0.001],"Period":[1,0,0],"Power":[61,5,17],"ApparentPower":[116,12,30],"ReactivePower":[99,11,25],"Factor":[0.53,0.45,0.55],"Frequency":[50,50,48],"Voltage":[235.2,234.1,234.3],"Current":[0.495,0.051,0.127]}}
{"Time":"2024-07-17T00:04:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.909,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.005,0.000,0.001],"Period":[0,0,0],"Power":[62,6,17],"ApparentPower":[117,12,29],"ReactivePower":[100,11,24],"Factor":[0.52,0.46,0.57],"Frequency":[50,50,48],"Voltage":[235.3,234.1,234.2],"Current":[0.499,0.052,0.123]}}
{"Time":"2024-07-17T00:05:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.909,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.005,0.000,0.001],"Period":[0,0,0],"Power":[61,5,17],"ApparentPower":[117,12,29],"ReactivePower":[99,11,24],"Factor":[0.53,0.44,0.56],"Frequency":[50,50,48],"Voltage":[235.2,234.1,234.1],"Current":[0.496,0.050,0.126]}}
{"Time":"2024-07-17T00:05:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.910,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.006,0.000,0.001],"Period":[1,0,0],"Power":[61,5,17],"ApparentPower":[117,12,29],"ReactivePower":[99,11,24],"Factor":[0.53,0.44,0.56],"Frequency":[50,50,48],"Voltage":[235.1,233.9,233.9],"Current":[0.497,0.050,0.126]}}
{"Time":"2024-07-17T00:06:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.911,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.007,0.000,0.001],"Period":[1,0,0],"Power":[61,6,17],"ApparentPower":[117,12,30],"ReactivePower":[99,11,25],"Factor":[0.53,0.47,0.56],"Frequency":[50,50,48],"Voltage":[235.7,234.4,234.5],"Current":[0.495,0.051,0.127]}}
{"Time":"2024-07-17T00:06:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.911,2841.010,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.007,0.000,0.001],"Period":[0,0,0],"Power":[61,5,17],"ApparentPower":[117,12,29],"ReactivePower":[99,10,24],"Factor":[0.53,0.45,0.56],"Frequency":[50,50,48],"Voltage":[235.0,233.7,233.8],"Current":[0.497,0.050,0.125]}}
{"Time":"2024-07-17T00:07:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.912,2841.011,2435.307],"Yesterday":[1.193,0.124,0.400],"Today":[0.008,0.001,0.001],"Period":[1,1,0],"Power":[61,5,16],"ApparentPower":[117,12,29],"ReactivePower":[100,10,25],"Factor":[0.52,0.46,0.56],"Frequency":[50,50,48],"Voltage":[234.9,233.6,233.8],"Current":[0.498,0.050,0.126]}}
{"Time":"2024-07-17T00:07:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.912,2841.011,2435.308],"Yesterday":[1.193,0.124,0.400],"Today":[0.008,0.001,0.002],"Period":[0,0,1],"Power":[61,5,17],"ApparentPower":[117,12,29],"ReactivePower":[100,10,24],"Factor":[0.52,0.45,0.57],"Frequency":[50,50,48],"Voltage":[235.3,234.0,234.1],"Current":[0.497,0.050,0.124]}}
{"Time":"2024-07-17T00:08:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.913,2841.011,2435.308],"Yesterday":[1.193,0.124,0.400],"Today":[0.009,0.001,0.002],"Period":[1,0,0],"Power":[61,5,17],"ApparentPower":[116,12,30],"ReactivePower":[98,11,25],"Factor":[0.53,0.44,0.55],"Frequency":[50,50,48],"Voltage":[235.2,234.0,234.2],"Current":[0.493,0.050,0.127]}}
{"Time":"2024-07-17T00:08:56","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.913,2841.011,2435.308],"Yesterday":[1.193,0.124,0.400],"Today":[0.009,0.001,0.002],"Period":[0,0,0],"Power":[61,6,17],"ApparentPower":[116,12,30],"ReactivePower":[98,10,25],"Factor":[0.53,0.47,0.55],"Frequency":[50,50,48],"Voltage":[235.4,234.1,234.3],"Current":[0.492,0.050,0.128]}}
{"Time":"2024-07-17T00:09:26","ENERGY":{"TotalStartTime":"2022-06-25T10:13:13","Total":[3711.914,2841.011,2435.308],"Yesterday":[1.193,0.124,0.400],"Today":[0.010,0.001,0.002],"Period":[1,0,0],"Power":[61,5,17],"ApparentPower":[117,12,30],"ReactivePower":[99,11,25],"Factor":[0.53,0.45,0.56],"Frequency":[50,50,48],"Voltage":[235.8,234.5,234.8],"Current":[0.495,0.050,0.127]}}

You can see that JSON Key “Today” does not have such value at all.

Also from the sensor graph you can see that around midnight there is no such consumption.

Any ideas?

Share the history graph of the sensor from the history panel zoomed in around midnight (so a little before and a little after).

My guess is that your sensor is not resetting exactly at “00:00”.

I think you are right!

It looks Tasmota sends data at 00:00:27, so 27 seconds after midnight hass still thinks there is no zero in consumption. I need to figure out how to make Tasmota to reset Today metering exactly at 00:00:00

Probably this:

https://tasmota.github.io/docs/Commands/#management

NtpServer<x> 	NTP server setup (x= 1..3)
0 = clear NtpServer<x> settings
1 = reset NtpServer<x> settings to firmware defaults
<value> = set NtpServer<x> host or IP address (32 char limit)

Try NtpServer1 unless you have a router that has an NTP service. In which case set everything (Including HA) to sync off that IP address.

I am trying to understand why resetting later than 00:00 results in this behavior.
What is the state_class and device_class of this sensor?

Well it’s an energy sensor, so

device_class: energy
state_class: total_increasing 

Or it would not be able to be added to the energy dashboard.

The problem is that home assistant calculates the energy statistics hourly. If your sensor does not reset until after midnight all that energy gets added to the 0:00 to 1:00 hour bin for the next day.

Your energy devices and home assistant need to be tightly time synchronised if you are using daily resetting sensors. That’s where the NTP server comes in.

EDIT: sorry did not realise that was not the original poster asking the question.

here we go…

state_class: total_increasing
unit_of_measurement: kWh
icon: mdi:calculator
friendly_name: PZEM CHBK32 ENERGY Today
device_class: energy

and this sensor is helper, that sums L1+L2+L3 energy today, because I use per Line (phase) energy monitoring for purpose

That’s fine. Are all the PZEM’s connected to the same Tasmota device?

the thing is I use 30 seconds telemetry period, in Tasmota this is TelePeriod command, so still first mqtt will be send probably at 00:00:30, or?

yes, one esp board handles all 3 PZEMs

BTW: You can fix the glitch by clicking on the ramp icon next to your entity in Developer Tools → Statistics and navigating to just past 0:00 and setting the huge value to 0.

But you need to stop it from keeping on happening.

I’m not sure, I stopped using Tasmota well before the energy dashboard was released (ESPHome FTW).

I am fixing every day :smile:

OK, I think I will try to make Tasmota rule to send telemetry exactly at 00:00 and will see. NTP is working fine.

The other option is to filter your energy total sensor through a daily cycle Utility meter helper. That will reset to 0 when HA thinks it is midnight.

Couldn’t you just use the total sensor in the energy dashboard instead of the daily resetting one?

1 Like

ok, thanks, I will try that, if tasmota rule does not help.

meanwhile I did:

ON Time#Minute=0 DO Teleperiod ENDON

will see tomorrow if this works.

That too would be a solution, if Tasmota supplies an ever increasing energy sensor.

Yeap, another option. Let me try that too and see tomorrow.

Insteresting. It still does not work.

with the help of Tasmota rule, I was able to achive that update is sent just 2 seconds after midnight, however dashboard still shows this false consumption even bigger then yesterday.

as plan B I also created new entity of total energy not reseting every day, but in Dasboard it says it does not have right device_class, so i cannot use it.

any ideas?

Your always increasing energy sensor should have the following attributes:

device_class: energy
state_class: total # not measurement

ok, but how to ensure this, if my entity is created in Helper? I have no chance to modify that attributes or?

if I look the source entity that I use in helper, it is fine:

state_class: total
unit_of_measurement: kWh
device_class: energy
friendly_name: PZEM CHBK32 ENERGY Total 0

but somehow Helper entity is not gaining these attributes