I'm wanting to calculate the rate of change of a variable (humidity in a bathroom), and use this as one of the conditions for triggering an action group (e.g. turn on fan when humidity has increased by > 10 in the last 5 minutes)..
what's the most appropriate way to do this calculation? e.g. retrieve the old value from postgreSQL; or update a variable based on a schedule?