Energy Integration Spike

I just set up the new Energy Dashboard using IotAWatt an the Integration sensor. I noticed a huge spike yesterday that appears false, so I’m trying to figure out what caused and how to prevent.

Energy Dashboard showing 40.38kwh usage at 7am (from sensor.import_wh_calculated)

When I look at the history for sensor.import_wh_calculated around the same time, I see a 3kwh drop, then it flatlines (which is expected when solar production kicks in)

Where does this usage spike come from?

sensor.import_wh_calculated is defined like this:

platform: integration
source: sensor.import
name: import_wh_calculated
unit_prefix: k
round: 2

sensor.import (from IotAWatt) doesnt even show a spike at that time

1 Like

I just found this GitHub issue about a similar problem, and am wondering if this is because of a HASS restart? I did restart today, however, and don’t see a similar spike… but import was 0 at the time.

For a template sensor, you can check availability of the sensor… but not sure how to do this with the Integration. Does that need a code update to be used by the Energy dashboard?

Try to check for the availability of your energy sensors.

This is an example code:

        value_template: "{{ ( states('sensor.total_yield')|float 
        + states('sensor.total_yield_2')|float )  | round(2)
        availability_template: "{{ states('sensor.total_yield') not in ['unavailable', 'unknown', 'Unknown', 'none']
        and states('sensor.total_yield_2') not in ['unavailable', 'unknown', 'Unknown', 'none'] }}"
        device_class: 'energy'
        unit_of_measurement: 'kWh'

hope it helps

I have the same issue, it does not appear to be related to restarts or sensor values.

I have several examples of this and the underlying energy is not showing any tract of this additional energy.

My energy provider also provides 30min power usage on their app and it also does NOT show any significant consumption around this time?

Screen Shot 2021-10-12 at 9.10.28 am

1 Like

Add another to the list … Almost everyday it gets ruined by a spike.

And it doesn’t show up on the inverter’s monitoring site:

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:

  - 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:

  - 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 }}"

I’m the IoTaWatt developer. Suffice to say that the current integration is not under my control.

There is a new release of IoTaWatt firmware coming out soon that will track solar import and export in the IoTaWatt and make integration simple. It will require using a HACS integration.

The current maintainer of the official version has a pre-release and may modify the current release version to work better. He has reported a similar problems with the current version to me.

I am testing with the original 0.0.8 HACS version. It seems to do all that is needed. I’ll post back here as the new version gets closer to release in a week or two.