Not sure if what I mention below helps any but thought it worth mentioning.
I had a similar issue with my energy dashboard and a zigbee pulse meter. If for whatever reason the zigbee network has a moment, the (custom) sensor (based on the Zigbee pulse meter) I am using to track energy usage would drop to zero briefly and when it came back to life, the dashboard has recorded a massive spike in energy usage - the difference between 0 and the (now working again) figure from the sensor.
For example, if my cumulative figure from the sensor was 1000, the zigbee network wobbles, sensor goes to zero, zigbee comes back seconds later, the sensor reports 1000 again, I’ve apparently used 1000kWh in that space of time.
I am not certain but it could be related to the fact that in my case, I’ve had to create a custom sensor myself based on the input data from the Zigbee pulse meter rather than the pulse meter’s actual data itself. (In my case, the Zigbee pulse meter uses a hard-coded 1000 impulses per kWh but my actual energy meter uses 4000 pulses per kWh)
To do that, I have this in my config - this is the sensor I add to the energy dashboard’s config:
template:
- sensor:
- name: "Home Energy Consumption"
state: "{{ states('sensor.home_power_consumption') | float / 40 }}"
unit_of_measurement: "kWh"
icon: mdi:flash
state_class: total_increasing
unique_id: "home_energy_consumption"
device_class: "energy"
I think the problem for me at least was that as mentioned above, the custom sensor goes to zero (rather than unavailable) before returning to normal.
To fix that, I read that adding an availability:
section to the sensor would prevent it recording zero. Unfortunately I don’t recall who suggested this (kudos goes to them).
As such, I ended up with this instead (adding the rounding for my own benefit) but the availability
section seems to have fixed matters as it hasn’t happened again since:
template:
- sensor:
- name: "Home Energy Consumption"
state: "{{ states('sensor.home_power_consumption') | float / 40 | round(5) }}"
unit_of_measurement: "kWh"
icon: mdi:flash
state_class: total_increasing
unique_id: "home_energy_consumption"
device_class: "energy"
availability: "{{ states('sensor.home_power_consumption') | int(default=-100000) > -100000 }}"