#Notify when garage door opened manually (not via Home Assistant)

1 messages ยท Page 1 of 1 (latest)

honest mesa
#

Hey, I want to make an automation that sends a notification when the garage door is opened using the physical remote, not through Home Assistant.

I already have a cover object that shows if the door is open or closed in HA. The idea is to only get a notification if it was opened manually, not when I open it via HA. Thanks.

storm rover
#

If the door is open and the automation has not been launched, it has been opened manually

honest mesa
storm rover
#

In the automation that opens the door, you have to add a step at the beginning of the actions that activates the helper

#

And one final step that deactivates the helper

#

This way, you can know if the automation is activated and running in this moment

#

For security reasons, I'll add a delay of let's say 10 seconds before deactivating the binary helper

#

That said , you can now create a new automation

#

If the door is open, and the binary helper is not activated, is because you have opened it manually, not by the automation

#

Does this suit you? ๐Ÿ™‚

grand marlin
# honest mesa Hey, I want to make an automation that sends a notification when the garage door...

You can use context provided by the trigger to determine how the door was opened.

https://community.home-assistant.io/t/how-to-use-context/723136

storm rover
grand marlin
#

The manual activation is determined by context as well. In that article, โ€œphysicalโ€ means any method outside of HA

honest mesa
# storm rover You can create a binary helper

something like this?

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO1
      mode: INPUT_PULLUP
    name: "Garage Door Sensor"
    id: garage_door_sensor
    device_class: garage_door

  - platform: template
    name: "Garage Recently Triggered"
    id: garage_recently_triggered
    lambda: |-
      return id(recently_triggered_flag);

globals:
  - id: recently_triggered_flag
    type: bool
    restore_value: false
    initial_value: 'false'

script:
  - id: garage_trigger_reset_script
    mode: restart
    then:
      - globals.set:
          id: recently_triggered_flag
          value: 'true'
      - component.update: garage_recently_triggered
      - delay: 10s
      - globals.set:
          id: recently_triggered_flag
          value: 'false'
      - component.update: garage_recently_triggered

cover:
  - platform: template
    name: "Garage Door"
    device_class: garage
    open_action:
      - script.execute: garage_trigger_reset_script
      - switch.turn_on: relay4
      - delay: 300ms
      - switch.turn_off: relay4
    close_action:
      - script.execute: garage_trigger_reset_script
      - switch.turn_on: relay4
      - delay: 300ms
      - switch.turn_off: relay4
    lambda: |-
      if (id(garage_door_sensor).state) {
        return COVER_OPEN;
      } else {
        return COVER_CLOSED;
      }
    optimistic: false
    assumed_state: false

storm rover
#

I usually create the automations via the HA front for easier reading. And I'm a programmer ๐Ÿ˜‚

honest mesa
storm rover
honest mesa
# storm rover What do you mean? ๐Ÿ™‚

Never mind, I did it like this, seems to be working

alias: Garage Triggered (Manual/ESP)
description: ""
triggers:
  - entity_id:
      - cover.garage_garage_door
    to: null
    trigger: state
    from: null
conditions:
  - condition: template
    value_template: |
      {{ trigger.to_state.context.user_id is none }}
actions:
  - action: notify.mobile_app_iphone1
    metadata: {}
    data:
      message: "Garage door open"
mode: single```
low apex
#

You also need to check on parent_id as well. As user_id will also be none if an automation was the cause.