#Repeat every 5 min until door closed. Once door closed break loop & execute next actions immediately

1 messages · Page 1 of 1 (latest)

rose sandal
#

Can someone please help me here.

Issues I have here is, in between the loop delay, if I close the door, it does nothing and wait until delay expires. Per my understanding until should break the loop immediately if state changes

  - repeat:
      sequence:
        # Define variable value with current open time in minutes
        - variables:
            minutes_open: "{{ ((as_timestamp(now()) - start_time) // 60 ) | int }}"
        - device_id: !input notify_device
          domain: mobile_app
          type: notify
          title: !input notification_title
          message: "Reminder: The {{ binary_sensor_friendly_name }} has been open for {{ minutes_open }} minutes. Please check."
        - delay:
            minutes: 5  # Repeat every 5 minutes
      until:
        - condition: state
          entity_id: !input door_sensor
          state: "off"
twilit sand
#

That's not how until works, it is only evaluated each time the sequence finishes

#

instead of a delay you need to use a "Wait for a trigger", w/ 5 minute timeout.

#

wait for a trigger of door changing to closed

#

then it will abandon the remainder of the delay as soon as the door closes

rose sandal
#

ok then please tell me if this logic is ok

trigger on 'on'
action:
  do some steps of notification on door open
  wait_for_trigger  # Initial wait
    state is 'off'
    state is on for 5 min
  
  repeat
    do other steps of notification while door remain open
    wait_for trigger  # repeat until state change
      state is on for  every 5 min

  do different steps of notification while door closed
      
rare cosmos