Rule for network check and switch

Dear all

I plan to setup a rule to monitor the network (WAN) connection and if it fails to reach out
control a zwave based switch to power off and on.

  • Platform information:
    • OS: Debian 9 Kernel 4.9.0
    • Java Runtime Environment: oracle version 1.8.0_201
    • openHAB version: 2.5.0.M1

It regularly happens that the internet connection breaks, basically the cable modem doesn’t find it’s way to the provider anymore. Under such circumstances only a switch off / on of the modem helps to restore.
To make life more easy I would like to do a check for the connectivity. I don’t know if it would make sense to do this time driven or another approach.

Currently the router is attached to a normal power plug. But a ZWave based power switch (devolo) is already on its way. And will be used soon.

I would appreciate if you could help me to find a good way to do it (no thread:sleep actions)…


Use network binding to ping some common external service -,, or etc.
Take a vote on more than one to prevent false alarms.
Probably include some timing/blocking element to ensure some time between power cycles if it stays broke.

good point! I will take that up

Under normal circumstances it takes about 5 - 10 minutes to come back. So that’s also something that I need to take into account.

Hmm that might get more complex than I thought before, but ok. Another adventure to play with :slight_smile:

I found this on the OH forums - How to monitor a dynamic WAN IP address

Unsure if your IP from the ISP is changing when it fails to reach the Internet, but could be another check to have in place.

That’s not important in my case, but thank you anyway.
I have my own dynamicDNS solution in place. Which is working nice.

My focus is not on the outside to inside network world, but the other way around.


I also have a dynamic DNS solution in place, but as I use a free service there is a window where it updates every 4 hours, which is more of an annoyance so I can at least be sent a telegram and manually update my record.

The other reason I posted it is in my case if my cable modem stops connecting to my ISP it will default to a IP address which doesn’t help in notifying me when I have an issue but if my IP becomes something in that range then I can trigger an outlet to cycle the power on the modem. I also have an SNMP query in place on the router so I OH has this info to make that decision.
I was unsure if your cable modem behaved the same way with defaulting to an IP address or if it retained your public IP given from your ISP.

Hmmm, actually I never kept an eye on that. But honestly I think not, i.e from network (and my) point of view it doesn’t really make sense to give the device (WAN) an address out of the private IP range when it looses its provider connection. But maybe I’m wrong because I didn’t watch out for such things.

When my wife complains that internet is not working, I should just hurry up and bring it back. :slight_smile:

I don’t get a choice with my modem, if it looses a connection to the ISP (lets say line cut) my modem will put an IP on itself with no intervention. I’ve only caught this as I’ve had long outages in the past and found the 192.168.100.x IP on the device, it never changes until the ISP can see it and a configuration is put into the modem at which point I loose web access to the modem.

I’ve also been in a situation with the Internet dropping and the spouse demanding it come back…I think maybe once a power cycle of the modem fixed the issue. Its become a lot more stable as I have lived in my house, but for a short while I was having to graph SNR and other stats to show a tech dispatched to figure out why my connection was so terrible.

How is your local network setup? If you are using one device for the Internet connection and as the network switch, you are running into a problem when trying the switch the Internet connection back on.

Hi Jürgen

directly connected to the cable modem are:

  • devolo powerline device
  • OH server itself (fixed IP)

IP addresses are served from a fritzbox attached on the powerline network
So even if the cable modem is in a state where we don’t have internet connection, the private network still operates. In fact during a reboot of the cable modem routing doesn’t work, but will recover after it is up again. Which is some kind of normal behavior. In other words I’m not expecting any issues to be caused by that, as I’m doing this anyway when it occurs.


Does pinging external services not meet your requirement?
You need a switch Item for each of the likes of and
A rule that triggers if either changes
The rule looks to see if both are off
and if so, initiates the router reboot.

A simple way is to have a dummy switch Item, and set expire binding on it for 20 or 30 minutes say to state OFF.
When a reboot is wanted, command ON to this Item.
A rule listens for change to ON and does the power cycle.

No matter how many times you command ON in the 30 minutes. no further change can occur. Until the expire lets it OFF again.