External Home Assistant watchdog

Hi all,

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.

Notifications

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.

Links

GitHub repository

main

16 Likes

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!

1 Like

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.

2 Likes

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

edit:
@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.

1 Like

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.

2 Likes

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 :slight_smile:

1 Like

Absolutely :slight_smile: 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.

Sounds good :slight_smile:

1 Like

Set this up tonight. Only took a few minutes and it works great. Very impressed.

1 Like

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.

1 Like

how can i format the date that is sent to my email ā€¦my timezone is gmt -3ā€¦sorry for my bad english

See here

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