.113/.114 Automation Rule with Timers Broken

Frist, if this is a repeat I apologize up front… Been super busy and finally had a change to get around to this.

Just had the chance to look into a broken automation rule but still not understanding how to resolve. Use to work perfectly, but after .113 update automation rule has been broken. Any help would be appreciated.

In a nut shell:

  • Rule is set to check if the garage door is left opened when everyone has left the house. If the garage is left opened it will send a reminder notification every 10 minutes until the garage door is closed.
  • Have discovered, when coming home and opening the garage door before HA knows we are home, it will send a notification. Then HA recognizes we are home but the timer continues to repeat sending notification every 10 minutes until the garage door is closed.

configuration.yaml

Copy to clipboard

# Timers
timer:
  garage_door:
    duration: '00:10:00'
    name: 'Garage Door'

automation.yaml

Copy to clipboard

 id: '1588618949530'
  alias: Garage Door Left Opened (Leaving House)
  description: ''
  trigger:
  - entity_id: group.track_all_persons
    from: home
    platform: state
    to: not_home
  - event_data:
      entity_data: timer.garage_door
    event_type: timer.finished
    platform: event
  condition:
  - condition: state
    entity_id: binary_sensor.visonic_mct_340_e_xxxxxxxxx_1_1280
    state: 'on'
  action:
  - data:
      data:
        priority: high
        ttl: 0
      message: Garage door still opened. Turn around and close.
    service: notify.mobile_app_sm_n950u
  - data:
      data:
        priority: high
        ttl: 0
      message: Garage door still opened. Turn around and close.
    service: notify.mobile_app_sm_g973u
  - data: {}
    entity_id: timer.garage_door
    service: timer.start

Once that automation is started, you are creating a loop that can be stopped only by the one condition you have in place : the garage door is closed.

From my perspective, the automation is functioning perfectly.
What is it that you want to happen that isn’t ?

Once our status shows home the loop should stop, not just when the door is closed.

Then you will need to add that in as a second condition.

How does your group.track_all_persons behave, does everyone have to be home for the state to change back to home ?

Not at all. The group works where if just one of us arrive/is home, it marks as home.

Then you need to add a condition as follows

- condition: state
    entity_id: group.track_all_persons
    state: 'not_home'

Thank for the quick response. Make sense on the condition. Have implemented and will test this weekend.

You also have the option of using the new repeat functionality introduced in 0.113.

The following sends notifications, pauses for 10 minutes, then repeats but only if the binary_sensor is on.

 id: '1588618949530'
  alias: Garage Door Left Opened (Leaving House)
  description: ''
  trigger:
    - entity_id: group.track_all_persons
      from: home
      platform: state
      to: not_home
  condition:
    - condition: state
      entity_id: binary_sensor.visonic_mct_340_e_xxxxxxxxx_1_1280
      state: 'on'
  action:
    repeat:
      while:
        - condition: state
          entity_id: binary_sensor.visonic_mct_340_e_xxxxxxxxx_1_1280
          state: 'on'
      sequence:
        - data:
            data:
              priority: high
              ttl: 0
            message: Garage door still opened. Turn around and close.
          service: notify.mobile_app_sm_n950u
        - data:
            data:
              priority: high
              ttl: 0
            message: Garage door still opened. Turn around and close.
          service: notify.mobile_app_sm_g973u
        - delay:
            minutes: 10

EDIT
You can probably remove the initial condition and it would still work correctly because the condition within the repeat will ensure that notifications are sent only if the binary_sensor is on.

hey, great example. helping me with something like this.
Was wonderig if I couldn’t leave out the main condition completely? Since it wont do anything is the condition is off in the repeat block either?

EDIT
Haha, no such thing as coincidence :wink: thanks for the edit! will give it a go!

Ha! Just after I finished amending my post, I saw yours. Yes, I do believe the initial condition can be removed.

 id: '1588618949530'
  alias: Garage Door Left Opened (Leaving House)
  description: ''
  trigger:
  - entity_id: group.track_all_persons
    from: home
    platform: state
    to: not_home
  action:
    repeat:
      while:
        - condition: state
          entity_id: binary_sensor.visonic_mct_340_e_xxxxxxxxx_1_1280
          state: 'on'
      sequence:
        - data:
            data:
              priority: high
              ttl: 0
            message: Garage door still opened. Turn around and close.
          service: notify.mobile_app_sm_n950u
        - data:
            data:
              priority: high
              ttl: 0
            message: Garage door still opened. Turn around and close.
          service: notify.mobile_app_sm_g973u
        - delay:
            minutes: 10

EDIT
I think what would not work correctly is if it used repeat - until. It would send the notifications once and then check the condition. repeat - while checks the condition first and then determines if the sequence should be executed.

1 Like

Taras, since you’re online, please let me ask you to have a look at an earlier post of mine, where I seek to optimize an automation… no hurry, it works, but I have a feeling this can be optimized… thanks if you would.