Close Windows if mobile action was not pressed

Dear Community,

I am looking into automation of the windows if all users leave home.
The idea is:

  1. Users leave home (works)
  2. Notification with text “windows will close in 5 minues” and action “prevent windows from clsoing” (works)
  3. if mobile event was fired → prevent windows from closing

I am struggling with the last step.
If it is pressed I can run something like open windows but how can I do it so the windows will close after 5 minutes only if the notification action was not pressed?

Thank you and best wishes,
TH

1 Like

I would probably use a boolean.
This automation sets a boolean to off first, then sends the notification.
Delay 5 minutes.
The notification command sets the boolean to on.
Add a condition after the delay to check the boolean
Close window

but how do I set it in the event fire?

this is my wait for trigger code:

wait_for_trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: DoNotClose_Windows
timeout:
  hours: 0
  minutes: 5
  seconds: 0
  milliseconds: 0
continue_on_timeout: false

after that I can do an action but the problem is if I set to continue on timeout it will always do the next action.
I dont understand how I can attach an action only to the wait for trigger /fire event and continue without doing thhat attached action

Post the full automation instead.
But you need to use a boolean.

that would be this one:

alias: Question_CloseWindows
description: ""
trigger:
  - platform: state
    entity_id:
      - group.groupfamily
    to: not_home
    for:
      hours: 0
      minutes: 0
      seconds: 3
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: cover.velux_window_roof_window_2
        state: open
      - condition: state
        entity_id: cover.velux_window_roof_window_4
        state: open
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.bwindows_open
  - service: notify.notify
    data:
      message: Windos will close in 5 Minutes.
      data:
        actions:
          - action: DoNotClose_Windows
            title: Do not close Windows
      title: Windows are still open
  - wait_for_trigger:
      - platform: event
        event_type: mobile_app_notification_action
        event_data:
          action: DoNotClose_Windows
    timeout:
      hours: 0
      minutes: 5
      seconds: 0
      milliseconds: 0
    continue_on_timeout: false
  - parallel:
      - if:
          - condition: and
            conditions:
              - condition: state
                entity_id: cover.velux_window_roof_window_2
                state: closed
              - condition: state
                entity_id: cover.velux_window_roof_window_4
                state: closed
        then:
          - service: notify.notify
            data:
              title: Windows Closed
              message: All Windows were Closed
        else:
          - service: notify.notify
            data:
              title: Windows Closed
              message: All Windows were Closed
          - service: cover.open_cover
            data: {}
            target:
              entity_id:
                - cover.velux_window_roof_window_2
                - cover.velux_window_roof_window_4
mode: single

I would do it like this.
Two automations, one that triggers when family leaves and one on the mobile event.

alias: Question_CloseWindows
description: ""
trigger:
  - platform: state
    entity_id:
      - group.groupfamily
    to: not_home
    for:
      hours: 0
      minutes: 0
      seconds: 3
condition:
  - condition: or
    conditions:
      - condition: state
        entity_id: cover.velux_window_roof_window_2
        state: open
      - condition: state
        entity_id: cover.velux_window_roof_window_4
        state: open
      - condition: state
        entity_id: cover.velux_window_roof_window
        state: open
      - condition: state
        entity_id: cover.velux_window_roof_window_3
        state: open
      - condition: state
        entity_id: cover.velux_window_roof_window_6
        state: open
      - condition: state
        entity_id: cover.velux_window_roof_window_5
        state: open
action:
  - service: input_boolean.turn_on
    data: {}
    target:
      entity_id: input_boolean.bwindows_open
  - service: notify.notify
    data:
      message: Windos will close in 5 Minutes.
      data:
        actions:
          - action: DoNotClose_Windows
            title: Do not close Windows
      title: Windows are still open
  - delay: "00:05:00"
  - condition: state
    entity_id: input_boolean.bwindows_open
    state: "on"
  - parallel:
      - if:
          - condition: and
            conditions:
              - condition: state
                entity_id: cover.velux_window_roof_window_2
                state: closed
              - condition: state
                entity_id: cover.velux_window_roof_window_4
                state: closed
              - condition: state
                entity_id: cover.velux_window_roof_window
                state: closed
              - condition: state
                entity_id: cover.velux_window_roof_window_3
                state: closed
              - condition: state
                entity_id: cover.velux_window_roof_window_6
                state: closed
              - condition: state
                entity_id: cover.velux_window_roof_window_5
                state: closed
        then:
          - service: notify.notify
            data:
              title: Windows Closed
              message: All Windows were Closed
        else:
          - service: notify.notify
            data:
              title: Windows Closed
              message: All Windows were Closed
          - service: cover.open_cover
            data: {}
            target:
              entity_id:
                - cover.velux_window_roof_window_2
                - cover.velux_window_roof_window_4
                - cover.velux_window_roof_window
                - cover.velux_window_roof_window_3
                - cover.velux_window_roof_window_5
                - cover.velux_window_roof_window_6
mode: single
alias: Mobile_Event_CloseWindows
description: ""
trigger:
  - platform: event
    event_type: mobile_app_notification_action
    event_data:
      action: DoNotClose_Windows
condition: []
action:
  - service: input_boolean.turn_off
    data: {}
    target:
      entity_id: input_boolean.bwindows_open
mode: single
1 Like

This worked perfect!

Thank you so much never thought about doing it that way.
Just gained a huge amount of flexibility with this approach

thank you!