I have a question regarding a problem and I don’t now whats better to use a Automation or a Skript.
I have a garage door and this door hat an photoelectric barrier so it could be that the garage door will not close when maybe a cat goes through the photoelectric barrier.
Now I want to add a “function” to send a message to my phone when 1 press the close button but 1 minute later the garage door is not closed.
What is better to use a Automation or a Skript.
I think maybe there could be a problem with the 1 minute delay and an automation.
Thanks for your suggestions.
That sounds logikal to me and was also my first thinking. But how to implement the delay of 1 minute?
description: "Send notification wenn Garage door is not closed correctly"
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.garagentor_fahrt_zu
from: null
to: "on"
condition:
- condition: and
conditions:
- condition: not
conditions:
- condition: state
entity_id: binary_sensor.garagentor_geschlossen
state: "on"
- condition: time
after: "00:01:00"
action:
- service: notify.notify
metadata: {}
data:
title: Warnung!!!
message: Garage door not closed
description: "Send notification wenn Garage door is not closed correctly"
mode: single
trigger:
- platform: state
entity_id:
- binary_sensor.garagentor_fahrt_zu
from: null
to: "on"
condition:
- condition: and
conditions:
- condition: not
conditions:
- condition: state
entity_id: binary_sensor.garagentor_geschlossen
state: "on"
- condition: time
after: "00:01:00"
action:
- service: button.press # or however you close your garage here
target:
entity_id: button.garage_door
- delay: 60
- condition: state
entity_id: binary_sensor.garage_door
state: 'on' # only do the next action if the door isnot closed
- service: notify.notify
metadata: {}
data:
title: Warnung!!!
message: Garage door not closed
looks realy complicated for such a small automation but im absolute beginner maybe thats the reason orit is because of my complicated first start code.
Is this an easy way?
description: Send notification wenn Garage door is not closed correctly
mode: single
trigger: # start Automation wenn Garage door is moving from open to close
- platform: state
entity_id:
- binary_sensor.garagentor_fahrt_zu
from: null
to: "on"
condition: []
action:
- delay: 60 # wait 60 seconds until door is closed
- condition: state # prove position of garage door and exit if it is status is on
entity_id: binary_sensor.garagentor_geschlossen
state: "on"
- service: notify.notify # only send notification if status of position of garage doo is "off"
metadata: {}
data:
title: Warnung!!!
message: Garage door not closed
Hello after some hours of trying now I have a solution that works for me.
For me it is necessary to prove if the garage door is closed or if it is not closed.
description: Send notification wenn Garage door is not closed correctly
trigger:
- platform: state
entity_id:
- binary_sensor.garagentor_fahrt_zu # Wenn garage door moves to close position this is the trigger
from: "off"
to: "on"
condition: []
action:
- delay: 60 # time delay to give the garage door the time to close
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.garagentor_geschlossen # prove if door is closed then stop sending a message / do nothing
state: "on"
sequence []
- conditions:
- condition: not
conditions:
- condition: state
entity_id: binary_sensor.garagentor_geschlossen # prove if door is not closed then send a message.
state: "on"
sequence:
- service: notify.telegram_gruppe
data:
message: garage door is not closed
mode: single
Here’s a more efficient way to achieve the same result. It uses wait_for_trigger and timeout.
alias: example
description: Send notification wenn Garage door is not closed correctly
trigger:
- platform: state
entity_id:
- binary_sensor.garagentor_fahrt_zu
from: "off"
to: "on"
condition: []
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.garagentor_fahrt_zu
to: 'off'
timeout:
minutes: 1
- if: "{{ wait.trigger == none }}"
then:
- service: notify.telegram_gruppe
data:
message: garage door is not closed
mode: single
The wait_for_trigger waits up to 1 minute for the garage door to close.
If it takes more than 1 minute to close, the value of the variable wait.trigger is none and so the notification is sent.
If it takes less than 1 minute to close, the value of the variable wait.trigger is not none and no notification is sent.