#Notify when garage door opened manually (not via Home Assistant)
1 messages ยท Page 1 of 1 (latest)
Do you have a door sensor? I don't get that
If the door is open and the automation has not been launched, it has been opened manually
I mean I want to know if the door was opened manually and not just someone clicking open on the dashboard. I have a cover object set up in esphome with a reed switch and a relay
You can create a binary helper
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? ๐
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
By checking three conditions you can tell if it was an automation, a physical device or a person performing an action in a dashboard that changed an entity. This can be useful if you need to know if a person or an automation did something, e.g. were the lights turned on automatically or by a person operating a physical switch or dashboard contro...
I think the problem here is that the manual activation is through a remote that is not integrated into HA. But I take note to use it some day, thanks ๐ ๐
The manual activation is determined by context as well. In that article, โphysicalโ means any method outside of HA
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
I can't read and understand the code easily, I'm in my phone, but I think that there you have created a physical binary sensor. I was talking about HA binary sensor, it's a type of entity ๐
I usually create the automations via the HA front for easier reading. And I'm a programmer ๐
But would that trigger if using a voice assistant for example?
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```
You also need to check on parent_id as well. As user_id will also be none if an automation was the cause.