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.

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.

An image of two smart switches next to each other, the left one in a Shelly I4, and the right one is a Sonoff MINI R2

These smart switches ticked all the boxes I was looking for:

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:

Which device is Better

Both devices work absolutely fine, and both have the advantages and disadvantages.

Sonoff:

Shelly: