Sometimes connectivity problems go away by power cycling a router. It’s a simple but inconvenient solution to a problem that shouldn’t exist, but that didn’t stop [Mike Diamond] from automating it for a few bucks in parts. The three-dollar router rebooter may be a simple device with only one job, but it’s well documented and worth a look.
The device is an ESP8266 board configured to try to reach Google periodically via the local wireless network. If Google cannot be reached, the board assumes a reboot is needed and disconnects the 12 V power supply from the router by using a relay. Then, after a delay, power is re-connected and all of one’s problems are over until the next time it happens. [Mike] used a relay module that has built-in screw terminals and a socket for the ESP8266-01, so it looks like the whole device can be put together without soldering a thing.
While the code for making this happen may sound trivial, [Mike] nevertheless delves into documenting it. It makes a great example of how to implement a simple event-driven finite state machine in a way that’s clear and concise. By structuring the code so that there is a finite number of specific states the device can be in (router power on, router power off, and testing connection) and by defining exactly how and when the device switches between those states, operation and troubleshooting becomes a much more manageable job. Another great example is this IoT Garage Door Opener project. If you’re programming devices that interface to physical things, these techniques are definitely good practice.
How about making it so it can be remotely manually triggered?
If the “remote” part of the trigger means online, it can only be triggered when the internet connectivity is stable, defeating its own purpose…
If it’s locally triggered, pulling the plug and plugging back is free.
Just send rapid high and low temperature settings to your Nest thermostat so the furnace blower glitches the power and resets it….
My router is in another building. Gimmie a button I can push over here to cycle the power over there.
Telnet into the router / send HTTP requests from the ESP to reboot?
Add a second ESP, on a different network, or a cellular-esp tot reset the first ons you meant :p
If you have any old WoL-capable ethernet cards, look at Whack-on-LAN or reset-on-LAN projects. I published one here: https://www.i3detroit.org/reset-on-lan-an-ethernet-aware-remote-reboot-device-from-junkbox-parts/
Would be pretty easy to do with a web site switch – set up a PHP page on a web server that writes to a file: “ON” and “OFF” and have the ESP read that page and respond based on the string found. I do this to manage lights in the house without having to punch a hole in my firewall.
All routers I’ve ever been in, have had a reset/reboot function somewhere in their web interface.
Here in the USA it is very common that a bridge or router is supplied by the ISP as a piece of CPE. My last one had the admin page filtered off from the LAN and WAN interfaces, and could only be reached over the ISPs management vlan channel.
Even my current CPE does not provide a reboot function in the user config area. There is one in the ISP config area, but I am not supposed to have the password to even get to that…
It’s a side effect from the govt handing ISPs monopolies. Can’t change to one with better service because there are no others, and they have no reason at all to provide a router that doesn’t overheat and lock up once a week, or care about giving us a working reboot function :/
I’ve had success at three ISPs to social my way to netops (for reverse dns) and maintenance dude (to find out which fiber conver to buy), and been lucky enough that have my own SPF module in my own router, no CPE for me, demarcation point is the plug.
Sometimes someone will call and ask me if I’m having trouble with the internet, because they cannot access their equipment :) I answer that I offered to send it back but they refused, so if they need access to it, I’m happy to send it.
I agree that the lack of competition in the US is really bad. Is it really so common here to have zero choices that allow providing one’s own equipment?
The largest cable provider in the US is Comcast. A majority of the US is served by Comcast. There are plenty of valid things to complain about them but hey do allow a user to provide their own equipment even if it isn’t their default arrangement anymore and you have to insist.
We don’t have Comcast where I live. We have a much smaller, more local company. I’m not sure if they still allow customers to provide their own modems but they definitely allow us to provide our own routers.
A lot of people in my area go with AT&T for their TV and broadband. It’s been years since I tried them but when I did they only provided modems with built in routers. They sucked. Port forwarding was very buggy. Everyone I know who choses them does so for the TV stations, not the internet. It’s a matter of priorities. You get what you prioritize. I don’t care much about the TV service. After dealing with it for a year I kicked AT&T and their crappy box out of our house.
Time Warner and Cox are sort of big too. Maybe they don’t let you provide your own router? I don’t know. Even if they are that way, their combined coverage area is not the majority of the US.
And then there are the smaller, local DSL and wireless internet providers. They do still exist, it just feels like they don’t with their smaller advertising budgets. The big guys own sports stadiums. They have bulletin boards everywhere and pretty much own the television. That doesn’t mean there is no local, smaller competition to be found if you actively look for it.
Remember, every month you subscribe to a service is a vote for it over it’s competition, if there is any.
“Here in the USA it is very common that a bridge or router is supplied by the ISP as a piece of CPE. ”
CPE? Is that a new way to spell “crap”?
B^)
Can also water plants by hand, yet we love to set up soil moisture monitors/irrigators.
Watering a plant is something we expect to do as part of the investment in owning a plant. Setting up some automation there makes sense.
Rebooting your router when it locks up is a bandaid solution for what is clearly failing hardware.
I bought >$33 of vegetable seedlings last week.
At the checkout counter, I quipped, “That’s a lot of money to produce $2 worth of vegetables!”
The cashier said that was his personal experience as well.
As long as I’m shelling out that kind of money, an automatic watering system is a form of “life insurance for plants”.
B^)
Yeah, but when it’s stopped routing traffic correctly what are the odds the interface is going to be working correctly? In my experience, low.
How about just install OpenWRT?
Also PC based solutions such OPNsense/pfSense or just vanilla FreeBSD work really well.
If you have trouble with your ISP, just switch to community network it anyway gonna be cheaper and stable.
https://en.wikipedia.org/wiki/List_of_wireless_community_networks_by_region
If you have a mod able router like ddwrt you can do the same in software (with the exception of when your router completely locks up)
First put a watchdog script in a persist location on the router (through ssh)
for example: /jffs/watchdog.sh
(Script Contents below)
echo -e “GET http://google.com HTTP/1.0\n\n” | nc google.com 80 > /dev/null 2>&1
if [ $? -eq 0 ]; then
echo “Online”
else
reboot
fi
THEN edit cron to have this command
(/10 means every 10 minutes)
/10 * * * * root sh /jffs/watchdog.sh
Or…. If the problem takes more than a day to crop up, setup the router to reboot every 24h at a time you know it won’t be/will least likely be used. If your router doesn’t have that option, get a 24 hour mechanical outlet timer and donut that way.
Alternatively, get a better router that doesn’t lock up.
Got any recommendations for decent routers? Trying not to go the whole dedicated AP setup.
I would suggest any of the $100+ Netgear or Linksys routers. Once you get up in that range you’re buying a bit of over kill for most homes, but that overkill us what keeps them running stable.
Skip over Linksys as they have bought up by Belkin since 2013. They are meh these days.
Look at what hardware are supported by newer version of OpenWRT or freshtomato.
FYI https://www.smallnetbuilder.com is where you want to go for router reviews etc.
if others suggestions of OpenWRT doesn’t match your needs (i.e. you really need complex firewall rules, multi-WAN, easy tunneling to IPv6 over 6in4, as well as snort to detect intrusions and adjust your firewall rules, etc), try pfSense (I don’t think I can go back to any thing now that I’ve gone pfSense).
I ended up with a script (on a router running dd-wrt firmware that never quite locked up, it just stopped routing) that had a list of 12 sites, took minutes modulo 12 and pinged one of the sites from the list – once all the sites were pinged and I got less than 5 replies back -> software reboot (sw watchdog thingy). Worked like a charm, it was rebooting 3 or 4 times a week and if I couldn’t connect to it (only caught it once from work) all I had to do was wait until next quarter of an hour and try again.
I did this too, but I used a Raspberry PI as the testing part.
https://hackaday.io/project/168150-reboot-o-matic
Just buy a better router.
Everybody says that, just like everybody says “Why use a microcontroller when you can just use a 555?”
My crap router needs rebooted so often I may as well use a 555 to do it…
Accept this is definitely a situation where replacing the device makes sense. If your router is having trouble staying connected to the internet, and you have to power cycle it more than once a month, then it’s time to start looking at a new one in the near future. It’s clearly having an intermittent failure that is almost certainly going to get worse sooner than later.
Not trying to brag, but I haven’t had to power cycle my router since the day I bought it 2 years ago. I paid triple digits for it, and for that extra cash it hasn’t failed. Routers are one of those things you should be buying as expensive as you can afford, or else expect to have to do nonsense like power cycling.
Until you receive one from the ISP that crashes.
If it is your connection endpoint that crashes, there is not much to do about it apart from this.
You can replace a DSL modem most of the time, fiber is also possible, ethernet is easy, but cable (as in DOCSIS) is another topic…
We have “Routerfreiheit” = the freedoms to choose your own router since the 1st of August 2016 by law in Germany.
A company called “Fritz” (not kidding) makes high-quality DOCSIS 3.1 compatible routers
https://avm.de/produkte/fritzbox/fritzbox-6591-cable/
Most providers let you buy your own DOCSIS modem so long as it’s an approved model, unless you have VOIP on the service too, for some reason.
Exactly. ISP box is the problem, quite often.
For the VoIP, I think the problem are the extra certifications for emergency calling etc. We could use our own CPE but then we had to sign something that they would not be liable if our self chosen CPE fails while dialing an emergency number. Apart from that it is just SIP so no real incompatibility to expect.
With the exception of my very first broadband ISP over 20 years ago, I’ve never had service from a cable ISP that didn’t allow you to bring your own CPE. Good DOCSIS modems are cheap (I bought my current SB6190 for $49 on Amazon), and DD-WRT/Tomato-capable routers are just as prevalent. It has always been the same story: buy modem, call ISP, provide RF MAC, return old modem for it to be removed from the bill.
@mathman,
So, it is not lying when you tell people that your home network is on the “Fritz”.
B^)
My ISP can’t force any hardware on me. I can use whatever I want including my own modem. Pretty sure the US government put an end to that kind of nonsense when it told AT&T that it couldn’t force people to use their phones only.
I have routers (running Tomato firmware) from $30-$70 and none of them requires a reboot. Most consumer routers (excluding combo modem/routers) are running some kind of embedded linux kernel anyway. Why would one need to reboot them?
Regular power cycling can cause more stress to the components such as caps or wall warts.
Adding to this, a better router doesn’t have to be expensive.
I bought a Linksys EA6900 for $30 and installed AdvancedTomato (ddwrt is also popular) and all my problems went away. I also gained a nice web interface and features such as ad blocking, network printing, remote access to my local network through a VPN, you name it.
https://advancedtomato.com/
100%, it doesn’t have to be expensive!
I have a total of $40 in my OPNSense router, an older i5 SFF that actually uses less power than the Netgear R8500 it replaced (which is now a WiFi AP only). You can get these SFFs for peanuts on eBay, since they’re usually just thin clients or receptionist workstations liquidated during a business upgrade. Recycling!
Doesn’t work when we are mandated by the internet provider to use their router and nothing else. Even worse when they refuse to supply a list of compatible modems.
– Someone in Australia who has a crummy Telstra supplied NBN modem that drops connections once an hour.
So many people here coming up with novel ways to deal with power cycling locked up or non connecting routers. All of those solutions are just temporary bandaid “fixes” for failing hardware.
I get that this is hackaday and we embrace novel and unexpected solutions for all sorts of problems, but there are only two ways to properly correct a malfunctioning router. 1, actually fix it, as in find the problem and repair the fault/alter the software so it never happens again. Or 2, if you can’t repair it, replace it.
I understand option 2 means throwing it away and creating more ewaste, but until it’s actually fixed, it already is ewaste.
Now, as an insurance measure for future issues, the device depicted in the article is an excellent idea. The only addition I would suggest is a few extra lines of code to email the admin/owner after a connection has been reestablished on the details of the event. IE, when and how many cycles were needed, along with a counter for the total events since the device was installed.
Theoretically I can use any DSL modem I want. But in practice all of them I’ve tried fail to work *here* despite working fine at the ISP’s office. I know what the problem is, there’s some crappy wire between here and there. When it rains my connection quality drops. One time it cut out completely and stayed off after a storm. What happened was the wire pair I was on had shorted out. Their “fix” was to switch me to another pair in the same iffy cable instead of finding the bad section of cable and replacing it.
Eeeer, there’s a 3rd option. First you create a problem (router running torrent client that downloads stuff to USB disk, etc) then you come up with the fix (script or relay) and all is well again. I ended up with a watchdog script, a friend of mine with exact same hw/fw ended up with uptime of 500+ days. We were both happy with it.
I have no need to reboot my router running Tomato/FreshTomato firmware. How often do you reboot your Linux machine outside of upgrades?
When there is a connection problem, it is usually the cable modem/ISP issues.
ISP worked on their network – a DHCP renew from a router script would fix it.
ISP change their channel allocations, but they “forgot” to reboot cable modem remotely. – need a modem reboot/power cycle.
My DCM476 does not have an URL for reboot like my old modem, so it requires a power cycle.
Not rebooting any Linux machine. Call me a Windows cretin but windows 10 works just fine for me. I have a Windows 10 machine that runs 24/7 as a plex/file server, it only reboots for updates, and even then all the updates so far have not cussed any problems and the machine comes back online within about 10min. I don’t run Linux save for some raspberry pis I work with.
Now my primary work/gaming PC does occasionally crash/blue screen. But I am often running beta software and questionable third party drivers in order to do things Windows and my rigs hardware just weren’t meant to do so all of those crashes were my fault.
“Repairing” or “replacing” hardware owned by someone else is a crime, either tampering for theft of service, or stealing.
You really should qualify your advice to only the tiny fraction of people that own their own CPE/router.
I’m sorry, I live in the US, where I don’t have to use whatever crappy router/modem my isp offers. There don’t we all feel better now?
I’d simply use a 10$ Tasmota WiFi Plug… but sure. There is no fun in using pre-built stuff ;)
A few words regarding “use a better Router”. Some People do not have a choice. We have a de-jure “Router freedom” in the EU which ensures that Providers can’t regulate which router you use (as long as yours complies to standards). But if you have a special type of internet connection which uses proprietary technology, then there is a de-facto monopoly.
I have such a connection where i get 3Mbit/s via DSL (over the POTS copper wire) and up to 25mbit/s via 4G. It’s transparent behind the router. So if the weather is good and there is no load on the 4G cell it’s fine. However the router hardware and software is crap and it also stops routing sometimes. I have no choice but take this router model, because no other Model is compatible with the Hybrid Aggregation Gateway that my provider runs to bring 4G and copper data streams together upstream or split them in the downstream.
“However the router hardware and software is crap and it also stops routing sometimes.”
Which ISP is it?
I worked on a similar router using MultiPathTCP that would aggregate both DSL and 4G.
There is now a fork of OpenWRT that does it:
https://www.openmptcprouter.com/
Otherwise, I still have to work on some VDSL modem liberation project, one OpenWRT told me to have vectorisation working for DSL you needed to download a .bin file from somewhere, because there was a patent on this feature.
Let’s be honest, there are few OpenWRT modems with open source xDSL support.
You usually must have ISP’s router as it provides VoIP and IPTV connectivity which would be nightmare for ISP to support if you used your own router for it. Their router is (usually) set up to be autoconfigured, it connects to DSLAM, sends MAC address and then configuration server sends config for specific user and it just works. That’s why ISPs don’t want to support thousands of different routers.
But there is a catch, you can use their router/modem for ISP connectivity, let it do it’s stuff except you offload internet connection handling. You ask ISP to switch internet connection from routing to bridge mode. VoIP and IPTV keep working normally, but now instead of routed internet connection you have layer2 bridge that you connect to your quality router of choice and use it to initiate PPPoE (or other PPP connection, depending on ISP), you handle NAT, DHCP, WiFi … everything else with quality piece of hardware instead some crappy all-in-one 20$ device. That way ISP’s router (now modem) will be used just as media converter and VoIP/IPTV gateway which will reduce it’s load significantly and it will perform much better. Your workhorse router of choice will handle internet connection. This will in many cases make home connection much more stable and reliable.
My brother has a smart plug on his router.
The router itself is locked in a location that is in accessible to his kids.
His parenting nuclear option is “Alexa, turn off internet.”
That is an excellent idea!
I have a bunch of Sonoff power switches and would love to keep using the Sonoff-Tasmota open source firmware (with all the MQTT/web server/OTA update fun) but also add the capability to have the thing reboot my router…Pointers to how to do this would be appreciated. (I s’pose I could start learning the Sonoff-Tasmota codebase. :/ )
Also this article is kinda repeat https://hackaday.com/2018/01/31/router-rebooter-eliminates-hassles/
answering my own question with an RTFM https://tasmota.github.io/docs/Rules/#watchdog-for-a-wifi-router
I was having the exact same problem and tried to approach it the same way, but then I realized, “what about updating the firmware?”. Worked like a charm and spared me a 555 ;)
The logic is very basic and should suffer from both false positives and false negatives. It tests internet connectivity not by trying to reach google but by a single dns request. Also doesn’t check if wifi is still up, so a disconnected esp would trigger a router reboot instead of a reconnect to the wifi. Also cutting the power for 30 seconds feels like sending a sloth to flip a switch!
The Sonoff Basic brings the ESP, power regulator, relay, and case for around 3 bucks if you are lazy ;)
Better solution. Fix the problem.
So far every router Iv’e had was linux based and has some telnet/ssh access.
Problems usually are related with incorrect tcp/nat settings for low memory embeded hardware or to low nsr configuration.
Script in expect and fix the problem:
#!/usr/bin/expect
set timeout 2
set remote_server 192.168.1.1
set my_user_id admin
set my_password admin
set my_command0 “adsl configure –mod d –lpair i –trellis on –snr 120 –bitswap off –sesdrop on –sra off –i24k on –CoMinMgn on –phyReXmt on”
set my_command1 “echo 4096 > /proc/sys/net/ipv4/netfilter/ip_conntrack_max”
set my_command2 “echo 300 > /proc/sys/net/ipv4/netfilter/ip_conntrack_generic_timeout”
set my_command3 “echo 5 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_close”
set my_command4 “echo 30 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_close_wait”
set my_command5 “echo 7200> /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_established”
set my_command6 “echo 120 > /proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_fin_wait”
set my_command7 “echo 120 >/proc/sys/net/ipv4/netfilter/ip_conntrack_tcp_timeout_time_wait”
set my_command8 “echo 30 > /proc/sys/net/ipv4/netfilter/ip_conntrack_udp_timeout”
set my_command9 “echo 3600 > /proc/sys/net/ipv4/tcp_keepalive_time”
set my_command10 “echo 5 > /proc/sys/net/ipv4/tcp_keepalive_probes”
set my_command11 “echo 1 > /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses”
set my_command12 “echo 0 > /proc/sys/net/ipv4/tcp_ecn”
set my_command13 “echo 75 > /proc/sys/net/ipv4/tcp_keepalive_intvl”
set my_command14 “echo 120 > /proc/sys/net/ipv4/tcp_fin_timeout”
set my_command15 “echo 1 >/proc/sys/net/ipv4/ip_no_pmtu_disc”
set my_command16 “echo 0 > /proc/sys/net/ipv4/tcp_low_latency”
set my_command17 “echo 4000 > /proc/sys/net/core/netdev_max_backlog”
set my_command18 “echo 16384 > /proc/sys/net/ipv4/tcp_max_syn_backlog”
send “$my_command0\r”
expect “#”
send “$my_command1\r”
expect “#”
send “$my_command2\r”
expect “#”
send “$my_command3\r”
expect “#”
send “$my_command4\r”
expect “#”
send “$my_command5\r”
expect “#”
send “$my_command6\r”
expect “#”
send “$my_command7\r”
expect “#”
send “$my_command8\r”
expect “#”
send “$my_command9\r”
expect “#”
send “$my_command10\r”
expect “#”
send “$my_command11\r”
expect “#”
send “$my_command12\r”
expect “#”
send “$my_command13\r”
expect “#”
send “$my_command14\r”
expect “#”
send “$my_command15\r”
expect “#”
send “$my_command16\r”
expect “#”
send “$my_command17\r”
expect “#”
send “$my_command18\r”
expect “#”
send “sysinfo\r”
expect “#”
send “df\r”
expect “#”
send “ifconfig br0 mtu 1500\r”
expect “#”
# txqueuelen 42
#send “ifconfig eth0 txqueuelen 84 mtu 1500\r”
send “ifconfig eth0 txqueuelen 840 mtu 1500\r”
expect “#”
#send “ifconfig nas_0_8_35 txqueuelen 23 mtu 1492\r”
send “ifconfig nas_0_8_35 txqueuelen 46 mtu 1492\r”
expect “#”
#send “ifconfig nas_8_35 txqueuelen 23 mtu 1492\r”
send “ifconfig nas_8_35 txqueuelen 46 mtu 1492\r”
expect “#”
send “ifconfig\r”
expect “#”
send “exit\r”
expect “>”
send “logout\r”
#expect “>”
Really crude but fix the problem.
I thought the days of needing to reboot routers were behind us. I have a $50 ubnt router thats been up for years….
This. Running an ER-X here and an AP AC Lite, total cost around $100-$120 give or take. It Just Works(tm). Haven’t needed to reboot either for troubleshooting reasons since I bought them over 3 years ago. And if you are a HaD reader, setup is a breeze for these. In fact the ER-X is likely the most complex to set up and for basic home routing duties the built in wizard is all you need. The Ubiquiti AP’s have a mobile app that will get them going if you don’t opt for a separate controller (not required but recommended).
In terms of connectivity, I would check for both something big and public like Google, but also the ISP’s portal. If you can get to the ISP but not Google, it’s likely one of their faults.
Advanced project: put photoreceptors over the blinkenlights on the cable modem to tell whether it’s fully functional.
SHEESH ! collective group of rube goldberg contestants here… smh…
Solution used – successfully & simply – is COTS “auto ping” power strips.
Sends periodic pings to the IP device in question, if it doesn’t respond, then cycle power.
The specific parameters are adjustable (ie. # of times before reset, wait times, etc).
IF you have to reboot your router, your router is crap. Buy at least a $100 router, everything else is just well, a crap IoT device pretending to be a router.
this is another IoST [ Internet of S**ty Things ] project, designed to fill a need that should not be there. My router has a crond scheduler that can reboot itself, a hardware watchdog, that can reboot itself, and other things that “real” routers should have. If you can not ssh into your router, and use gcc, you do not have a router, you have a IoST device.
Also, have a backup router for when someone is dumb enough to run a compiler on your router.
Uh, that is not going to break the router. Do you know how a compiler works, and what it does? How else are you going to compile iptables, or other useful utilities that are not included in the base distro?
don’t worry, if you pay 6.99/Mo, I will secure your router. You don’t need the admin password, you don’t even need access. Heck, you can rent a computer from me for only 12.99/Mo, no admin access needed/required.
it only has 2 knobs, and you shake it to do a system restore.
Right, the only possible option is to bog down your router for hours, obviously nobody else is using it. Do you know how compilers work?
I can use ipkg to get precompiled packages and optware for my consumer router running Tomato firmware. No need to compile anything these days.
It has a pretty weak 800MHz dual core ARM and 200MB of free ram, but it doesn’t have much of a filesystem out of its firmware. My old netbook would probably beat it on compile because it has a SATA HDD. :P
I was compiling some ARM code on an Atom N270 netbook the other month, was expecting to tie it up all afternoon, but was pleasantly surprised when it only took half an hour.
Exactly. My advice has always been to pay atleast $100 and to avoid off brands unless you really trust the manufacturer.
I need something like this for a difficult IP camera that tends to go unresponsive on me at random times and I never notice until I need to view it. It has USB power, and I know there’s a SONOFF thing out there that can switch USB power but I don’t think I can flash it with my own firmware because it doesn’t use an ESP chip.
A friend of mine built one of these for his remote ham-radio site, it reboots the router and the fiber converter and all of his hamradio gear if it looses the contact with the Internetz.
Kind of important for his remote site that is only acessible with snowmobile or helicopter in the winter.
I think there is a commersial variant to buy aimed at ham-radio remotesites.
i am of both minds about replacing the router. I had a switch (unmanaged) that needed periodic reboots, and thought about building one of these…but I realized I was being dumb and i bought a new switch (this time paying $120 for netgear instead of $35 for nameless).
but i also have a cablemodem that needs rebooting every now and then. i’m not entirely sure where the failure is, if it’s local or remote. but if i don’t do anything, it typically comes back on its own in about 6 minutes (5 minutes to give up on the old connection, 1 minute to establish a new one), while if i manually power cycle it, it’s back in about a minute. so it’s not necessarily the case that the cablemodem is faulty, maybe it’s working as designed.
I did this myself like 10 years ago with a light sensor and micro servo. If the light sensor didn’t detect light from the router’s “internet” light then it would wait 30 seconds, the servo would shut the power switch off, wait 30 seconds then turn it back on then wait 5 minutes before resuming monitoring the light.
How is the relay configured for a fail back situation, leaving power on or off?