#What's wrong with this automation?

1 messages · Page 1 of 1 (latest)

austere iris
#
alias: Door Open
description: Notify target if door is open.
triggers:
  - alias: When Door Sensor changes from Closed to Open
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
conditions: []
actions:
  - action: notify.notify_to_all_devices
    metadata: {}
    data:
      title: Door Open
      message: Someone at the door
      data:
        car_ui: true
        channel: DoorOpen
        push:
          sound: Doorbell.caf
  - repeat:
      while:
        - condition: state
          entity_id: binary_sensor.door_sensor_contact
          state: "on"
          for:
            hours: 0
            minutes: 10
            seconds: 0
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0
        - action: notify.notify_to_all_devices
          metadata: {}
          data:
            title: Door Open
            message: WARNING!! Door open
            data:
              car_ui: true
              channel: DoorOpenAlert
              push:
                sound: Alert_SpartanConnecting_Haptic.caf
mode: single

The goal is to notify on door open and if it is left open for more then 10 mins then notify again forever or until closed with 10 second delay between each notification. This does work for notifying when door opens but I never get notified if its left open.

#

I have another automation for another door which only notifies after 5 mins if its left open, no notify on open on this one,

alias: Door Open
description: Notify target if door is open.
triggers:
  - alias: When Door Sensor changes from Closed to Open
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 5
      seconds: 0
conditions: []
actions:
  - repeat:
      while:
        - condition: state
          entity_id: binary_sensor.door_sensor_contact
          state: "on"
      sequence:
        - delay:
            hours: 0
            minutes: 0
            seconds: 10
            milliseconds: 0
        - action: notify.notify_to_all_devices
          metadata: {}
          data:
            title: Door Open
            message: WARNING!! door open
            data:
              car_ui: true
              channel: DoorOpenAlert
              push:
                sound: Alert_SpartanConnecting_Haptic.caf
mode: single

this works as expected though.

#

So what's wrong with the first one?

#

I have redacted the sensor name and all BTW.

wintry dawn
#
alias: Door Open
description: Notify target if door is open.
triggers:
  - alias: When Door Sensor changes from Closed to Open
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
    id: opened
  - alias: When Door Sensor changes from Closed to Open
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 10
      seconds: 0
    id: open_10_min
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - opened
        sequence:
          - action: notify.notify_to_all_devices
            metadata: {}
            data:
              title: Door Open
              message: Someone at the door
              data:
                car_ui: true
                channel: DoorOpen
                push:
                  sound: Doorbell.caf
      - conditions:
          - condition: trigger
            id:
              - open_10_min
        sequence:
          - action: notify.notify_to_all_devices
            metadata: {}
            data:
              title: Door Open
              message: WARNING!! Door open
              data:
                car_ui: true
                channel: DoorOpenAlert
                push:
                  sound: Alert_SpartanConnecting_Haptic.caf
mode: single
#

something like this should work

#

this is a better more efficient setup than a long running looping automation

languid hemlock
#

That won't repeat the notification every 10 seconds

languid hemlock
#

you can use the example from Micheal, but then put the repeat loop in the sequence for the 10 minute trigger

austere iris
#

@wintry dawn Hey sorry for the late response got busy with stuff. So I tried this according to what you suggested,

alias: Door Open
description: Notify target if door is open.
triggers:
  - alias: When Door Sensor changes from Closed to Open
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
    id: door_open
  - alias: When Door left opened for 10 secs
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 10
    id: door_open_10min
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - door_open
        sequence:
          - action: notify.mobile_app_foo
            metadata: {}
            data:
              title: Door Open
              message: Someone at the door
              data:
                car_ui: true
                channel: DoorOpen
                push:
                  sound: Doorbell.caf
      - conditions:
          - condition: trigger
            id:
              - door_open_10min
        sequence:
          - delay:
              hours: 0
              minutes: 0
              seconds: 10
              milliseconds: 0
          - action: notify.mobile_app_foo
            metadata: {}
            data:
              title: Door Open
              message: WARNING!! door open
              data:
                car_ui: true
                channel: DoorOpenAlert
                push:
                  sound: Alert_SpartanConnecting_Haptic.caf
mode: single

it does notify me when I open the door and also notifies me when its left opened for more than 10 secs (short time for testing here) but it doesn't repeat the notification every 10 second

#

Guessing I would need repeat/while action here still?

wintry dawn
# austere iris Guessing I would need repeat/while action here still?

yeah adjust it to something like this:

alias: Door Open
description: Notify target if door is open.
triggers:
  - alias: When Door Sensor changes from Closed to Open
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
    id: door_open
  - alias: When Door left opened for 10 secs
    trigger: state
    entity_id:
      - binary_sensor.door_sensor_contact
    from: "off"
    to: "on"
    for:
      hours: 0
      minutes: 0
      seconds: 10
    id: door_open_10min
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - door_open
        sequence:
          - action: notify.mobile_app_foo
            metadata: {}
            data:
              title: Door Open
              message: Someone at the door
              data:
                car_ui: true
                channel: DoorOpen
                push:
                  sound: Doorbell.caf
      - conditions:
          - condition: trigger
            id:
              - door_open_10min
        sequence:
          - repeat:
              sequence:
                - action: notify.mobile_app_foo
                  metadata: {}
                  data:
                    title: Door Open
                    message: WARNING!! door open
                    data:
                      car_ui: true
                      channel: DoorOpenAlert
                      push:
                        sound: Alert_SpartanConnecting_Haptic.caf
                - delay:
                    hours: 0
                    minutes: 0
                    seconds: 10
                    milliseconds: 0
              while:
                - condition: state
                  entity_id: binary_sensor.door_sensor_contact
                  state: "on"
mode: single