Template sensor measurements no more than every x seconds

Hi, I’m looking for some tips how to make template sensor measurements less frequent. I have Xiaomi Air Purifier which also has temperature and humidity sensors and I would like to use them to monitor those values during the day.

Unfortunately, due to the low sensitivity of these sensors, the measurement can often change between two values:

Is there any way to limit the frequency of the sensor check?

Current configuration for this sensor is

sensor:
  - platform: template
    sensors:
      humistat_bedroom:
        friendly_name: "Bedroom humidity"
        unit_of_measurement: '%'
        value_template: "{{ states.fan.xiaomi_air_purifier_2.attributes.humidity | int }}"

Bump

After almost a year I found my old thread :smiley: still looking for solution for the same issue, filter sensor or mean value is not working very well in that case

Filter sensor is really the only option without compromising your data.

You could attempt to check the last updated time and only update the humidity if the last updated humidity was over x seconds ago.

Also, have you looked at your device settings? There could be a setting that reduces the noise in your output from the device.