How to trigger action for sensor reading under/over threshold "for a while"?

I have Home Assistant set up, configured and working fine but now I want to turn off a switch if a certain sensor reading has been constantly under a threshold for a certain time. If it goes back up above the threshold within that time the action is not supposed to happen until it goes under again and stays there for the set time. Kind of a poor man’s low-pass filter. I just started getting into Home Assistant and assumed this would be a pretty common scenario but even after reading about scripting and automation I still haven’t found anything that would allow me to do this. Can any of the more experienced users here shed some light on it? Thanks.

Chris

You may want to look at the “above/below…for” in sensor trigger, example
Sounds like that’s what you are looking for.

Here’s an example:

- id: memory_monitor_alert
  alias: 'Memory Monitor Alert'
  trigger:
    entity_id: sensor.memory_use_percent
    platform: numeric_state
    above: 90
    for:
      minutes: 5
  action:
    service: notify.all_ios_devices
    data:
      message: 90% of memory resources used.
      data:
        push:
          sound: "Warning.wav"

Thanks, guys, also for not lecturing this n00b on “RTFM’ing better”! :wink:

…which I’ll have to do, obviously.

1 Like