I’m new on HA, and I’m want it to send me a notification on my phone when my HA hub is offline( due internet connection or power failure), and reset in case is just the internet.
the problem is that I don’t know whitch trigger i should use
You want HA to send you a notification if it loses internet or loses power? Think about that question for a second…
The only way that will happen is if you have a backup battery and a second internet connection (cellular, GSM, etc.). And at that point, you now have redundant systems in place and should never experience such a failure. The only thing I can think of is having an external service that pings your HA and when it stops responding, then send you a notification. But this would be external to HA and hardly anything, if anything at all, to configure in HA. Not sure if a DDNS service like DuckDNS would do this or not.
Can I use the internet connection as a triggert to reboot my RPI (some times the connection fails and when I reboot It comes back)
You probably can, but It has nothing to do with HA at this point. You would create a script that acts like a “dead mans switch” and if something doesn’t change, say a counter, a heartbeat, whatever that’s being set externally, then the script executes and issues a reboot command on the RPi.
At least for the part of knowing if either the HA system or the internet connection is down, I have implemented the following:
On the server hosting HA, I have a cronjob that sends a ping every minute to healthchecks.io which then notifies me via Pushover if no ping has been received for the last 5 minutes.
But I don’t have any automated restart/reset or internet reconnect in place since the failure situations can be pretty complex and likewise are the steps to resolve.
hey man, interested in this.
How did you set this up?
- Sign up on healthchecks.io
- “Add Check” on their website for your HA server - this will give you a ping URL.
- For my HA server I configured a period of 1 minute and grace time of 5 minutes.
- Add “Pushover” (or whatever you prefer and is supported) as an integration.
- On my HA server (running Ubuntu 16.04), I added a new line to
/etc/crontab
with the above ping URL, and which will run every minute.
* * * * * root curl -fsS --retry 3 https://hc-ping.com/ad372ea0-xxxx-xxxx-xxxx-xxxxxxxxxxxx > /dev/null
Thanks mate.
Went with the easy route in configuration.yaml:
rest_command:
healthcheck:
url: 'https://hc-ping.com/xxxxxxx'
Running Hassio on RPi2
I have a NodeRED flow that looks at the HA webhook.
If it doesn’t hear anything from the webhook in 10 mins then it will fire off an alert.
i just added your code into config file. BUT how often does it ping the site hc-ping.com?
is it possible to change the frequency?
The rest command itself does not ping automatically at all. You will have to create an automation around that which could be triggered at time intervals.
got it!
now, i wonder if i can use the rest command to ping my NVR’s IP. if NVR does not respond, then the rest command won’t respond to hc-ping.com …then i will know my NVR machine is down. or maybe something more eloquent to notify me when NVR is down?
Assuming that you want to cover the case where HA is still up and running, but your NVR isn’t: Why not use a simple ping
binary sensor? And then build an automation that notifies you when that ping is not coming through anymore for a certain period of time.
@tung256 Sorry for the late reply. Seems like you got it working?
let me know if you any other questions.
How do I configure the automation to use the “rest” command?
Thanks for the quick response! I am setting that up now.