Sort out outliers from sensor

Hi!

I use a tasmota-based infrared read head to get data from an energy meter. To use this data for the energy dashboard, I created a template sensor like this:

state:

{% if float(states('sensor.tasmota_sml_total_kwh'), default=0) > 10 %}
  {{ float(states('sensor.tasmota_sml_total_kwh')) | round(4) }}
{% else %}
  {{ states('sensor.sml_consumption_total') }}
{% endif %}

availability:

{{ has_value('sensor.tasmota_sml_total_kwh') }}

Unfortunately, sometimes the read head delivers incorrect data (eg. too small, but not necessarily zero) or no data at all.

How can I filter the data in a smart way and remove outliers so that the energy statistics are correct?

Thanks a lot and have a great weekend! :slight_smile:

Thorsten

Hello Thorsten,

Add to your availability template to make sure the return not only has a value, but the value is > whatever number you think is not valid.

Well. It’s not just values below 10 or near zero. There are also not plausible values as a value that is much too high or a value that is lower than before (electricity meter only runs forward) but not near zero.