My DIY home automation in a rental apartment

I emphasise the fact that we rent and not own - this is important because it’s always been the domain of home owners to do any sort of home automation - at least, it’s been perceived that way. I’m here to show how this doesn’t have to be the case and that you can do a lot of home automation even without the need of an electrician through the sheer magic of software. 
However, I should note that you have to be handy with tools and in my example, you should understand your mains electricity. This is neither a guide or a how-to-manual, it’s simply to document what I had done over the last two years (coinciding with the appearance of a certain virus) to make my home smarter.
Before I start this excursion, I’d like to highlight what some of my goals were. Clearly, my number one goal was to save electricity or rather, not waste electricity when we do not have to have the lights on or the TV or whatever else could have a power switch. 
My second goal was to do it in such a way that I would not need to alter anything in the apartment in regards to the electricity or light switches or other things. 
My third goal was to experiment (as is often the case when I undertake something).
I had already experimented with the Philips HUE system, in fact half of my apartment is based on Philips HUE but the system was simply not powerful enough and you had to buy into Philips’ ecosystem which I didn’t like because of the high price. I learned that the hard way when I tried to expand it with a smart plug. So I looked for other solutions. 

Setup

I did some research also because I saw how a friend of mine was utilising ZigBee without the Philips HUE bridge (the Philips HUE system uses the ZigBee standard to communicate) but I needed something to tie other ZigBee devices together into a uniform way. 


ZigBee2mqtt

Enter ZigBee2Mqtt - as the name implies, it is an open source ZigBee to Mqtt bridge. 
What does that mean? Well, the software package translates from ZigBee device communication to a lightweight IoT messaging queue (mqtt) over TCP/IP. But the ZigBee portion does a lot more - its software can manage a very large catalogue of ZigBee devices, completely manufacturer independent. This is important because it allows you to mix-and-match different ZigBee devices. Take a look at the catalogue here.   
Now, it requires that you run two components on Linux: an Mqtt server (I use Mosquito) and the ZigBee2mqtt software that communicates with a ZigBee hub, which is connected via USB to the Linux machine. Which USB hub you can use is really nicely documented as well on the ZigBee2mqtt website. It does require (in my case) firmware flashing but it’s well documented. It also gives you pointers where to order the USB ZigBee hub from. 
Because one of my goals was to reduce waste, I installed all this on a Raspberry Pi 4 with very low-power consumption and it’s been working fairly nice. 


Raspberry Pi running ZigBee2mqtt


Homeassistant

At this point, I was able to send commands via Mqtt directly to my connected ZigBee devices and that worked really well, but I realised that if I wanted to do something complex and sophisticated, I would have to write the software or scripts myself or I look for a system that would help orchestrate all this. 


Enter Homeassistant - you would never know from the name what a powerful tool this is. Homeassistant is exactly the orchestration tool I was looking for to bring all my devices together. But it does a lot more .. a lot. Homeassistant can instantly grab everything you already have on your home network and make it accessible for you to configure. We’re talking your router, your printer, your NAS, your IP cameras, your TV, all your phones and the list goes one. But that’s not enough, Homeassistant also has modules for a lot of different IoT standards. The combination of Homeassistant and ZigBee2Mqtt is _mindblowingly_ powerful and the reason why I could do what I’m showcasing here. 

My Homeassistant instance used to run on another Raspberry Pi but because I kept changing configuration constantly, the SD card in the Pi simply gave up at some point. I have moved my Homeassistant to an Odroid system which is still low-power but much more resilient than a Raspberry Pi. 

I could write probably another several pages just on how awesome Homeassistant is but I’ll leave that for you to read up on. 


Odroid running Homeassistant



My first task was to incorporate the existing Philips HUE system into Homeassistant - this works brilliantly because Homeassistant already has implemented all the relevant APIs and so it’s just a matter of finding out the IP address of the HUE’s bridge and connect to it (it does require that you physically press the button on the HUE bridge) - so, now I could control all my Philips devices from a central point. Neat. 
What also amazed me was that I could run two different ZigBee networks and they did not interfere too much. My original plan was to disconnect the devices connected to the Philips system and re-connect them to my ZigBee2mqtt setup - but Homeassistant basically saved me that work with a direct integration into the Philips system. 
With the power-combination of ZigBee2mqtt and Homeassistant, I was ready. 

Use case: motion detector

My next step was to start looking for opportunities to save energy - the first one was through a motion detector. So I bought several Xiaomi (also known as Aqara) ZigBee lightbulbs and motion detectors - the motion detectors are very low power that can measure the amount of light and motion and they run off batteries. After connecting them to ZigBee2mqtt and having Homeassistant pick up the new devices (this btw happens automatically), I was able to program the motion detectors in such a way that they would only turn on the lights if there was motion and not enough light. After 2 minutes of no motion, they would turn off again. 


Aqara motion detector

Light switches

This worked great until I realised that anyone could simply turn off the power to the ZigBee lightbulbs and then it wouldn’t work anymore. And Furthermore, I wanted to control other lightbulbs that needed to be always connected to make the system work. So I had to prevent the use of the existing light switches - the solution was twofolds: a) prevent the use of the existing light switches and b) add new ZigBee light switches. 
To prevent the use of the existing light switches, I decided to design and print my own cover - to essentially block access to them. This looks a little bit funky but absolutely works without changing anything in the apartment. Your light switches may look different - these are Swiss standards.  


3D printed covers for the light switches

The covered light switches next to the fancy new Aqara switches



Non-ZigBee lamps and light fixtures


Of course, I had lamps that I had no way of connecting to the ZigBee network because I couldn't swap out the lightbulbs - in fact I had three such cases. Namely, a built-in light over the stove in the kitchen and two light fixtures that I simply couldn't make smart. This is where the ZigBee switch module came in handy. 

Aqara ZigBee switch module with neutral



I was able to implant two of these modules directly into the light fixture but for the light over the stove I had to to hire an electrician because it requires disassembly of the light switch which I didn't feel comfortable in attempting. 

With these modules in place, and all other bulbs replaced and new switches everywhere, I could focus on the next thing.

Use case: The cat alarm

We have a cat that goes out from time to time. The problem is we don't know when she comes back in. We could have tried a motion sensor outside but the much better approach was to use a camera with motion detection for pets. The newer Reolink cameras do just that and even better there is an integration into Homeassistant through the community. I programmed Homeassistant so that when the cat is outside, one of our lights would turn green so that we knew if the cat wanted to get in. 

Camera mounted on board (not wanted to drill into rental apartment walls)

Light turns green when cat is detected


Use case: The connected cat door

Of course, the next phase was to use a connected cat door so that we could actually track when the cat was home. This was made possible through a Surepetcare bluetooth bridge connected cat door which integrates directly into Homeassistant. 

Use case: The connected car

Not to be outdone, of course there is also an integration for Tesla cars of which we happen to have one. So with Homeassistant, I could create an automation based on the charging levels of my car but for now, we simply use it on the dashboard. 

Some Tesla stats; charging state, charging levels, range, temperature, location. energy use, etc.


Use case: Raspberry Pi Temperature

I have a Xiaomi temperature sensor that I placed in the wash cabinet where I have all my network and computing gear. The challenge is that when the tumbler is on, the heat increases and often times, I find that the Raspberry gets hot - too hot maybe. However, I realized, I need to measure the temperature directly of the Raspberry Pi. Enter Mqtt - because I was already running mqtt which is connected to Homeassistant, the easiest way was to send the temperature readings from the built-in sensor, via Mqtt to Homeassistant. If the message is properly formatted, Homeassistant sees it as a new sensor and it's then super easy to make use of it in Homeassistant. 

Temperature - there is a correlation between the Raspberry Pi's CPU temperature and the Wash cabinet


Use case: Public transit information

Because Homeassistant has a very active community, someone managed to integrate Switzerland's public transit data which I was able to configure and display.

Our quick glance dashboard

The screenshot above shows the smallest dashboard that I have configured - it's the default that conveys important information and allows for important functions. There is the weather, the next public transport opportunities, Izana's whereabouts (the cat), how much battery and range we have for the car, two buttons - one for all lights in the living room and one to turn everything off and finally, a map of the car's whereabouts.

Conclusion

In conclusion, the fact that we live in a rental apartment has not prevented me from making my house fairly smart. This post is very short, I could probably write many more pages here to illustrate more use cases, or discuss more aspects - but my goal was to simply illustrate what I had done, what combinations I had used in the hopes that I can inspire others. 


Comments

Popular posts from this blog

Will Libra change the world?

Apples Vision Pro Headset strategy is all about its Arm-chips.

Will smart phone cameras be better than digital mirrorless cameras?