Restart router if no internet connection

My use case is, that openHAB runs on a remote location and accidentally I figured, that sometimes the router loses internet connection but never reconnects. I don’t know the cause yet and I hope if I switch to a new Fritz.Box the problem is gone - but still…
Is there some kind of system, which can power off the router and turn it on after some time? - of course without internet access? :sunglasses:

I could just use a “normal” time clock and do this every week. But I’d prefer a smarter solution. Is there something which can be triggered to do so on its own? Just start the process via oh2 and the device “hard boots” the router?

You could ping an outside IP say Google and if no response turn off the router and turn it back on with remote RF socket (Not a WiFi one obviously)
Or send a reboot command to your router. Some routers have this facility.

Usually all Fritzboxes i know have the feature to reconnect to the internet on a daily schedule. This is a leftover from the time the Telekom killed internet connections after 24 hours.

Look for a menu item like “Zwangstrennung zuvorzukommen”.

That would be a possible solution, if openHAB would still be running - but still if I had to reboot the whole setup including openHAB. My idea is to have some Kind of device which can automatically turn the power strip on again - obviously without an additional trigger but all by itself. Kind of a time clock - but on demand and not on schedule… :wink:

Maybe a “treppenlichtschalter” (staircase light switch) - but in the other way.

When you switch on the “treppenlichtschalter” it will cut off the power for a given time period (maybe 5 sec) and after that, power will switch on again on its own.

Don´t know, how to cable this, but it is possible.


Or you can send a http command to your fritzbox, to do a reconnect. This would be the smarter way:
http://www.gtkdb.de/index_7_1302.html
or

If this doesn´t work, look on goolge for fritzbox reconnect script.

There was some change in the firmwares some time ago, you have to look for a script which is still working. But it is still working with the latest firmwares, only the command has changed.

1 Like

“Treppenlichtschalter” would be a solution - but backwards! :wink:
But the idea is great… Perhaps I can work something out…

I’d prefer not to rely on a responsive Fritzbox - if the box crashes (which I don’t know yet, I’ll drive up on the Weekend), this won’t work… so I prefer a “Hardware” solution. :wink:

I remember seeing something like that based on an ESP8266 and a relay.
The ESP8266 was pinging regularly and resetting the relay if no response.
I don’t have time to look right now but a sonoff with custom firmware will do the job very nicely.

I do have some Sonoffs with Tasmota - but I was under the impression, they need MQTT commands - with that one I need a working network or even internet connection. Or do you mean, I should flash a completely custom firmware, which pings regularly and shuts down, if the ping isn’t successful.

Yes that’s what I mean:

https://www.elec-cafe.com/esp8266-automatic-restart-modem-or-router/

This code in a sonoff should work
You’ll have to reassign the pin to the sonoff relay pin which I believe is pin 12 from memory.

compile and upload in Arduino IDE

1 Like

@binderth Justmy2cents Kick the Fritz!Box in the bin and buy a real router.
There are too much features in Fritz!Boxes which has nothing to do with the main job
-> beeing a reliable router. I think you are from Germany. Take a look at the “Digitalisierungsbox” from Telekom. It is a branded bintec-elmeg business router.
Not a feature monster like the Fritz!Box but what is inside work as it should.
A router has to work without a reset the whole year!

Turns out, tasmota already has this implemented with the Backlog feature with Delay:

Backlog Power OFF;Delay 600;Power ON

switches the power off, waits 60 sec and switches the power on

Using http
http://sonoff/cm?user=admin&password=joker&cmnd=Backlog%20Power%20OFF;Delay%20600;Power%20ON

Using MQTT
Topic tasmota/mydevice/cmnd/Backlog Payload Power OFF;Delay 600;Power ON

1 Like

Yes but do you get the sonoff to check if the router is still connected to the internet in order to start this backlog sequence?
As far as I am aware Tasmota doesn’t have an Internet live ping check feature.

Interesting. But reading the specs, what features make the Frizbox a feature monster, which are not included in the “Digitalisierungsbox”?

I own a Fritzbox and it’s working fine. No disconnects or reboots, VPN works like it should. Wlan is fine after extending the antennas.

@job no NAS Feature (really crap on a router) no Smart Home
and a processor that can handle more VPN connections and not getting in performance troubles and no propitary solutions. All implemented features are based on common know standards
I didnt say that the router is a low feature one. Every feature works even when all used together. The box has wlan contoller for 3 Accesspoints on board too. I have 2 connected. Nice handling. I had a Fritz!Box before…
My conclusion overhyped and to expensive for the used processors on the boards…

Ah, i see. All the features i do not use. That’s why i forgot these.
Except for the VPN, which was terrible to set up.

Thanks for the hint.

I’ll ping from some machine (could be OH2 and a rule) different http-sites or I’m using the Fritz-binding… If there’s no Internet, I’ll tell the Sonoff to do its magic.

1 Like

As you said in post #4, it is a possible solution if openhab is still running but you want something standalone. I maintain that my idea of a custom firmware sonoff is what you need. Burning custom firmware is easy if you already have done it with Tasmota.

You’re right. That way I won’t have to do anything and I could either ping Internet - restarting the router or pinging my pi - restarting OH2.
But to add a bit more metadata - presently I only have one Sonoff on the remote place. So my thinking is:

  • router won’t work => restart it with Sonoff
  • OH2 won’t work => I’ll log on to the VPN of my router and restart my Pi. (I know, if it’s unreachable, I’ll have to find another solution for this)

Even better…
Use the sonoff relay to reset the router
Connect the spare gpio on the sonoff (pin 14 if I remember) to a pi gpio and run a reboot script when the gpio is triggered
A bit of coding involved but it’s all good fun

Regards

1 Like

Reads like fun! And all the tech stuff is already in one place. I’ll try it and hope, the Pow had that the gpio also…