Automating my apartment: Part 1
I wanted to automate a light bulb. Ended up reading RFC 6762.
This is the first part of a series of posts on how I automated parts of my daily routine in my apartment. First steps into the Smart Home world, HomeKit, Thread, Matter, mDNS, and some rabbit holes. Subscribe to be notified of the rest of the story.
This journey started on a usual night at my apartment. I was watching some random Netflix series on my TV, lying on the couch when bedtime came, triggering this nightly routine:
-
Turn off the TV
-
Turn off the floor shade next to it
-
Walk to the bedroom, turning off the main living room light
-
Turn on the bedroom light
-
Go around the bed to turn on the nightstand lamps
-
Close the shades
-
Go back to the bedroom entrance to turn off the bedroom light
-
hygiene time
-
Turn off the nightstand lamps
-
Sleep
Since I spend most of my time thinking about how to automate boring and repetitive tasks, this ritual was a perfect candidate for automation.
Saying “Goodnight” to the Living Room smart speaker should do all of this — stopping at the hygiene step
Alright, let’s do this.
First things first
This automation must follow a simple rule: I don’t want to lose the ability to turn on and off lights with my current analog switches. After some searching, I found Shelly, a Bulgarian company that sells Wi-Fi switches that you can retrofit into any common analog switch.
I bought two cheap Shelly 1, their entry-level device. After some DIY electrician work (double-checking that the circuit breaker was off), I installed the first Shelly behind the main living room light switch. With the circuit breaker up, I installed the Shelly app on my iPhone, configured Shelly to connect to my home Wi-Fi network, and, ta-da 🎉, I can turn on and off my living room light with a click of a button on the app.
I was very pleased with the build quality and reliability of the Shelly devices. At the time, if someone asked me for recommendations, Shelly would be a no-brainer.
Connecting to HomeKit
As my phone and computer are Apple devices, it felt natural to expand this integration to Apple’s smart home ecosystem — HomeKit. However, Shelly does not have support for HomeKit. After some research, I found a custom firmware that adds support for HomeKit but you lose the Shelly Cloud connection feature. As this was not a big deal at the time, I flashed the custom firmware following the easy instructions on the GitHub repo. Another ta-da 🎉, it worked perfectly.
This was my first step into HomeKit.
I immediately liked Apple’s Home app interface better than the Shelly app — I like apps that follow the OS design principles or have a strong design language, none of the previous applies to Shelly.
Although the custom firmware was working, there were a couple of things that were boring me:
-
I couldn’t control the Shelly device when I wasn’t connected to my home network
-
Bugfixes or new features in Shelly’s official firmware need to be implemented in the open-source contributors of the custom firmware, which can take some time or not happen at all
Fortunately, I found HomeBridge, a project that advertises itself as a smart home hub to HomeKit, with lots of plugins to connect non-HomeKit devices to Apple’s ecosystem. It is lightweight, thus it can be installed in a Raspberry Pi or some old Linux box you have.
I reverted the Shelly firmware to the official one, picked up an old Intel NUC I had building up dust, installed HomeBridge and the homebridge-shelly plugin, and, you guessed it, ta-da 🎉!
Automation and Scenes
At this point, I set up the second Shelly on the floor shade next to the TV. When I turn on the main living room light, I also like to turn on the floor shade. With Apple Home’s Automation feature, I could turn on/off both lights simultaneously:
Additionally, I created a Scene in Apple Home that turns off the main living room light, the floor shade, and the TV (an LG which had HomeKit integration out of the box).
I must say that picking up my iPhone and saying “Hey Siri, goodnight” and looking at everything turning off instantly while walking to my bedroom feels good.
In the next part, I discovered Matter and started building a Thread network.