My Smart Home Experience: Home Assistant on a Raspberry Pi, Ecosystem and Device Decisions, and Programming Automations
After returning from California to my home in Shenzhen to continue with my summer holiday, I noticed a few issues with our home that slightly my daily life somewhat unpleasant. First, it was summer, temperatures average around 30–31 °C, making it uncomfortable indoors without AC. If I arrive home and the AC isn’t already on, I have to wait for the room to cool down. I also don’t like how the AC remotes often disappear into random rooms, especially as my family frequently moves the controllers. I realized it would be much more convenient to control air conditioners from my phone and have them turn on automatically before I get home.
To solve these problems, at first, I only purchased some AC controller sticks that send infrared signals to the AC. That worked fine, although I had another issue. It was too much of a hassle to walk to my room's entrance and turn light switches on or off, when I already lay in bed and want to sleep or when I wake up in the midnight/morning. I thought, perhaps, it was the perfect timing to upgrade our home to “smart mode.”
I purchased a Raspberry Pi, and used the official Imager tool to install Home Assistant OS on a SD card. Home Assistant OS seemed the de-facto choice to me because of its ability to integrate different smart home ecosystems, which is extra important because Chinese and Western smart home devices and apps are using protocols all over the place (which is, not a good thing, but taking the fact that many low-cost devices exist because they support Xiaomi's Bluetooth protocol, that seemed like a good tradeoff).
There was an issue though. Due to internet circumstances in China, such as the Great Firewall, Home Assistant OS basically took forever to download everything, whether it's the initial installation or the community plugins. It needed to pull images from Docker Hub or download repositories from GitHub and was really slow.
I started to consider whether I can install a proxy service on my Raspberry Pi and found that Home Assistant OS does not support installing software that runs separately from its core OS. To run any third-party software, they must be in the plugin format. So I created a repository, trying to create my own proxy setup. And I chose Mihomo as the proxy. It didn't work, though. Considering that it was really a headache for this plugin style configuration, I decided that I should switch to the Docker version of Home Assistant on a standalone Linux system, e.g., Ubuntu.
The only trade-off of this decision was that the Home Assistant OS version had built-in Matter server support. Matter is a very standardized, widely adopted smart home protocol, especially in the modern world. But still, there are methods to set up a Matter server on a standalone Linux system. And finally, I was able to set up a VPN transparent proxy service so I can access a faster Internet unobstructed by the firewall.
By the way, I haven’t mentioned much about protocol choices. To my knowledge, some of the most common protocols in home automation are Apple HomeKit, Matter, and Zigbee. HomeKit is Apple’s protocol, primarily Wi-Fi or Thread-based, and designed to prioritize local communication, which was very appealing to me because of its privacy and speed benefits. It has the best support for the Apple Home app. However, for remote access and automation, an Apple Home Hub device is required, which means necessary purchases of HomePods or even Apple TVs. I didn't want to purchase multiple Apple devices, which would increase the cost by quite a bit, and it felt exclusive to Android users (i.e., my mom). Matter is a relatively new, open-source, IP-based standard, supported by Apple, Google, Amazon, and others. I love how it's standardized, open-source, and compatible. Matter runs over Ethernet, Wi-Fi, and Thread and supports both local and cloud control. Unfortunately, almost none of the devices sold in Chinese smart home market adapts this protocol, and those that do have much higher price tags. Zigbee is a widely adopted, low-power mesh protocol that operates on the 2.4 GHz band, independent of Wi-Fi. Unlike HomeKit or Matter (which are IP-based), Zigbee devices require a dedicated hub or coordinator, like a smart home bridge, to connect to the home network. It is efficient and has low-energy footage. A well-known reseller that focuses on Zigbee devices is Tuya. However, considering its limitations in range (and the need to purchase edge nodes/signal extenders), I doubted if it's suitable for our home.
To try out ZigBee for fun and test it's signal and networking, I also bought a ZigBee USB dongle and several ZigBee thermometers that measure temperature and humidity, allowing them to send data wirelessly to the Raspberry Pi. Since my home has two floors and covers about 200 square meters, I noticed the ZigBee signal is weak between floors when the Raspberry Pi is on the first floor and some devices are on the second, and I gave up with ZigBee.
I ultimately decided to go with Xiaomi’s smart home ecosystem. I definitely didn't like it at first: it isn’t open-source, is somewhat cloud-dependent by default (though nearly full local control is possible with their gateway), and I have concerns about privacy with many Chinese tech companies. With that being said, I found it hard to ignore Xiaomi’s advantages. The Xiaomi ecosystem is extremely popular in China, with broad device support from both official and third-party manufacturers. In fact, almost the entire smart home industry here is built around Xiaomi compatibility. I also discovered that the official Xiaomi team provides a HACS add-on for Home Assistant, allowing you to connect your Xiaomi account directly. (Trade-off: While this integration is convenient and likely part of Xiaomi’s product/business strategy, it does mean that Xiaomi could revoke access to the add-on at any time.) Also on the plus side, Xiaomi devices just work remotely if you have Wi-Fi, and just work locally if you buy their gateway (unlike Apple HomeKit for example which requires you to purchase a HomePod or an Apple TV.) No complicated configuration needed. The Mi Home app is also beginner-friendly, which is great for my family.
I purchased Xiaomi’s Bluetooth gateway, which uses a custom, proprietary Bluetooth mesh protocol to communicate with their devices. The system works well overall. I also experimented with Home Assistant’s HomeKit integration and bridge, but found it unreliable—devices often go offline or experience lag, likely due to iCloud sync issues. But for now, the Xiaomi ecosystem provides the most practical solution for my needs.
Light Switches
Now it was time to consider which smart light switches to purchase. Oh, let me briefly explain why I focused on smart switches instead of other smart lighting solutions. Generally, the most popular options for smart lighting are smart bulbs and smart switches. There are other solutions, like smart relays or modules you can embed inside electrical boxes. However, I chose smart switches for several reasons.
- They are relatively straightforward to install—an electrician can replace existing traditional switches without needing to change every light bulb in the house, which would be much more work given how many bulbs we have.
- The old mechanical switches in my home were quite dated, so this was a good opportunity to modernize their appearance.
- Smart switches are much less expensive than replacing all bulbs with smart bulbs.
- Most importantly, many smart switches allow for custom key functions, such as syncing multiple devices, controlling lights in different rooms, or setting up programmable scenes, making them much more flexible and extensible.
While searching for suitable products, I encountered an important limitation. My home interior was built over 12 years ago, and the wiring for most switches does not include a neutral line (also known as the “zero line”). For traditional mechanical switches, only the live and load lines are present, which is sufficient to simply open or close the circuit. But smart switches need a small amount of power even when the light is off for communication and control, which usually requires a neutral line* (I also tried using the capacitor method, which did not work well.) Because most of my home lacks a neutral, I had to specifically look for smart switches that work without it. This significantly narrowed my options and ruled out some of the more advanced models, like those with touchscreens and customizable displays.
TODO
Life has to continue anyway, so does my search of light switches. I browsed a variety of switches compatible with no-neutral setups. The switches differed in design, features, and feel. Being careful about my choices, I bought two or three units of each shortlisted switch and had our electrician install them in different rooms to test them thoroughly. My family and I evaluated each one, paying attention to things like tactile feedback, how quickly the switch rebounded after pressing, and, importantly, how responsive it was. Some switches turned the lights on or off immediately when pressed, while others only triggered when the button was released, and I strongly preferred the immediate response.
After testing, I settled on a model that balanced cost, functionality, and appearance. The final switch offered multiple advanced features: each button could be set to different modes, including scene mode (to activate smart scenes), remote mode (to control devices elsewhere instead of the local circuit), and even a special mode that I guess is built for programmers like me.
More about the modes
Speaking of which, the switches had impressive RGB indicator lights—eight different colors, customizable independently for the “on” and “off” states. I could also programmatically change the switch’s indicator light color and behavior.
We ended up purchasing 40 smart switches, all with 4 keys each. You might wonder why I chose 4-key models (even for locations where the original switch only had 2 or 3 keys). My reasoning was that extra keys provide more customization possibilities. Keys that aren’t wired to a circuit can still be programmed for various functions like controlling other devices, triggering smart scenes, or running automations.
We hired an electrician to handle the installation. Replacing every switch took about four days of afternoon and evening work. I manually enrolled all switches into the Xiaomi home app and they automatically propregated into Home Assistant.
Automations
After completing all the hardware setup and installations, I finally started working with Home Assistant. The Xiaomi integration proved to be extremely powerful—it exposed every device property, including custom or third-party attributes. For example, I could control the RGB indicator lights on the switches directly in Home Assistant, even though those controls were specific to the switch manufacturer.
This gave me a lot of flexibility. I wanted all the indicator lights in the house to use my favorite color, and with Home Assistant’s batch control, I could update every switch’s RGB settings at once (instead of clicking into each individual switch's settings and changing it from there). I also organized my setup into rooms and areas on the Home Assistant dashboard, which made it easy to turn on or off all the lights in any room with a single tap.
Using Home Assistant quickly became a major convenience, especially on the first floor, which has about 22 switches across six switchboards. Previously, it would take several seconds to manually press all those buttons to control the lights. Now, a single tap on my phone or a voice command controls everything instantly.
Another practical improvement: I no longer have to get out of bed to turn off the lights at night. I can simply do it from my phone. We also added two security cameras, which integrate with Home Assistant and expose motion events. If someone enters the kitchen, the lights are set to turn on automatically. Late at night, the kitchen lights turn off unless motion is detected, so if anyone goes for a drink, the system will light up the kitchen for them.