Add 'Moving Median' as a Filter type

Some sensors like temperature and humidity have the odd spike which we’d like to ignore.

A moving median is a simple and effective filter to remove these outliers (and in my view an under utilised smoothing approach).

A moving median of 3 will filter out a single spike and a moving median of 5 will filter out a double spike.

Esphome has this as an option.

It would be nice to have this available in Home Assistant too. Actually it would be nice to just be able to apply filters in a similar way to ESPhome (have filter as option for all sensors), but I guess that’s another story.

# Example Esphome configuration entry
- platform: wifi_signal
  # ...
  filters:
    - median:
        window_size: 7
        send_every: 4
        send_first_at: 3

Related Post: