I don’t know how many times I had routers providing access to the internet that would not reboot in case there are problems. Or sometimes the problem is a Raspberry crashing from time to time that I don’t have time to debug.
If it’s the router, the solution would be replacing the router, but it’s not always so trivial. Sometimes you are forced to use your ISP’s router. Sometimes the technology your ISP is using makes very difficult considering an alternative. Remember: here in Spain they sometimes do not disclose connection details or VoIP configuration details. And if you problem is with a Raspberry, you
First advice: if your problem is a router and if you can replace it, go ahead. And consider buying one that supports OpenWrt.
If not, maybe you already considered some options. Ubiquiti’s mFI mPower used to be a nice option and I even still have one. But they are usually expensive and hard to find nowadays, and (worst of all) the firmware is not maintained at all.
NETIO products seem like a nice alternative but well, the only have three products that allow watchdog. The two most interesting for home use are EoL (NETIO4 and NETIO4All) and the third one is a nice PDU (PowerPDU 4C) so you will need adapters.
You could also consider WiReboot, but it seems it’s not available in Europe and I don’t want to mess with customs.
And if you keep looking, you will see more and more alternatives, most of them complex. Because yes, we have “smart” sockets, but it seems that they do not provide this kind of feature.
So if you want to play a little, you can also consider hacking one of such “smart” socket. There are a lot of models and a lot of them are based on the Tuya platform. Ignore those. Changing the firmware can be easy, or just impossible.
Tasmota and Sonoff S26
WARNING: Be aware that you will be working under your exclusive responsibility, and that by doing this you can be violating some local regulations. I do not take any responsibility or liability for following the instructions. Make sure you know what you are doing, and just do not proceed if you are not sure.
WARNING: Never, ever, tinker or try to flash a device using the serial programming interface while it is connected to MAINS ELECTRICITY (AC power).
WARNING: The Sonoff S26 supports a maximum load of 2200W and 10A. Do not connect any devices exceeding that load and do not connect more than one device at the same time.
So what do you need?
- Read and understand warnings at the start of this section. Read them. It is really important.
- Prepare a Tasmota build with USE_PING enabled (doesn’t come enabled on any official builds) or just get the one I prepared at https://jenkins.juliogonzalez.es/job/tasmota-sonoffS2X-watchdog/lastSuccessfulBuild/artifact/.pio/build/tasmota/firmware.bin (enables USE_PING and USE_TELEGRAM, and disables a lot of stuff that I don’t need, check the details)
- Prepare the software to flash the binary. I recommend tasmotizer
- A FTDI USB to Serial adapter to connect your computer to the Sonoff S26 either by soldering the cables or without soldering.
- Load your build or my build to your Sonoff S26.
- Apply the rule (if you want to check that internet is working, don’t ping the router, ping something on the internet such as 126.96.36.199) from the link above, enable it and then reboot the Sonoff S26.
- Do some testing to verify that everything works.
As you noticed above, my build included USE_TELEGRAM, as I want to get notifications to telegram when the Watchdog is acting:
Rule1 ON system#boot DO Var1 3 ENDON ON system#boot DO tmchatid <MY_TELEGRAM_ID> ENDON ON system#boot DO tmstate 1 ENDON ON system#boot DO tmtoken <TELEGRAM_BOT_API_TOKEN> ON Var1#State>1439 DO Var1 1439 ENDON ON Time#Minute|%var1% DO Ping4 192.168.1.1 ENDON ON Ping#192.168.1.1#Success==0 DO backlog Mult1 3; tmsend Unresponsive router: restarting power; Power1 0; Delay 10; Power1 1 ENDON ON Ping#192.168.1.1#Success>0 DO Var1 3 ENDON
Then I enabled the rule and rebooted:
Rule1 1 Restart 1
Keep in mind <MY_TELEGRAM_ID> is not your alias or your phone number. You can use a bot to get your ID.
And the <TELEGRAM_BOT_API_TOKEN> can easily be retrived from Telegram’s Botfather bot.