ESPHome has a new sensor filter, rh_correction, that recalculates relative humidity after you correct the temperature of the same sensor. It was written by damib and merged on 22 October 2026 after review by J. Nick Koston (bdraco) and Jesse Hills. The code went into the dev branch, one day after ESPHome 2026.10.0 came out, and the documentation sits in the branch for the next release, so it should arrive in ESPHome 2026.11.
Why an offset is not enough for humidity
A DHT or BME sensor often shares a case with an ESP board, a regulator and other parts that warm it up. The temperature then reads a few degrees high, and an offset filter fixes that. Humidity is harder. Relative humidity depends on how much water vapour the air can hold at the measured temperature, so a sensor that runs warm reports air that is drier than the room. The error grows and shrinks with conditions, and a fixed offset on the humidity value cannot follow it.
The new filter uses the Magnus formula to rescale the reading from the measured temperature to the corrected one. It assumes the amount of water vapour is the same inside and outside the enclosure.
Configuration
The filter goes on the humidity sensor and points to the temperature sensor that already carries the offset:
sensor:
- platform: dht
pin: GPIOXX
temperature:
id: t_sensor
name: Temperature
filters:
- offset: -6
humidity:
name: Humidity
filters:
- rh_correction:
sensor_id: t_sensor
temperature_offset: -6
temperature_offset must match the offset on the temperature sensor and can be a template. use_fahrenheit: true tells the filter that the temperature sensor reports °F. The documentation warns about one easy mistake: if sensor_id points to a raw, uncorrected temperature, the humidity comes out wrong and nothing warns you.
Edge cases
The result is clamped to 0-100%. Until the temperature sensor publishes its first value, or while the measured or corrected temperature is outside -40 to 50 °C (-40 to 122 °F), the humidity passes through uncorrected and a warning is logged once. If the temperature sensor publishes NaN or the offset evaluates to NaN, the update is dropped with a one-time warning and the last corrected value stays.
The pull request lists tests on ESP32 with Arduino and ESP-IDF, ESP8266 and BK72xx. Anyone who has built a humidity sensor into a small box with a hot ESP board, or into a wall plate next to a power supply, can use this filter instead of their own calculation once the release is out.