#How to perform an action when some condition DID NOT happen in the last XX minutes.

1 messages · Page 1 of 1 (latest)

crystal coyote
#

I have an automation that notifies on my home speakers that the laundry is done.
I want to add a reminder, so if after 20 minutes the washing machine's door hasn't been open, it notifies me again. (Important, waiting 20 minutes and checking if the door is open is not correct. It needs to show only if the door never been been open in the last 20 minutes)

I don't see an easy way yo achieve that

rugged kindle
#

My idea would be something like this:

actions:
  - wait_for_trigger:
      - trigger: state
        entity_id:
          - binary_sensor.door_washingmachine
        to: "on"
    timeout:
      hours: 0
      minutes: 20
      seconds: 0
      milliseconds: 0
    continue_on_timeout: true
  - if:
      - condition: state
        entity_id: binary_sensor.door_washingmachine
        state: "on"
    then:
      - stop: Door has been opened
    else:
      - action: notify.notify
        metadata: {}
        data:
          message: Panic
#

If the door is opened, nothing happens - if the door has not been opened for 20 minutes it times out and fires the notification.

#

Would not survive a restart of HA during the waiting period though.

granite hawk
#

you can just use a helper too

crystal coyote
#

I think I don't understand the wait_for_trigger thing, but I think I get it now.
That action makes any action that comes after it stay on hold until the trigger fires OR the timeout happens, whichever comes first. And then the action that comes after can] check if the state is open or closed to know if it fired because a timeout or because the state became "open"

#

correct?

rugged kindle
#

Yes.

crystal coyote
#

done. In ~20 minutes I'll know if it works!

bleak ingot
# crystal coyote I have an automation that notifies on my home speakers that the laundry is done....

Another option is to create a binary sensor that shows if you have wet laundry in the washer. Then you can easily automate notifications from that.

template:
  - triggers:
      - trigger: state
        entity_id: binary_sensor.door_washingmachine
        to: "on"
        id: "off"
      - trigger: state
        entity_id: sensor.state_washingmachine
        to: "Finished"
        not_from: unavailable
        id: "on"
    binary_sensor:
      - name: "Wet Laundry in Washer"
        state: "{{ trigger.id }}"
        device_class: problem
uneven lagoon
#

I think I'd use a timer helper for this. When the cycle finishes, start the timer. When the door is opened, cancel the timer. When the timer finishes (trigger on the timer.finished event so you only trigger when it finishes, not when it's cancelled), you can send a notification then restart the timer. The timer helper can be set up to restore its state when home assistant is restarted, too.