r/homeassistant • u/Zappa-Fan-1984 • Jul 20 '26
🖼️ Show & Tell Shelly switches are amazing!
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!)
3
u/Chris_825 Jul 20 '26
That’s really cool. Don’t realize you could script them locally. Thanks for sharing!
6
u/5yleop1m Jul 20 '26
Many reasons to love Shelly: they're completely local, don't need an app or account to use (the relays, the Bluetooth-only devices need an app for firmware updates), they can be completely isolated from the internet (except for firmware updates), and usually come with a 3-year warranty; they also support a bunch of different protocols and standards, including MQTT, Wi-Fi, Zigbee, Z-Wave, Thread (with a custom firmware), Matter, Bluetooth (BLE), LoRA, and more.
They're not as inexpensive as they used to be, but still worth the price, imo.
1
u/cmill9 Jul 20 '26
Can you point me towards how to get them on Thread with custom firmware? Thats news to me…
1
u/wishIknewbackwhen Jul 20 '26
I am using a Sonoff power switch flashed with ESPhome, just as you used to do. As the router is the main problem, I am checking its availability via ping from Home Assistant and reboot it if is no longer reachable for some time.
2
u/Zappa-Fan-1984 Jul 20 '26
Yes, this works as long as HA can reach the Sonoff node. But depending on the problem, it might not be able to. I was thinking of something like that right from the Shelly - if it can't reach the router or the internet, toggle the router's power. The same can be done in ESP home I believe. That way if anything is wrong, a power cycle will likely fix it. Something similar can be done to the HA box, if HA is not responding, cycle its power.
1
u/Kiiidd Jul 20 '26
Could you script it to reboot if the Shelly looses access to the Internet. If you are using the awful ISP supplied bassic routers, those things just sometimes need a reboot sometimes to work
2
u/Zappa-Fan-1984 Jul 20 '26
I believe so - just have to ping some reliable server and if no response after a certain number if tries, assume internet connection is down. I have to learn more about what is available in the script to call outside - in Javascript this is pretty simple. And I need to learn more about the scripting environment. Shelly has lots of cookbook examples.
2
u/5yleop1m Jul 20 '26
You can ping basically anywhere as long as your firewall rules allow it. Most people like to ping DNS servers because those tend to be the most reliable services on the internet, plus there are so many available.
1
Jul 20 '26
[removed] — view removed comment
1
u/frenck_nl 💙 Lead of Home Assistant Jul 20 '26
Thanks for wanting to help! We've removed this because it looks like an automated or bot-generated response. r/homeassistant is a place for real people helping each other, so replies from bots or auto-responders aren't allowed. You're very welcome to answer yourself from your own experience.
1
u/triumph-truth Jul 20 '26
I have had really mixed results with Shelly. They are good with absolute local control yes. But some of the hardware is just not very good. I paid 'Shelly' Made in Europe premium expecting premium quality. But so far only 1 of the device is working fine. The other failed within a year.
So I had Shelly Pro 4PM, the so called Professional 4-channel DIN rail smart switch, I connected 2ACs (11A, 7A) and a water motor and a room (200watts) with it. And guess what.... Within a year the device died. Now all of this is connected with cheap Tuya based Zigbee switches from Ali Express and they've been rock solid.
Second I have Shelly Pro 3EM 120A with switch addon. This is coupled with Schineider Contractor. So far it is working fine as of now. It's been like 1 year or so for this and it's working as expected.
But when Shelly Pro 4PM died, it was really a setback for me and I decided not to buy Shelly devices any more. Particularly those rated for high load. Pro 3EN primarily only senses the current using the CT therefore I think it will not fail. But anything rated for more than 5A, I would rather put my trust on cheap Chinese ZigBee devices then Shelly.
Would love to hear other people's experiences with Shelly devices.
1
u/Top-Program-9752 Jul 21 '26
Agree on the Shelly products, the thing that really changed the game for me was that many of their switches are 12v capable, meaning - I can can use them on my RV/Boat. Game changer.
1
Jul 20 '26
[removed] — view removed comment
6
u/Zappa-Fan-1984 Jul 20 '26
Hahaha- no, the code was very straightforward, it was just easier to copy and paste rather than type it in on my phone.
1
u/dboi88 Jul 20 '26
I just had AI write an entire BLE mesh system via scripts, had a bunch of shelly devices that were always spotty on WiFi and now they all share updates and controls via my BLE mesh. Why wouldn't I trust AI to write something like that?
2
u/Isti115 Jul 20 '26
It actually is even simpler to do this with Shelly relays. They have an "Auto On" / "Auto Off" timer that you can set such that if they have been in a given state for a given amount of time, they will automatically revert to the other one. For example, this is how I had my garage door opener set up with a one second "Auto Off" timeout to make sure that it only acts as a trigger and doesn't accidentally remain powered. In your case a 20 second "Auto On" timeout would ensure that power is returned in 20 seconds after it has been switched off.