@finity Oh, sorry about that. It is late here
By the way, your code on post 3 seems fine to me. I still spot some unnecessary lines, like the condition and the timer, but it is just me. I am trying to keep it as simple and less lines as possible.
Edit: And I just realized we WANT the automation to repeat itself every 30 minutes… @FutureTense I missguided you! My code DOESNT repeat itself! If you want it to repeat, then I guess the code you posted is OK! Sorry!
I agree that they aren’t necessary if you want it to only fire once but if you want it to continuously send notifications at an interval you need the condition and timer…I think…
But no worries. We all have our ways of doing things.
And yes I’m still not sure why @FutureTense needs all the different automations. I’m pretty sure my one automation will do exactly what they want. Unless I’m missing something… Which is entirely possible… Hence the question above…
The only thing that stood out at me was having “30” repeated, as well as what happens if you open and close and open again. Maybe your code resets back to 30 minutes again. But I do like code being called from the same place, that is the timer expiring. Having the closed event trapped to disable the timer is a necessary evil.
Oh I found the problem moving the code to automation.ymal. seems the timer doesn’t go there.
I looked at the alert component and it seemed that it was more complicated (to me at least) than what I’m doing.
And to answer your last question…
I guess it wouldn’t reset the timer in the condition that the door was opened, closed then reopened outside of the first 30 minute interval (the timer doesn’t get triggered to run until the after the door has been opened the first time for 30 minutes). So it could lead to a shorter time interval (less than 30 minutes) between notifications in that specific instance. But I don’t really see that as an issue. And I’ve never noticed it happening. But that may be because I don’t open & close my garage door that often. It’s usually closed.
If you are that OCD about it you could use another automation to kill the timer when the door closes…but why?
Again, either way, use what you feel best fits your needs. It just seemed that you were over complicating things and re-inventing my easier wheel I had shown you already existed.
Because as a developer, I don’t like unexpected behavior, even if it’s unlikely to occur. However it’s not really a big deal. But I do think the alert code is far simpler than any of the other solutions proposed. The only problem is (so far) I don’t know how to make it work with an external service like IFTTT.
The problem with the alert component is that it needs a notifier. If there was a notify template, you would have been able to use the ifttt component and used a trigger that would then send the sms. This however seems complicated as well. There are other notify components that are able to send sms as well. Would that work? For example https://www.home-assistant.io/components/notify.twilio_sms/
When I first created my garage door project, I wanted a way to send me a notification, so I use automations. I wrote about how I did that in THIS BLOG POST.
I’m not sure if it was my feature request that did it, but after setting up that I put in a feature request for something exactly like the alert component. And within a month of that, someone had actually created the alert component. So I wrote ANOTHER BLOG POST on using the alert component. After reading it just now, I realized that I need to update it. I was using an automation to notify when the condition no longer exists(garage door is closed). However, that automation is no longer necessary. It’s just a simple ‘done_message’ setting in the alert component.
You can take a look at both of those posts and see which one you prefer. And honestly, I couldn’t imagine anyone trying to do it any other way but the alert component. I’ve been using the alert component since it came out, and it’s been rock solid since then. It has alerted me every x minutes when my door is open, and again when it finally closes.
Let me know if you have any questions about using it.
Thought I’d share something with you that I learned today.
After seeing this snippet:
value_template: >
{% if is_state('cover.south_garage_door', 'closed') %}
Closed
{% elif is_state('cover.south_garage_door', 'open') %}
Open
{% endif %}
It made me wonder if there’s a filter to capitalize the first letter of each word in a sentence. In other words, something to convert front door to Front Door.
A quick search turned up title. So this converts the states opened and closed to Opened and Closed.
value_template: "{{ states('cover.south_garage_door') | title }}"
Thanks! that can come in useful. If I can only remember it again when I need it.
I don’t use that particular code anymore since the MyQ component is so unstable I built my own control system and the MQTT binary position sensor uses on & off that I convert to Open & Closed.
Does anyone have an example of how to use the Alert feature with a basic phone notification (via the companion app)? The doc is lacking and the examples in this thread alert via other methods I’m not using.
Nice. Like the notification interaction to close the door. That’s phase 2 for me.
Do you know of a way to get it to keep reminding you every 15 minutes if it remains open? My understanding is that’s what Alerts are designed for which is why I’m trying to get those working.
Yeah Alerts have a significant limitation of not being able to call services, scripts and other such things directly. There are work arounds but they’re abstractions that make the setup unclear and harder to trace if you need to troubleshoot or change later.
Have relented to trying to use Automations instead hence my question about triggering the examples here at different intervals.
I might just go with the basic approach of setting a delay at the end of the Automation that re-calls itself or maybe better options would be to use a time pattern and have it just repeat the automation ever 15 minutes (for example) with a condition that the door be open. Both have disadvantages over Alerts but allow me to do what I want in the resulting action much easier than Alerts do.
I did multiple triggers (via the UI) but it only triggers the first time after 15 minutes, not at 30/45 like I would have expected.
- id: '1600463929200'
alias: 'Security: Garage Door Remains Open'
description: ''
trigger:
- platform: state
entity_id: cover.garage_door
to: open
for: 00:15:00
- platform: state
entity_id: cover.garage_door
to: open
for: 00:30:00
- platform: state
entity_id: cover.garage_door
to: open
for: 00:45:00
...