Deadman's Switch for Home Assistant

EDIT: Server shut down … it is basically the same as healthchecks.io

Hi, a while back I’ve read this post

and came to the conclusion that my Home-assistant setup is too important to run without any supervision. I didn’t like the suggested solution, because it involves to open a port in the firewall which I’d like to avoid.

That’s why I’ve created a small service that I’ve described here:

I’d be curious if anyone else would like to comment the method / code or even want to use it.
As of now it is running stable for 3 days and open for everyone to use.

Kolja

Very similar approach here: I’m using healthchecks.io where I defined a check for HA. I implemented an automation that calls the healthchecks URL every minute. And then activated the Pushover integration on healthckecks.io which sends me a message if HA hasn’t checked in for more than 5 minutes.

I do the same on the server that runs HA using a cronjob and a different URL so that I can distinguish between general loss of Internet connectivity at home and just HA becoming unresponsive.

Thanks for sharing. It’s a reasonable approach and somebody would like to play with it, but in a long run it’s not reliable to rely on someone else’s service, even on a commercial one.
That’s why many might use the idea/code, but run their own server for that.

DAMN IT … I can’t believe it :face_with_raised_eyebrow:
I’ve googled for almost an hour yesterday before programming.
My assumption was that a service like this would already be there.
But didn’t find it. Thanks. I’ll switch an shutdown my server task …

grrrrrrrr

Happy to share a few config snippets if it helps.

Setting up the rest command:

rest_command:
  healthcheck_ping:
    url: 'https://hc-ping.com/xxxxxxxx-xxxx-xxxx-xxxx'

Call above rest command every minute:

automation:
  - id: healthcheck_ping
    alias: "Healthcheck Ping"
    trigger:
      platform: time_pattern
      # Ping every minute
      minutes: "/1"
    action:
      - service: rest_command.healthcheck_ping
3 Likes

Thanks, that’s about the same that I’m using. You can add the xxx part to your secrets.yaml … just to make it a bit more portable
Server down, project closed :sleepy:

Interesting concept, thanks for posting the snippets.

I do something very similar, but for a different reason. The URL I call every 5 minutes is a script on an external web hosting service where I have a few domains I dabble with. That script records the caller’s IP address in a text file on the server.

Thus, the scripts on the server always “know” the IP address of my external router. This can come in handy. For example I have a link that sends me to the correct HA address whether I’m home or away. That link calls another script which compares my home IP address to the one I’m currently using. If they match, t redirects to my internal (192.168…) HA address, but if not, it redirects to the external address it reads from that text file.

The check-in script also returns the IP address to the caller, so now HA also can display my home IP address:

  - platform: command_line
    command: python3 -c "import requests; print(requests.get('http://www.mydomain.com/myip.asp').text)"
    name: home_ip
    scan_interval: 300

(Yes, I’m an old Windows guy so it’s still running an old, classic ASP script. But it’s dead simple logic. You could do the same thing in PHP or any other scripting language.)

Since I already have this up, it wouldn’t be hard to add some logic to notify me if HA hasn’t “checked in” for a while, or at the very least, show on my home page when the last time was.

My point is, here’s another way to implement the regular check-in, using the command_line platform instead of rest and an automation. The main benefit here is that you can call a URL which returns some useful text (in my case, the IP address) that you can use elsewhere.

It does all depend on a reliable web hosting service. But the big names in hosting all boast uptime far better than anything I could achieve with my own hardware.