I want to trigger automations when something (humidity, pm2.5s, etc) rapidly increases, so I can turn on a fan or air purifier. I also want to detect when the rate has decreased enough that the fan/purifier is having a negligible effect, so I can turn them off.
How can I setup detecting a rate of change?
For example, I would like to detect the massive spike in pm2.5s in my kitchen and have the purifier turn on. Then after an equally massive spike downward, when it starts to trail off and the purifier has very little effect, detect the rate of change has slowed and turn it off because purifiers cost energy and are loud.