NOTE: Below, I mention that they don’t have a feature that sends a message when the condition no longer exists. Well it got added shortly after I wrote this. So you don’t need to do that fancy automation to do that. Just use the ‘done_message’ parameter.
This is an update to my post about the Garage Door Notification which was based on my Wifi Garage Door Controller .
About a week after my post about sending a repeating notification through Home Assistant, the developers created a new ‘Alert’ component that basically made my post obsolete. So I decided to switch over to the Alert component and add some extra features.
One thing I was disappointed about with the alert component was the fact that it didn’t have a built in way to send a notification when the alert condition no longer exists. So I added that in using an automation. I also added the ability to acknowledge the alert via telegram so that you can stop getting the repeating notifications.
Here is the Home Assistant yaml code to accomplish all this. There are plenty of tutorials out there on how to get your API key and chat ID for telegram. But let me know if you need any help with that:
#Setup Telegram to send notifications
notify:
- platform: telegram
name: telegramBot1
api_key: <apiKey>
chat_id: <chatID1>
- platform: telegram
name: telegramBot2
api_key: <apiKey>
chat_id: <chatID2>
- platform: telegram
name: telegramBot3
api_key: <apiKey>
chat_id: <chatID3>
- name: telegramBotGroup
platform: group
services:
- service: telegrambot1
- service: telegrambot2
- service: telegrambot3
#Setup Telegram to allow you to reply to your chat Bot
telegram_bot:
platform: polling
api_key: <apiKey>
allowed_chat_ids:
- <chatID1>
- <chatID2>
- <chatID3>
#If the garage has been open for at least 15 minutes, send a notification when it is finally closed
automation:
- id: GarageClosed
alias: Notify when garage door is closed after an alert
trigger:
platform: state
entity_id: binary_sensor.garage_door_open_for_15mins
from: 'on'
to: 'off'
action:
service: notify.telegramBotGroup
data:
message: '{{now().strftime("%H:%M:%S %Y-%m-%d")}}: Garage has been closed.'
#Turn the alert off when a telegram message of /ackGarage is received.
- id: replyAckGarage
alias: 'Telegram bot to ack the garageDoor being open'
hide_entity: true
trigger:
platform: event
event_type: telegram_command
event_data:
command: '/ackGarage'
action:
- service: alert.turn_off
entity_id: alert.garage_door
#send a repeating alert if the garage door is left open. I put '/ackGarage' at the end of the message to allow the
#recipient to easily acknowledge it by tapping on it.
alert:
garage_door:
name: '{{now().strftime("%H:%M:%S %Y-%m-%d")}}: Garage door open for {{ relative_time(states.cover.garage_door.last_changed) }}. /ackGarage'
entity_id: cover.garage_door
state: 'open'
repeat:
- 15
- 30
can_acknowledge: True
skip_first: True
notifiers:
- telegramBot1
- telegramBot2
- telegramBot3
binary_sensor:
- platform: template
sensors:
garage_door_open_for_15mins:
value_template: '{{ is_state("cover.garage_door", "open") and (as_timestamp(now()) - as_timestamp(states.cover.garage_door.last_changed) > 15 * 60 ) }}'
entity_id: sensor.time
sensor:
- platform: time_dateAnd as always, if you have any questions feel free to contact me.