How would I log actions that occur during an internet outage and send notifications to my mobile once internet is back up?

Let’s say, hypothetically, my internet service goes down while I’m away from home and motion is detected or a door/window sensors is triggered during that time. How could I “queue” all actions/events to send notifications to my phone once my internet connection is back up?

Ideally, I’d like to

  1. In the event no additional events occur: Receive a notification stating my internet was briefly down (and give from when to when).
  2. If motion detected or door/window sensors are triggered: Receive a “Summary” notification listing all events during the outage and the times they occurred.

How could I accomplish this?

For #1 I personally use healthchecks.io. It’s a third-party service. If your internet is down then your device hosting Home Assistant can’t alert you that it is down because there is no internet. The way that Health Checks works is you have your device running Home Assistant ping HealthChecks on an interval (I use every 5 minutes). When a ping is missed, HealthChecks sends you a notification. I receive the notifications via email and Slack. There are several integrations for notifications. Once the internet comes back up and Health Checks receives another ping, it will alert you that the internet is back up. HealthChecks.io is a free service. Here is what my check looks like on their service.

1 Like

I have done this a little different. Because our internet is down now and then I bought a 3g modem as backup. I know all routers can not do this but my Fritzbox can. So in settings it is set to only use the 3g if main internet connection is down. Works flawless. There is more and more routers around now with this feature

I’ve done a similar thing, I use a Negear LB2120 cellular modem attached to a Netgear router running Asuswrt merlin (that supports dual wan fail-over/back).

It works fine for outgoing messages but I can’t log in or use the ios app when connected to the cellular modem. I’m happy with that as it is just a backup.

The DNS IP sensor warns me of a change in IP associated with connecting to a different network.

That might work, but I was hoping to get a solution that would work for both 1 & 2.

I have a Netgear C3000-NAS100 router/modem combo device. Any idea if it’ll work with that?

I don’t want to have to flash custom firmware on my router.

The native C3000 firmware does not support dual wan.

There is no alternative firmware for it anyway.

Back to your original plan…

1 Like

On my router the usb port is the second wan port.

Can you please share how you have setup the healthcheck in Home Assistant making the HTTP request?

If I were to use @bradyn12’s suggestion of healthchecks.io for being able to be notification when my internet goes down that could work. I just need a way to share all actions that occurred locally during the outage once the internet is back up. Is there some simple way to just send all actions/events from the system’s logs between two times (beginning of outage and end of outage) to my phone either via text or notification?

Im not sure. You can write them to the logbook easy enough if the net is down and check that when it comes up later.

Use the ping sensor to check for internet connectivity by pinging a public web page (e.g. google)

For all your notifications insert a template to test the ping sensor and write custom entries to the logbook instead of your usual notification method if required.

Having a single notification script you pass messages to would make this easier.

I’m not sure how but you might also be able to write them to a file and email that as an attachment when the ping sensor reconnects.

1 Like

Can anyone provide a step-by-step of sorts on how to accomplish this? Recording to logbook & and sending those recording that happened during downtime would be perfect.

You’d be better off writing them to a file than the logbook. The logbook will have other automated entries that will clutter up you messages and I’m not sure how to extract a time range.

So basically, if my logic is correct it would go something like this:

  • Using either the Ping or Healthchecks.io services, routinely check for loss of internet connection.
  • Once internet connection is lost, record time it’s lost to a file using the File component
  • Continually add any actions such as motion sensors or door/window sensors triggered that happen during downtime to the file with timestamps.
  • Once Ping/healthcheck.io component detects internet connection is back online send SMS to phone with contents of the log file

Am I on the right track?

Something like that. I wouldn’t use SMS to sent the file contents. It has a very limited message length (160 characters). SMTP (email) would be better.
You could send an SMS to tell you internet is back to check your email. But if you are going to do that you might as well log into your HA instance once you get the alert SMS and go over the logbook. :thinking:

You could use Node-Red to do this, probably easier than doing it in Home Assistant alone.

I was actually curious about using the NodeRed add-on for this. How would the NodeRed routine show in my configuration.yaml file?

TBH, I’d rather avoid NodeRed for now. I’m sure someone has been able to come up with a relatively simple script for this sort of thing.

Your config file has nothing to do with Node-Red. Node-Red could use the state of the ping from HA, and log to a file, and when the state of the ping changes back, it fires off the messages to you in any way you like (email, pushover, pushbullet, SMS, Telegram, Facebook Messenger, etc)

Would you mind sharing how you have the healthchecks.io ping set-up on your server? Did you add a cron job or did you set up something in Home Assistant? Could you provide the instructions on setting it up how you have it? That situation is ideal for me now.