I’m monitorting the energy consumption of my heatpump. The heatpump sensors work via MQTT, unfortunately the graph shows outliers once in a while. Sometime an increate of 500.000kwh and sometime it goes to a very low value. So I checked the documention and found the outliers filter which should to the trick in this case. The outliers are actually filtered, however, I see some behavior which I don’t understand.

For example.
I created the following filter for the total energy consumption:

There are several decreases of the values while there weren’t any outliers in the original sensor at that moment. I’m trying to understand the outlier filters but I’m a bit stuck here. What am I missing?

Thanks for the quick reply, I’m trying to understand how it should work so I can also use it with different kind of sensors. What do you mean with “those are larger than your radius”?

In the documentation I see the following for the outlier filter:

distance = abs(state - median(previous_states))
if distance > radius:
median(previous_states)
else:
state

In my understanding the radius means the maximal increase for each step, but if I read your post I’m probably wrong , or does it means total of the total window size instead of each update?

The heathump has an increasing sensor starting at day one when the heatpump was installed. These 12.000kwh are over 3,5 years, so it should be accurate, it also matches with a youless energy meter in front of the heatpump.

This is a bit old thread, but google got me here while trying to solve my own problem with outlier-filter. Still don’t know what is wrong with mine, but i thought to say what i think is wrong here.

Window size of 10 makes this code check last 10 values, all of them should be smaller than the always increasing new value. Median selects the middle one of those values (average of middle two with even number of values), after sorting them. So, that value which is compared to the new one, should be 5.5 smaller than the new value.

Then there is the radius of 5.0. I don’t actually know how that filter even worked as well as it seems in the graphs, maybe some values are read multiple times and that median of last 10 values usually gets closer to the new value and passes that filter. Those dips in the graph might happen when there are exactly one update per kilowatt increased and filter failure chooses the median of last 10 as the new output.

So, smaller window or larger radius should help.

Ps. I think that whole outlier filter is stupid, because it uses old median value when new value fails. It would be way better to discard the value and make the sensor not available or what was it called here. There is most likely a way to do it, but most users find these default functions and just believe that this is a normal way to fix the problem.