Hi, I found this conversation so I think is good to keep it here for everyone else. I also had a problem with energy spike that is messing up with my historic data. My problem here is not the origin of the incorrect data but the data itself.
My problem is that in energy dashboard I see the data spike but when going to Deverloper tools > Statistics; I cant find the data that creates that spike within the entity. I search within the day and within the hours in Statistics and nothing was recorded related to that entity.
If I search in the history no data has been recorded within the day of the spike.
This is heading down a slightly different path to the original question, however I had this problem as well. My SMA Home Manager Energy Meter occasionally provides a garbage value for several of its reported parameters.
To fix out of range errors, I processed the values through a bounding template, where the values are clipped at “reasonable” values when excessive values are supplied.
templates.yaml:
# Solar Power
# Sum all solar producers
# Limited to positive and <20kw to reduce noise from data corruption
- sensor:
- name: Solar Power
unique_id: solar_power
device_class: power
state_class: measurement
unit_of_measurement: W
state: >
{% set net_power = states('sensor.sb5_0_1av_41_887_pv_power') | float(0) %}
{{ [[ net_power, 0 ] | max, 20000] | min }}
The second issue can be that your energy sensor (or perhaps your template) replies with a zero value rather than ‘unavailable’ during data loss or initialisation. When the new value appears, the energy sensor will use the new value as if the sensor had been reset and produce a massive first value. You can really only fix this (I believe) with a template that correctly invalidates garbage values.