#Energy Spikes in Energy Readings

1 messages · Page 1 of 1 (latest)

dim gazelle
#

I am sure it has been said 100x about energy spikes in the reading.. This is not your typical the sensor goes to unavailable then back again so the reading keeps jumping by a bunch. I'm talking about a sensor that jumps by 30 Billion kWh and then back.. I am using the Hubitat integration and it has to be the cause of this to be honest as these reading are not on the sensor on the Hubitat side but are on the sensor on the Home Assistant side. I cannot tell what is doing it and it does not seem like it will be fixed at any time so I am trying to use a filter but these don't seem to work either

    filters:
      - filter: outlier
        window_size: 10
        radius: 4.0

that is what I am using and the spike still happened. Is there a bug in the filter for outlier or am i just not understanding how this filter should work?

minor raft
#

Can you share more context? History graphs and such?

#

What/where is that filters from? Is that a template sensor?

dim gazelle
#

this is what I posted on the Community Form

#

I got the typical use an availability template (which is not the issue)

#

then use a filter option which still seems to ignore the spikes

minor raft
#

Filter says it uses the median of previous states, not average.

#

So that should still work if you had one bad state in the history?

dim gazelle
#

correct

#

so it should take my last 10 reads and median it

#

then it cannot be off by more than +/- 4

#

if it is it will just use the median value

#

my last 10 readings were 18kWh for all of them

#

I have just started to use a range filter

      - filter: range
        lower_bound: 0
        upper_bound: 4

To see if that combined with outlier if that fixes it

#

because the value should never jump by more than 1 or 2..

minor raft
#

As a quick aside I want to make sure you understand that using a filter creates a new entity, it does not modify your existing entity.

dim gazelle
#

correct

minor raft
dim gazelle
#

i feed my existing into the filter then the output of that into my utility meter

minor raft
#

What does graph of Patio Lanterns Energy - Filtered look like?

dim gazelle
#

oh crap sorry , ill get the filter one

#

crap sorry I don't have a screen grab o fit any more.. the filter spiked up to 300 million then the next read was like 10 million then a million then back to normal..

#

Sorry I cleaned up the spike form my historical data last night as it was throwing all my costs off

#
  • filter: range
    lower_bound: 0
    upper_bound: 4
#

maybe that is the better one to use..

#

so far it has not happened again...

#

this sensor for some reason does not have decimal points so it will jump by 1kWh at a time.. nothing else in my place should jump more then 2kWh between reading as that is a lot of power

minor raft
#
if new_state > upper_bound:
    upper_bound

Sounds like range might not do what you want

#

Actually range is not filtering on the increase, it's filtering on the absolute value of the entity?

dim gazelle
#

ohh

#

gotcha.. sorry i was thinking it was working on the differance

#

ahh crap

minor raft
#

I'd try stick with outlier, but if that doesn't work for some reason, I might just write my own triggered template sensor.

dim gazelle
#

okay yeah you are right i was not reading the filter right

#

Ill just create my own sensor that does the math, basically create my own filter

#

im just confused why the outlier did not work.. I dont see a long on it either that tells me what it did

minor raft
#

Well it sounds like you may be getting multiple incorrect values in a row?

#

Maybe need a bigger window

dim gazelle
#

I guess i could use

      - filter: range
        lower_bound: 0
        upper_bound: 100
#

as all these reset each month

#

so value must be between 0 and 100

minor raft
#

That's still going to report 100 if you get 100,000,000.

#

You won't like that

#

it clamps the value, not drops it

dim gazelle
#

ohh becuase it returns the upper bound

#

okay thanks,

#

Ill create my own filter 🙂

#

plus then it can be in the UI!!!

#

must be between this or that and if not retun none or return the value

#

Im assuming I would juut use a number template to do this?

minor raft
#

I'm not 100% sure how statistics will handle Unknown/none value.

#

I know it ignores Unavailable.

#

Hopefully it is the same for Unknown.

dim gazelle
#

ahh okay ill use that

#

thanks for the help!!

minor raft
#

You can't use Unavailable without an availability template, and that is yaml only

dim gazelle
#

i just do it in code

minor raft
#

IT's worth a try to see if Unknown works, but go whichever way you like

#

anyway cheers, good luck.

dim gazelle
#
{% set s = 'sensor.driveway_light_utility_meter' %}
{% set i = 'input_number.hydro_rates' %}

{% if states(s ~ '_mid_peak') in ['unknown','unavailable'] or
      states(s ~ '_off_peak') in ['unknown','unavailable'] or
      states(s ~ '_on_peak' ) in ['unknown','unavailable'] or
      states(i ~ '_mid_peak') in ['unknown','unavailable'] or
      states(i ~ '_off_peak') in ['unknown','unavailable'] or
      states(i ~ '_on_peak' ) in ['unknown','unavailable'] %}
  {{ None }}
{% else %}
  {% set mid_usage = states(s ~ '_mid_peak') | float(0) %}
  {% set off_usage = states(s ~ '_off_peak') | float(0) %}
  {% set on_usage  = states(s ~ '_on_peak' ) | float(0) %}
  {% set mid_rate = states(i ~ '_mid_peak') | float(0) %}
  {% set off_rate = states(i ~ '_off_peak') | float(0) %}
  {% set on_rate  = states(i ~ '_on_peak' ) | float(0) %}
  
  {{ (mid_usage * mid_rate) +
     (off_usage * off_rate) +
     (on_usage *  on_rate) 
  }}
{% endif %}
#

that's an example so I don't have to use an availability temple for all these sensors.. i just test for it first

#

is taht a bad idea or just another way to do it?