Restart Modem/Router with a smart plug if internet is down

in #hive-10249621 days ago (edited)

The best part of having a smart home is the ability to monitor the house remotely. Especially, if you have a little anxiety, like me. ("Did I lock the door?", "What about the windows?", etc. These questions are easy to answer.)

This comes with a requirement though, you need a stable internet connection.

I have a 250 Mbit/s internet at home, which is quite okay for personal use. However, the modem provided by Ziggo is not the best, it goes down from time to time and needs a manual restart.

Imagine you're on your summer holiday, a manual reboot is not really an option. When I try to think a solution for that, the first thing that came into my mind that I can use a smart plug for the modem, and activate/deactivate it if the internet link is down.

script-logs.png

I have a couple of smart plugs (IKEA, Heiman, Hue, etc.) that I can use with my Zigbee gateway, Conbee. Since they're controlled in Zigbee protocol, it can be controlled on localhost. I have also a couple of Raspberry Pi's hanging around so I can use one of them to run a Python script which:

  • checks if the internet is down
  • If it's down, deactivate the plug, wait 60 seconds, activate again.

Using a couple of extra libraries, it was quite easy to implement something like that. Here, is the prototype implementation that I've been experimenting at the moment.

This script can be triggered via a crontab entry in a periodic interval. (I don't want a long-running script to keep things simple and stateless.) I execute it in every hour via CRON.

Screen Shot 2020-07-24 at 17.39.47.png

You have any backup plans for cases like that in your home? "High-availability" on Smart homes should be a thing in the near future. :)

Sort:  

If you DIY tomato router, you don't have to use a RPI. You can just have the router restart itself.

https://advancedtomato.com/

You can also hack your router to do so much more regarding environment changes. As well, as prioritization of data on the fly.

Looks like a great project, thanks!

Tomato blogpost inbound, right? LOL

I have picked your post for my daily hive voting initiative, Keep it up and Hive On!!

Imagine programming an auto-restart rather than buying a good ol' new router. Get an USG or hEX @emrebeyler!

You're right: it's good to be smart about all aspects of your life.
How's the lockdown going?

"The best part of having a smart home is the ability to monitor the house remotely."

Suspicious girlfriends, hackers, and deep state agree 100%. You're making a lot of people happy with that.

All my gadgets don't have access to my WIFI network. They connect and report to a HUB which communicates with my phone in a secure way. (end-to-end encryption)

Of course, if you go into the "deep-state" shit, there is no %100 security. You're being tracked by using a laptop/pc/mobile device. You're making "deep-state, "hackers", "stalkers" happy. :)

easy and rocking ;)

I don't today... but I will soon now that I've seen you doing it :D

My router is solid, but the modem gets crabby from time to time. A solution should be pretty simple

Thanks for the inspiration! I feel kind of silly that this hadn't already occurred to me. Well done

What do you have in your mind? :)

I've got a spare WiFI plug flashed to run MQTT around here somewhere. Plug the modem into that, setup a script on the Pi that runs all the home automation stuffs to check for external connectivity, after x minutes of no external connectivity, power cycle the modem. This will likely be schedule by cron, but managed within OpenHAB since that's where the mqtt bridge is managed

All the times that I've rushed back to see if it's the frickin' modem again, power cycled it, and sat there watching the lights blink.... and it never occurred to me that I could just monitor connectivity and bounce the modem. It's nearly humiliating 😂

Wow! I did not realize what was available out there. Thanks

Here on Hive you can learn so much! I had no idea you could do this!