This is an automated archive made by the Lemmit Bot.

The original was posted on /r/homeassistant by /u/Zappa-Fan-1984 on 2026-07-20 01:45:00+00:00.


I’ve used a few Shelly switches in the past for basic smart control of outlets or appliances like ceiling fans. I love that you can configure them to come to whatever state you want after a power outage.

Recently, I set up a pair of Shelly 1 Mini Gen 3’s to control power to my router/modem and HA (separately) at a vacation home out of town. I wanted to be able to cycle power remotely if I ever needed to, but was confronted with the usual problem: you can power off the router, but then you can’t get to the smart switch to power it back on! I’ve flashed sonoff outlet modules with custom ESPHome configs to solve this problem in the past by simply having the outlet wait 10 s after a shutoff and then turn back on. But now I found out Shelly makes it sooooo much more capable!

Shelly introduced a scripting engine for Gen 2+ devices that is a subset of Javascript and runs locally on the switch with no cloud, no internet, no network, no nothing! (Except power of course 😜) Now when there is a power outage, I have my HA box come up with power off, wait a couple minutes, and then power up - to give the network a change to stabilize. And it solved my power-back-on problem- I have a script that turns off the router power, waits 20 seconds, and turns it back on. Now if I need to remotely cycle the router (provided it is working enough to get to the Shelly switch), I just run that script from the Shelly app. It’s awesome!

Looking forward to doing some more smart stuff to monitor the network and automatically cycle power when nothing else works - this has not happened often, but when it does, I’m offline (cameras and the whole works) until I can physically go there.

This has me rethinking how I use Home Assistant and Home Automation entirely. I’ve always thought the best smart device is one that is smart locally and can be remotely controlled as well. I have a couple of projects like that at home that can work locally even when there is no network.

I want to explore more of what can be done with Shelly (or other switches) with local scripts that can be triggered by a local switch or Home Assistant as needed.

Interested to see what creative and useful solutions others have found in this space.

Mostly I just wanted to share how awesome Shelly is as I had no idea how capable these amazing little devices have become in case anyone else can benefit from this.

(Also, I am by no means an expert on Shelly scripting, I barely glanced at the docs and Google AI wrote the script for me. Since I am a Javascript expert, and the code was simple enough and made logical sense to me, I gave it a try! Worked like a charm!)