Negative energy ussage last night

Hello everyone,

I’ve recently set up a new ESP home sensor to monitor my energy usage through my P1 port. So far, everything has been functioning smoothly. I even added an extra sensor to track the daily costs from my energy provider.

However, last night, I noticed a significant anomaly. Between 04:00 and 05:00, my usage for both Tariff 1 and 2 suddenly displayed as negative. Here’s a snapshot of the unexpected drop:

I checked both entities, but couldn’t find anything unusual:


For context, I switched over to the lower Tariff 1 at 21:00 last night, which I maintain throughout the weekend.

I’ve tried searching Google and this forum for solutions, but most results lead back to an issue from last May caused by a bug that was released in home assistant.

Could anyone assist me or direct me to a relevant post for troubleshooting this issue or at least fix the data? I’m struggling to find more detailed information that links the energy dashboard to my sensors.

Thank you in advance!

I had it happen a few times in the past 3 days. Mostly in the early mornings.

Hi,

You can try;
Ontwikkelingshulpmiddelen > Statistieken > Zoek sensor > Klik op onderstaande icoon
afbeelding

English:
Developertools > Statistics > Search for the sensor and click on the above shown icon

Thanks! That worked. Any idea how i can prevent this in the future or look into the source of the problem?

The graphs of the entities don’t show a drop, isn’t that weird?

Edit:
How stupid would it be set filter on the sensor in ESP home? Can negative values for energy_delivered_tariff1 and energy_delivered_tariff2 be logical?

Regarding to the below;

Don’t make changes on a sensor setting when the sensor is writing to the SQL database :wink:
I think this was causing the negative date.
Other reasons can be a drop of connection to your Wi-Fi network or bad signal.

It shows a little gap

Good spot! I missed that!

Would that explain a weird negative value? I would agree if it was 0 or even a Unavailable, but some random negative amount feels so weird.

I might check some logs!

I know. I think it is a device related response which value it is “spitting” in a disconnect situation.
In the past I used Domoticz (Other smart home platform) and spotted the same behavior on this kind of sensors.

1 Like

Hello everyone,

Last evening, I encountered the issue again. Curiously, I’ve noticed that at exactly 20:00 and again at 04:00 each day, my energy readings exhibit an odd behavior: the system seems to skip the 5-minute interval. During these specific times, I sometimes observe the negative energy values.

Here are a couple of screenshots showing the anomaly:


To address this, I’ve written a template sensor in Home Assistant, intending to eliminate these negative values. However, I’m still getting negative readings, albeit different ones. I’m wondering if there might be an error in my template. Here’s the code I’m using:

- name: "Adjusted Energy Consumed Tariff 1"
  unit_of_measurement: 'kWh'
  state_class: 'total_increasing'
  device_class: 'energy'
  state: >
    {% set value = states('sensor.smart_gateways_smart_meter_energy_consumed_tariff_1') | float %}
    {% if value < 0 %}
      0
    {% else %}
      {{ value }}
    {% endif %}

- name: "Adjusted Energy Consumed Tariff 2"
  unit_of_measurement: 'kWh'
  state_class: 'total_increasing'
  device_class: 'energy'
  state: >
    {% set value = states('sensor.smart_gateways_smart_meter_energy_consumed_tariff_2') | float %}
    {% if value < 0 %}
      0
    {% else %}
      {{ value }}
    {% endif %}

I’m keen to hear any insights or suggestions you might have. Could this be a configuration issue, or is it something more inherent to the system’s data handling at these specific times?

Thank you in advance for your help!