Like many here, I’m still trying to understand home assistant and I’m learning on a daily basis. I’ve had an Aqara humidity sensor for sometime and I’ve used a static humidity value to trigger a bathroom extractor fan. However, the seasons and weather changes so does ambient humidity and therefore a fixed value isn’t working so well. I wonder if it’s possible to perhaps store a reading from an hour ago which can be compared with a % increase (current humidity) And have a trigger in that way? Is this possible, if it is what would be the best approach please?. Or is there an alternative approach to this?
For automations like this, most people either use a second sensor outside the bathroom to establish a baseline for comparison or they use one of the statistical sensors to determine when the humidity is rising quickly.
There are a number of existing blueprints, like this one that you can use for you situation.
If you just want a sensor that tells you the value of your humidity sensor an hour ago, you can use a SQL sensor to retrieve that data from your existing database. The query would be as follows (make sure to use your own sensor entity id):
SELECT state from states
where entity_id = 'sensor.YOUR_SENSOR'
and last_updated_ts <= strftime('%s', 'now','-1 hours')
order by last_updated_ts DESC LIMIT 1;