Doing more with a light switch
I like having physical switches and buttons to control lights inside a home, because they are faster, more reliable, and easier to use than other “modern” ways to control “smart” lights.
- Mobile app: You need to take out your phone, open the app, than find the lights you want to control.
- Wireless remote: Way faster to use than a phone, but batteries will run out and the remote can become lost. (Good luck finding it then)
- Voice: I don't like shouting into a machine and hoping it will turn on the lights.
But sometimes I wish a good old light switch could do a bit more, like triggering automation's inside Home Assistant to quickly turn off all the lights.
Using a Smart Switch
WARNING: Installing these kind of devices requires you to work with mains voltage, which can be dangerous if you don't know what you're doing.

These smart switches ticked all the boxes I was looking for:
- Local control (The Sonoff was flashed with ESPHome)
- Allows using the existing switches
- Low power usage
- Able to directly connect with Home Assistant.
Sonoff
The Sonoff come by default with terrible firmware, it lost connection, didn't work well with Home Assistant, didn't allow for a lot of customization. But the device is quick to open and uses an ESP8285. So I quickly created an ESPHome firmware for the device. Which can be found here. This solved all of my issues I had with the device, I have multiple of these devices deployed for over two year and never had any problem with them.
Shelly
A few months ago I found out that a hardware store nearby was selling Shelly devices, after looking at the features set of the device I was interested. Shelly devices allows the user to write scripts on them to alter the function of the device.
One API call caught my interest Shelly.emitEvent(). By the sound of it, it allows the script to send events to other clients that are connected to the device. But after some testing I couldn't get the events to show up inside Home Assistant, so I created a pull request home-assistant/core#135979 which adds event entities for each script the user creates.
After that I could finally re-implement the functionality I had created for the Sonoff inside of a Shelly script. Which can be found here.
What do I use this for
With both the ESPHome firmware and Shelly script, it allows you to add an automation that gets triggered when a switch is quickly turned on and than off (within 250ms). I've personally use it for the following stuff:
- Turn off all the lights on a specific floor.
- Turn off the lights 10 minutes after the last personal leaves.
- Allows you to control the fan inside the room.
Which device is Better
Both devices work absolutely fine, and both have the advantages and disadvantages.
Sonoff:
- + It's a bit cheaper to buy
- - In some sockets it's quite difficult to install the device due to it's size
Shelly:
- + It doesn't need to be physically opened up
- + It a bit smaller than a Sonoff, so easier to install
