I’m trying to have Home Assistant notify me when my garage door opens and I’m not at home.
My garage door configuration is a Cover using the MQTT platform. It’s a reed switch that connects to a Shelly relay that controls the garage door opener. Here’s the cover:
- id: '1636145538565'
alias: Garage Notification
description: Notify me when the garage door changes and I'm not home
trigger:
- platform: state
entity_id: cover.garage_door
from: '0'
to: '1'
attribute: current_position
condition: []
action:
- service: notify.mobile_app_pixel_4_xl
data:
message: Garage Door Opened
mode: single
Because the cover is using the MQTT platform, do I need to do this a different way?
A cover’s states are open and closed. You can confirm that by inspecting the state value of cover.garage_door in Developer Tools > States.
To constrain the automation to notify you only when you are not home, you need to include a condition that checks your current status. In the following example, I used a device_tracker but you will need to replace it with whatever entity you are currently using to indicate if you are home or not.
- id: '1636145538565'
alias: Garage Notification
description: Notify me when the garage door changes and I'm not home
trigger:
- platform: state
entity_id: cover.garage_door
from: 'closed'
to: 'open'
condition:
- condition: state
entity_id: device_tracker.your_device_tracker
state: 'not_home'
action:
- service: notify.mobile_app_pixel_4_xl
data:
message: Garage Door Opened
mode: single
I omitted the condition because I was trying to rule out anything that could have been preventing this from working. This is my final automation that works:
- id: '1636145538565'
alias: Garage Notification
description: Notify me when the garage door changes and I'm not home
trigger:
- platform: state
entity_id: cover.garage_door
from: closed
to: open
condition:
- condition: not
conditions:
- condition: zone
entity_id: device_tracker.pixel_4_xl
zone: zone.home
action:
- service: notify.mobile_app_pixel_4_xl
data:
message: Garage Door Opened
mode: single
BTW @123 you helped me with another issue with this cover I had 7 months ago. Maybe I should just call you directly next time