A temperature sensor polled every 10 seconds sends thousands of nearly identical values a day, and every one ends up in Home Assistant's database. Filters let the device sample often and publish only what matters.
A good default for slow-changing values
sensor:
- platform: bme280_i2c
address: 0x76
update_interval: 10s
temperature:
name: "Temperature"
filters:
- sliding_window_moving_average:
window_size: 6
send_every: 6
- delta: 0.2
- heartbeat: 5min
What happens, in order:
sliding_window_moving_average: averages the last 6 readings and emits one value per 6 readings (once a minute here), smoothing out noise.delta: 0.2: passes the average only if it differs from the last published value by at least 0.2.heartbeat: 5min: re-sends the current value every 5 minutes, so graphs and "unavailable" detection keep working when nothing changes.
Order matters: filters run top to bottom. Putting delta before the average would filter raw noise instead of the smoothed value.
Other useful filters
| Filter | Use it when |
|---|---|
throttle: 60s |
a sensor can fire very fast (pulse counters, analog inputs) and you want at most one value per period |
filter_out: 85.0 |
a sensor reports a known bogus value (DS18B20 sensors report 85 °C when a reading isn't ready) |
exponential_moving_average |
you want a fast update interval with smoothed output |
clamp |
physically impossible values should be limited to a range |
timeout |
you want a fallback value when readings stop arriving |
Tips
- Set
update_intervalon the sensor platform, then shape the output with filters. - Pick
deltain the sensor's real resolution: 0.1 °C on a sensor accurate to ±0.5 °C only records noise. - For energy or counter sensors, don't average away real changes. Use
throttleordeltainstead.