Automating Router Reboots with Xiaomi Plug

I’ve been dealing with frequent internet outages lately, and it’s been quite the hassle to manually unplug and replug my modem each time. After some research, I decided to automate this process using my Xiaomi plug, which is already integrated into my Home Assistant setup. Here’s how I did it and how you can too!

First, I set up a simple automation that pings my router every 5 minutes. If the connection is down for more than 5 minutes, the Xiaomi plug turns off, giving the modem a quick reboot. After a short wait, the plug turns back on, and the modem reconnects. This has been a lifesaver, especially during late-night outages when I don’t want to get out of bed!

The setup was straightforward:

  • Use the ping component to monitor the router’s IP (I used 8.8.8.8 as a backup check).
  • Configure an automation that triggers when the ping fails consistently.
  • Integrate the Xiaomi plug to control the modem’s power.

I also added some logging to track when the automation triggers, which has been helpful for troubleshooting. If anyone has tips for improving this setup or alternative methods, I’d love to hear them! It’s amazing how a bit of automation can make such a big difference in daily life. :blush: