Homey Community Forum

How to detect an internet deconnection?

Hello,

I live in an area with a lot of internet loss.
My actuall router is not compatible with a 3G/4G LTE dongle to automaticly switch between networks.
I will change it soon.
But for now, i need to know if there is a way to detect an internet deconnection to automaticly turn off/on the plug off my modem.
Is there a reliable way for Homey to detect internet disconnection ?

Thanks.

1 Like

Perhaps the NetScan App could do this. Using a official IP (from Google perhaps like their DNS 8.8.8.8) could tell you if it’s offline.

This is for local network isn’t it ?

Don’t know. Haven’t tried yet. If it’s using just a IP/port, then it shouldn’t matter if it’s a local IP or not.
The http request flow app could call a server outside your network if NetScan doesn’t work.
I would just try some of these apps if you can call such a IP.

Hi Jeremy,
I tested the suggestion of @RonnyW and it works using NetScan with my own internet IP address, but not with f.i. 8.8.8.8
I pulled the plug from my internet wall outlet to simulate it.

So the app seems to work fine, but Google has not opened the used port.
You can check if you can set another port in the app/device or try some other public IPs. Perhaps your internet provider has some static IPs you can use, then the traffic is only in your provider network and not depending on access to www-servers.

I tried both athom.com IP’s with no luck. I didn’t specify a port yet, just default ping

What device did you use? IP address or TCP port?
I don’t know what kind of connection check is used for IP (ping?).
I tried the port-devicetype with 8.8.8.8 port 53 (DNS port). This seems to work even though DNS port 53 uses UDP and not TCP.

I used the IP device.
Ping doesn’t use ports afaik
If you use the TCP port device, you can, well, monitor an open or closed port at a specified IP.
But nonetheless, using a TCP device for let’s say google DNS IP’s or whatever you’d like makes sense!
Using netscan TCP device works for both www.athom.com:80 IP’s
Thanks for the hint, Ronny

If you happen to have a netgear router you can detect internet down with the Homey Netgear app. It doesn’t have to be your main router to work with the app.

Yes i have a Neatgear R9000 but the detection is not reliable at all…

In the device settings you can select who is doing the internet check. Try switching that to Homey in stead of Netgear.

Yes i tried both and this is not very precise…
But i use it meanwhile i find something better.

1 Like

Well, there must be some other issue then. I made the Homey internet check pretty reliable (or so I thought :thinking:)

Edit: I checked my code, and I am actually letting Homey do a DNS lookup to www.google.com:
dnsLookupPromise('www.google.com')

So if that really doesn’t work something must be totally wrong in your network config. Your DNS server config must be whacked. How are you handing an IP address to your Homey? Are you using DHCP?

Homey runs its own DNS server (for whatever reason). If that has been configured to use caching, it might be possible that it returns a result from cache instead of performing a full lookup, giving the false impression that an internet connection is present even if it’s not.

Sux

You can use https://ipv4.icanhazip.com. The response is very simple. If your internet connection is working this server responds with your external ip address.
You can best use the HomeyScript fetch command for this

2 Likes

The Netscan app doesn’t use ping because that requires privileged low level access to sockets that is not available to a Homey app.
The main differences between the two types is what errors determine a good connection. One accepts a rejection as a valid connection and the other one doesn’t. The IP connection method actually tries to connect to port 1.
Basically this is the actions if the original Netscan app and I have just continued with the same approach.

The best approach is to make a connection to port 80, e.g. a web page.

2 Likes

Why not use:
(?)

2 Likes

Im gonna try this app and see if it is better than netgear detection.
If not I will ask for an exemple of a script for Homeyscript.

2 Likes