I just discovered theMy Q cover which allowed me to connect to my Chamberlain garage door opener.
What design approach options do I have in home assistant to send an alert (say email) if the door state is not closed for 15 minutes? I want to use not closed as opposed to open because I believe there are other states like stopped and unknown — though I can’t find any documentation for MyQ cover.
The design should take into account that I could open the door from something other than Home Assistant, such as the physical garage door button, remotes, or even the MyQ app.
I suppose I need something to monitor the door state and as soon as it becomes !closed, start a 15 minute timer and when the timer expires send an email. And if during that 15 minutes the state changes to close, cancel the timer. What parts in HA will help me accomplish this?
automation:
- alias: 'North GD Open Notification'
trigger:
- platform: state
entity_id: sensor.n_gd_pos_template
to: 'Open'
for:
minutes: 30
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.north_garage_door
condition:
condition: state
entity_id: sensor.n_gd_pos_template
state: 'Open'
action:
- service: notify.pushbullet_notify
data:
message: 'The North Garage Door Is Still Open'
- service: timer.start
entity_id: timer.north_garage_door
timer:
north_garage_door:
duration: '00:30:00'
it sends a pushbullet message after the door has been open for 30 minutes and starts a 30 minute timer. which, when finished restarts the automation. so it sends a message every thirty minutes when the door is open.
@finity is it possible to have the trigger work for ! ‘Closed’ instead of Open? It’s possible that have the garage be in other states, such as stopped (and others I’m not even aware of nor know how to find). So I’d like to check to see if it’s not closed instead of opened.
I’m not sure if that’s possible but I don’t think it’s necessary.
I have a MyQ garage door opener that I just installed a month ago and it only has 2 positions (open & closed). there is no intermediate position. once it gets about 2 feet open it goes from closed to open & once it goes about half way closed it shows closed.
If you have your garage door opener programmed in to HA as a cover, you can go to the states page & see the status change as you operate it.
To add my MyQ opener I just added the MyQ component. It automatically found my opener and created the cover like yours did. Since I have two garage doors my doors are named north & south in my set up. So it created a cover.south_garage_door based on the MyQ name.
Then since I didn’t like just the standard arrow and square display I created a template sensor to extract out the position in words to show on the frontend to make the position more explicit. I did that for both doors so the sensor.n_gd_pos_template is the template sensor I created for the non-MyQ north garage door.
I also did some customizing for the icons and stuff too.
The example I gave was for my non_MyQ north garage door opener. the concept would be the same tho. just change sensor.n_gd_pos_template to cover.garage_door_opener. And you’ll need to change the position to ‘open’ (not capitalized). Mine is capitalized by my template sensor for the position. The original created automatically isn’t capitalized.
Is that hassio? BTW, would this command line install also work for installing to a Rock64? It doesn’t appear to be hardware specific (excep for the -m option, which im not sure what it does)
All of the following is based on just guesses on my part from the link you posted:
it looks like (from the link) you went with Hassio.
It looks like it would work on other platforms depending on the “-m” option you choose but I don’t see in the code a selection for “raspberrypi3” for the machine option. It looks like the first line in that code pulls the hardware version and then installs the correct hassio version based on that so you might be able to use one of the other options (i386, x86_64, etc) depending what hardware the Rock64 is.
Or maybe try running with everything in that curl command leaving off the -m and see if it works.
So with this, if I open the garage, close it 1 minute later, then open it again and 29 minutes elapse, then the notification will still be sent? To fix this from happening, I would need to create an automation that would reset or disable the timer if the garage is closed? How can you determine if a timer is active or running?
ETA: Actually it appears I don’t need to do that because of the for condition, though it might make sense to disable the timer upon the door being opened OR create 3 triggers where the first starts the timer when the door is opened, the second sends a notification when the timer expires, and a third which cancels the timer when the door is closed. I like this approach because you only have to define the time period once
I rewrote this to use 3 triggers. One for the door opening, one for the door closing, and one for the timer triggering which then calls IFTTT to send an SMS. I use IFTTT because the SMS always comes from the same address and I can use my iOS devices to assign that a custom tone which will always go off even if the phone is in silent mode.
automation:
- id: garage_opened
alias: 'Garage Door Opened'
trigger:
- platform: state
entity_id: cover.garage_door_opener
to: 'open'
condition:
condition: state
entity_id: cover.garage_door_opener
state: 'open'
action:
- service: timer.start
entity_id: timer.garage_door
- id: garage_closed
alias: 'Garage Door Closed'
trigger:
- platform: state
entity_id: cover.garage_door_opener
to: 'closed'
action:
- service: timer.cancel
entity_id: timer.garage_door
- id: garage_opened_timer_finished
alias: 'Garage Opened Timer Finished'
trigger:
- platform: event
event_type: timer.finished
event_data:
entity_id: timer.garage_door
condition:
condition: state
entity_id: cover.garage_door_opener
state: 'open'
action:
- service: ifttt.trigger
data: {"event": "GarageLeftOpened"}
- service: timer.start
entity_id: timer.garage_door
timer:
garage_door:
duration: '00:30:00'
Cool thinking, but you dont need all that stuff.
Lets clear it a bit if you feel ok with this:
First of all, remove the conditions. Basically you did this:
“trigger the automation when the door opens, but only if the door is open” — see what you did there?
You can think ahead and say that you want a condition when you are not home. Lets leave that for now.
Second, you dont need timers because they can be intergrated into the automations:
I rewrote your automations. I believe it is a bit more clear now. A single automation to do all the above.
automation:
- id: 'garage_open_notification'
alias: 'Garage Door Opened'
trigger:
- platform: state
entity_id: cover.garage_door_opener
to: 'open'
for:
minutes: 30
condition: []
action:
- service: ifttt.trigger
data: {"event": "GarageLeftOpened"}
No, it will happen only ONCE per trigger. That means that it will notify you once when it is open for 30 mins. If the door changes state (closed) and then opens again, then it will wait for 30 minutes and will notify you again.
I guess I’m confused about what your concern is with the code I posted originally above. It should do exactly what you want it to do.
It sends a notification 30 minutes after the door opens and sends a notification every 30 minutes until the door closes. If the door closes before the 30 minute timer is up then the condition of the door being open isn’t met so everything just stops.
No no nothing wrong at all!. The automation I posted was just to clear things up a bit. Nothing more! Sorry for the confusion! My purpose was to minimize the code as much as possible and have the same effect!
Your automation is perfect and I already mentioned it is: