How to eliminate bad measurements?

Hi,

I’ve got an Hichi IR sensor at my power meter. This delivers bad data every now and then. Sometimes it knows it’s wrong and delivers 999999. sometimes it doesn’t realize a single digit was flipped.

Step by step I eliminated the errors by adding some IFs:

        state: >
          {% set new = states('sensor.tasmota_emh_e_in') | float(999999) %}
          {% set old = this.state | float(0) %}
        
          {% if new == 999999 or new > 10000 %}
            {{ old }}
          {% else %}
            {% if new < old %}
              {{ old }}
            {% else %}
              {% if new > old + 2000 %}
                {{ old }}
              {% else %}
                {{ new }}
              {% endif %}
            {% endif %}
          {% endif %}

Now I deleted the bad measurements from the STATE table using the SQLLite app. But they do not disappear from graphs which makes graphs unreadable when there is a 2MW spike or something like that.
I tried fiddling with the statistics table but could not find any wrong data.

any idea how to eliminate bad data from graphs?

thanks

PS: shouldn’t total_increasing sensors drop data that’s below the last data point?

You need to delete them from the statistics table too. You can do this in Settings → Developer Tools → Statistics. Click the ramp icon next to your entity and navigate to the time of the erroneous measurement. Or click the find outliers button.

Found Dev Tools/statistics and my entity.
but I cannot find any ramp icon or repair buttons.
“erweiterter” mode is enabled.