I wrote a small project using Google Apps Script to watch HA status.
The main idea is having a super stable external system for monitoring.
The script uses Home Assistant API to query the instance state.
You can configure the required number of failures before notifying.
Another configuration is the number of failures before notifying again.
All notifications are sent by email (configurable), available notifications:
- HA is unreachable/down
- HA has been unreachable/down for several attempts
- HA is back up
You can find all the necessary information in the GitHub repository below.
Wonderful idea. I’d always been turned off by external watchdog services because they required more time than I had, required infrastructure to pay for, etc. This is a great step around all that. Thank you!
I think a dedicated service like uptime robot can be a better solution. They have free plan with 5 minute check interval. You can even connect to pagerduty/opsgenie/victorops if you want to have a complete incident management. But you can just receive an email if you HA instance went down.
There are many similar services out there.
I can’t say how stable or good they are, but I can tell you about some of the advantages of Google Scripts over most of those:
- Check/Parse json response (or whatever parsing you want to do) and not only HTTP/Ping/or even keyword which is not always enough
- Higher flexibility, after my instance is Down, I don’t want to be notified every 5 minutes but only once in 3 hours and obviously, you can play with that too
- As stable as this kind of service can get
- Do whatever you want with the data (inc. adding it to a google sheet for traceback)
- It’s a free service and nobody is running behind you to pay for any extra usage
@oroce I’ve just checked the service you suggested.
I wasn’t able to find how to perform a
GET request with
Authorization: Bearer header… (and I’m not sure it’s possible, at least for free)
Definitely interested in checking this out.
Although I do find this interesting. I agree with @oroce that an external service is better. Especially for those that don’t want to expose their HA instance externally. The way services like the one oroce mentioned work is you set up a cron job on the server to perform a curl request to the address the service provides you with. It works just like your project, minus notifying you when HA is back up. Typically when there is an issue and a cron is missed that means it requires manual intervention, thus essentially making the follow-up feature of your project useless for local installations. I can see the benefit for externally accessible instances though (say to detect if internet is down). But, still I believe an online service is a better option. My suggestion is healthchecks.io or cronly.app.
Well, unless you really don’t want to expose your instance, I can’t see the benefits of using one of the online services over this, but… it’s always good to have multiple options
Absolutely To reiterate, I was just stating the benefits and downsides of both sides. I expose my instance, so it’s not an issue for me. In fact, I will likely use your method to be alerted when internet is both down and back up, which is something I was looking to accomplish.
Set this up tonight. Only took a few minutes and it works great. Very impressed.
Very cool! Super easy to setup, and this was my first google script.
The trick about adding +… to my gmail address didn’t work. No e-mail was delivered.
It delivers it, but it doesn’t show up in Inbox.
You have to create a filter and mark ‘never send to spam’ for this email, Google, go figure.
I was able to configure a folder to receive the messages, but I will never know I received them unless I look into that folder. Not much good unless they can get to my inbox. I’ll skip the “+” for this. It is a good trick for other e-mail situations though.
What this has highlighted to me is how often my Home Assistant is going down without me realising. I presume mostly when my home network drops out.
Annoyingly though my doorbell (using MQTT) doesn’t ring after HA has restarted until I power-cycle it.
You should definitely check this out. Mine is pretty stable
Many thanks @sagilo for this. I set it up and it has been running perfectly for days now. No problems at all.
how can i format the date that is sent to my email …my timezone is gmt -3…sorry for my bad english
Thx i Just seeach for GMT…and then showme a hidden tab in the project…so i chance the GMT there and nos Works great