How to create automation trigger based on historical states of sensors/data/etc

I would like to create an automation where I can take previous values of a sensor, and based on a calculation I trigger an automation.

For example:
If no motion in the last hour, trigger
if the moving average of temperature over the last three hours is below 65F/18C, trigger
If the barometric pressure is dropping over the last 2 hours at a rate of , close shutters

How would I go about it?

Thank you.

(My lingo/understand is at novice level so forgive me if I conflate them.)

1 Like