What kind of filter do I need here?

Dear community,
I have a humidity sensor (based on an AM2303 sensordevice), where I would like to smooth out the readings. They currently look like this (blue graph), but I would like to have a somewhat more evened-out curve, like I’ve drawn in hand (red) below.

image

I’m guessing the approx 2% fluctuations during the day happen when our house A/C’s kicks in during day and removes some of the moisture. I would just like to see a more “normalized” set of data with said fluctuations flattened out, if possible.

For starters, I configured the example filter from the help page, where the filters section looks like this

    filters:
      - filter: outlier
        window_size: 20
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

I’ve tried changing the numbers over at random (as I honestly have little idea what I’m doing there), yet it does not seem to make any difference to the graph for the filter sensor. It pretty much looks the same as the one for the phys.sensor

I’m hoping somebody’s got a bit better grip on the filters than I and can recommend some things to try above.

One thing I noticed: Seems that the time_simple_moving_average does not work.
If I change the filter to this, I get an error when I check the configuration:
Invalid config for [sensor.filter]: not a valid value for dictionary value @ data['filters'][0]['filter']. Got 'time_simple_moving_average'. (See ?, line ?) - Is that to be expected or did I do a dumdum? :slight_smile: Never mind, I had overlooked the window_size needs to be in “hh:mm” format

Thanks!

1 Like

Where are you putting this?

It’s going into the configuration.yaml file, as shown on the filter help page: Filter - Home Assistant
The above is just the exerpt which defines the filter, not the whole thing.

Share your actual config.

Sure, yet it’s doubtful if that makes much difference. The filter just doesn’t do anything significant to the data, i.e. I was looking for some guidance to the filtertypes and numeric parameters, as the configuration is valid enough.

sensor:
  - platform: filter
    entity_id: sensor.mysweethygrometer_filtered
    name: "Humidity filtered"
    filters:
      - filter: outlier
        window_size: 20
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

Bump. Anyone’s got some actual filter experience here?

I just had a similar problem like you and I think I figured it out:
I think you just confused some things in the set up. When setting up the filter sensor, you would do it like that, assuming you have a humidity sensor called sensor.mysweethygrometer:

sensor:
  - platform: filter
    entity_id: sensor.mysweethygrometer
    name: "Humidity filtered"
    filters:
      - filter: outlier
        window_size: 20
        radius: 4.0
      - filter: lowpass
        time_constant: 10
        precision: 2

By doing so, HA will create an entity called Humidity Filtered. The corresponding id should be something like humidity_filtered. The entity ID you list in the config is the ID of the entity that should be filtered - NOT the ID of the newly created entity.

Hi Josh, thanks for sharing your insight. I’m going to give it another try and see if I can make it do something useful.