Watchdog to notify that server is down from phone

I would like the Home Assistant server to send some regular heartbeat, and I want a watchdog on my phone to notify me if the heartbeat has not been detected.

One idea is if the Home Assistant Companion could set and reset e.g. a 10-minute timer, or an alarm 10 minutes from now every 5 minutes. A search for “AlarmManager” gives https://github.com/home-assistant/android/blob/1f48c44f44299025c4ff92b1a1f7ca87ada2fbcd/app/src/main/java/io/homeassistant/companion/android/sensors/NextAlarmManager.kt but I am not sure that is what I’m looking for.

Any other ideas?

I use healthchecks.io for this and works perfectly fine and has multiple platforms to notify you.

2 Likes

Thanks for the pointer. I might have misunderstood, but to clarify, I’m looking for something that works on my phone. That is, it doesn’t rely on any other infrastructure to raise an alarm when things are not running.

Make an HTTP request to the provided URL each time your cron job completes. When Healthchecks.io does not receive a ping at the expected time, it sends you an alert.

If my phone does not have a connection to their service, then I won’t get the alert, right?

My HA instance sends a heartbeat every minute to a specific healthcheck.io URL. When healthcheck.io doesn’t receive a heartbeat for 5 minutes, it sends an e-mail to my work address and a message to Whatsapp. They also provide SMS, phone calls, slack and many more.

1 Like

As I said, if my phone does not have a connection to those services, then I will not be made aware of the issue. So this is not what I’m looking for.

Like no access to SMS or phone calls? If the phone doesn’t have access to these services, how would it even connect to your HA instance in the first place?

2 Likes

If your phone has no connection how will it ever notify you? I think you’re looking for a carrier pidgeon

3 Likes

I guess what I’ve written already isn’t clear. Let me try again.

Suppose there is a message that Home Assistant can send to my phone that instructs the phone to set a system timer, the same way you set an alarm on your phone through the Clock application, or by telling the voice assistant “Set an alarm for 8 AM.”

Additionally, suppose there is a message to delete the previously set alarm.

Every 5 minutes, home assistant can send the message “delete the last alarm and set a new one for 10 minutes from now”. If my phone is then in a Faraday cage, or all other computers in the world break, my phones alarm app will still ring and I will be informed of the disruption.

It’s a simple idea. It’s like running healthcheck.io on my phone.

1 Like

This sounds more of a job for Tasker because its not just HA in this situation its literally your entire phone…but don’t think if everything is down what does it matter at that point? The real thing is that if your HA goes down and your phone has a data connection. You should worry about things that are in your control and not out of your control (i.e. all the computers going down or someone putting your phone in a faraday cage).

1 Like

The specific feature I illustrated is something that the Home Assistant Companion could conceivably do, in a similar way that certain notification channel names (e.g. alarm_stream) affect other aspects of the phone.

The examples I gave are just to illustrate the point, and to preclude any solution that would require a stable connection between my phone and yet another server. There are more realistic and benign situations that can happen. For example, my phone sometimes connects to a WiFi network that has a captive portal and requires me to log in, and if I don’t notice that, then I won’t receive notifications.

To me it seems like a straightforward concept, and I am surprised that the conversation has not been straightforward so far. I am not looking for a carrier pigeon. I’m not unreasonably worried about something that is outside my control. It just sounds like a feature that I want is not available. If anyone holds the opinion that I should not want the feature, feel free to continue sharing it, but it’s besides the point of my original question.

Your phone doesn’t need to have a stable connection to yet another server in my example with healthchecks.io. You don’t need any connection at all between heathchecks and your phone.

You will receive them, phone call, SMS and whatsapp would still be able to reach you. I think you don’t understand healthchecks.io, there’s no connection between your phone and healthchecks.io.

I’ll try to clarify, in case you misunderstand my point to mean “my phone needs a IP connection with healthchecks.io”, that I mean “I do not want my phone to require any communication whatsoever with another entity. The phone should indicate to me if there is an issue between the communication between the phone and Home Assistant.” So there’s

phone <-----> Home Assistant

and you’re suggesting

phone <-------------> Home Assistant
    ^---->healthchecks.io <-----^ 

where those arrows mean “any communication whatsoever”. For example, it can mean “healthchecks.io sends an SMS through the cellular service, which arrives at my phone”.

That model will send me an alert if and only if a specific link, the one between HA and healthchecks.io, goes down:

phone <-------------> Home Assistant
    ^---->healthchecks.io <~x~x~x~^ 

This is not what I want for two reasons:

  1. If my internet is down, but I can still access HA through my local network, I will receive an unwanted alert
  2. If the link between my phone and healthchecks.io goes down, I can miss a wanted alert.
  1. Ok, I want an alert for that, if the internet is down some parts of HA will not work and that’s something I want to know about.
  2. There is NO link between your phone and healthchecks.io. If healthchecks.io sends an SMS, you’ll receive it as soon as you have a signal, same goes for Whatsapp or similar services.

Please understand what I meant with

those arrows mean “any communication whatsoever”. For example, it can mean “healthchecks.io sends an SMS through the cellular service, which arrives at my phone”.

I do not know how to be any clearer. Information has to move from healthchecks.io to my phone.

Ok, we’ll never come to a conclusion.
Good luck finding a solution to your issue.

@Burningstone @gustavo.goretkin

I believe you are both correct.
What Burningstone says works for one of your cases. When HA looses internet.
Even if your phone at the same time also lost internet then you will get a message.

However the case that this will not work is when HA has internet and everything works fine at home but your phone is connected to a wifi that does not give you internet.
As an example a wifi with a portal as you said or as in my case when I need to print from my phone I connect to the printers wifi at work and forget to disconnect.

I believe in these cases it’s probably better to use a tasker looking app.
This could monitor the phones internet connection without a delay.
And possibly not give you wrong messages due to slight issues in network where you do not get the last heartbeat.

On a different note, turn off your wifi when you are not home.
Especially if you have used free wifis with your phone.
I could name my wifi “McDonald’s” and your phone would connect to it and you could be a victim of a ‘man in the middle attack’.
My wifi automatically turns off when I leave home.
I use an app called Llama, “location aware mobile app” or something.
Sadly the developer went missing a few years ago and the app is no longer available for download.
But it’s a great app which uses the cell towers names to determine rough position.
Because of that it uses practically no battery at all.

SMS and phone calls don’t need internet.

Anyway, I don’t wanna discuss this any further.

2 Likes

You still don’t understand.
That is not the issue he got.
And your page will not fix it.

Your page will only report an issue when HA is down.
Not when the phone does not have internet.
If the phone does not have internet then HA messages does not get through, but since HA is up an running then you do not get an sms from your page either.

I don’t see the problem here. As others already suggested I would use tasker for this. You can reset and set an alarm every time HA sends a signal to your phone and if it doesn’t (because you don’t have a connection or because HA is down) the alarm notifies you.
EDIT: You can also test tasker by installing it via the APK

1 Like

For the record, Tasker for Android