How to automate on historic sensor data?

i’d like to automate things triggered not only by the current state, but the historic state of a sensor.
use-cases are:

  1. do something, when i was home for at least 2 hours today
  2. turn off the burner at night, but not if the gas meter has increased within the last 30 minutes (don’t kill the pump)
  3. water plants unless it rained today for at least 1 hour

how is this possible in a generic way? (the second example may be addressed by looking at the updated_at atribute.)

Check out ‘for x time’ in a condition.

thanks @Emphyrio, but i think this only applies to the last state update.
i’d like to sum up all intervals, where state matches a condition within a (past) time interval.

Does this help? https://www.home-assistant.io/integrations/history_stats/

1 Like

this looks promising. thanks, i would not have expected to find this feature implemented as a sensor :upside_down_face:

The utility section of the integrations page has some real treasures :slight_smile: https://www.home-assistant.io/integrations/#utility

the stats already have my attention, but the bayes is really exiting…