Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95533

What is the best way to eliminate 'spikes' in temperature/humidity sensors' readings in real time?

$
0
0

@AhmadK wrote:

Hi All,

I use some DIGOO R8H temperature&humidity sensors in my setup and they work very well.
The readings come to HA via RFLink integration.
I noticed on the sensors’ history graph that once in a while, totally randomly, both temperature and humidity readings (they come in one message afaik) get far away from the previous values (namely - the temperature jumps some 10 degrees up and the humidity plunges some 20% down or vice versa). Apparently the next reading is back to normal so the graph looks absolutely fine apart from that momentary glimpse.

I know there are integrations like Filter or Threshold, but they all need some input readings before they start producing output. My physical sensors send their readings every 50 seconds and sometimes I miss a new reading and need to wait for the next one for another 50 seconds (maybe because of poor antenna(s), long distance, interference or a bit of all that - I tried to improve that, but there’s still not ideal). That’s why I just don’t want to use any of these integrations as they will make my slowly-updated sensors even slower and for some applications 2 minutes lag is a bit too much…

So far I use this template sensor to stop that spike propagating:

- platform: template
  sensors:
    rflink_filtered_outdoors_digoo_temperature:
      device_class: temperature
      unit_of_measurement: '°C'
      entity_id:
        - sensor.outdoors_digoo_temperature
      value_template: >
        {% set unknown = 'unknown' %}
        {% set value = states('sensor.outdoors_digoo_temperature') %}
        {% set prev_value = states('sensor.rflink_filtered_outdoors_digoo_temperature') %}
        {% if prev_value == unknown %}
          {{ value }}
        {% else %}
          {% set def_deviation = 5.0 %}
          {% set cur_deviation = states('input_number.thb_sensor_temperature_deviation') %}
          {% set deviation = def_deviation if cur_deviation == unknown else float(cur_deviation) %}
          {{ prev_value if value == unknown or (value | float - prev_value | float)|abs > deviation else value }}
        {% endif %}

It works, but only if the deviation is selected right - if it’s too small (imagine sharp rise/fall in temperature), the template is stuck until the readings get pretty close to the stored value (I witnessed that once).

I wonder if there is a better solution to this issue at all?

Posts: 4

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95533

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>