#Repeat Automation - WHILE or UNTIL both give one extra notification

1 messages · Page 1 of 1 (latest)

indigo sorrel
#

Hello,
I am trying to trigger a notification when my window has been left open every X minutes until it is closed. Unfortunately both WHILE and UNTIL repeat statements give me an "extra" message even after it has been closed (as it appears to be documented so this is probably correct behavior). But how can I improve my automations.yaml entry to mitigate this?

The extra notification erodes user trust in the message. The user cannot know if the window has been closed yet (the message is an extra) or should ignore it (leading to bad user habits). Someone has asked this exact question before but didn't really receive an answer that I know how to make use of.

Thanks in advance.

  description: ''
  trigger:
  - platform: state
    entity_id:
    - binary_sensor.bathroom_window_opening
    to: 'on'
    for: 00:05:00
  condition:
  - condition: numeric_state
    entity_id:
    - weather.home
    attribute: temperature
    below: 5
  action:
  - service: notify.all_devices
    data:
      message: Close the Bathroom Window (t > 5m, T <= 4°C)
  - repeat:
      until:
        - condition: state
          entity_id: binary_sensor.bathroom_window_opening
          state: 'off'
      sequence:
        - delay: '00:05:00'
        - service: notify.all_devices
          data:
            message: The window is still open! Close the Bathroom Window! (t > 5m, T <= 4°C)
  mode: single
  id: redacted ```
static marsh
#

It's just due to the way you've written it

#

Add a condition in the sequence to decide whether to send the notification just before you do it

raw pagoda
#

Or flip the delay and the notification which would even be more consistent with what you wrote as the first message will be sent 10 minutes after opening the window

static marsh
#

Yes, or that 🙂