Two years ago my wife an I bought a house that needed some refreshment. After two years of breaking out walls, building walls, installing all utilities -including the electrical installation- time has come to switch on the light.
As an automation engineer and enthusiast it would be very difficult -not- to automate my house. Although an ‘everything off’ switch is still very useful nowadays home automation is more then that. Living in a world where everything is getting connected it must be possible for those devices to make smart decisions on their own. Why should I press the ‘everything off’ button if the house knows everybody left?
Smart things are getting common: smart watch, smart phone, smart thermostat, smart smoke detection, smart light bulbs, smart fridge, smart… The clue is making a smart connection between those things. That’s where the ‘smart hub’ comes in. That’s some kind of choirmaster that listens to the things and tells them what to do. The intelligence of this hub and the automatons that is configured transform all those separate things to a great orchestra.
This post will cover some general principles and descriptions of the setup I’m using for my home automation. Future posts will go deeper into detail on how to install and configure the different components of the system.
Hard-‘WIRES’ – connecting dumb things
After introducing with how great the internet of things is this might be some disappointment because it shows a little lack of trust: I still want to be in control when those smart things fail for one reason or another. And that’s where the Siemens LOGO! comes in.
The Siemens LOGO! is a ‘smart relay’, not as smart as some other things but much smarter than a simple switch. Best of all: it can be connected to a network!
The relay outputs of the Siemens LOGO! are used to break power to the lights. UTP cables are used to connect the push buttons from all over the house to the inputs of the LOGO!.
The big drawback of this setup is that you require a lot of wiring. Every light point needs its cable to the cabinet where the Siemens LOGO! is installed. To reduce cabling work you could install multiple LOGO!’s on different places. Like for example one LOGO! for each floor.
The LOGO! needs to be programmed but we’ll keep that very basic. An input just toggles an output. Additionally to the hard wired inputs network inputs are configured to switch the lights over the network.
To run all services and servers I’ll use an VMWare virtual machine running Ubuntu. By configuring everything in a virtual machine it is very easy to backup the server and eventually deploy it on an other host when there is an hardware failure on the active host.
An IoT language to communicate
To make it possible for our smart things to communicate they need some kind of universal language/protocol: MQTT to the rescue! MQTT is a lightweight protocol that is supported by a lot of things and is an ideal gateway for the smart hub.
MQTT needs a broker to receive messages and forward them to subscribed things. Mosquitto is an open source broker that you’ll have running in a few minutes.
Making smart connections between things: Node-RED
Node red acts as a hub and makes it possible to connect different things with virtual wires. Although it has a nice and easy to use interface, configuring nodes and interactions isn’t always as easy as I was hoping.
Many useful palettes with nodes are available on node red. Using those nodes you can retrieve weather forecasts and other useful information for your automation.
One of those palettes can be used to read and write data from the Siemens LOGO! : the S7 contrib palette
A smart home with Home Assistant
Actually this is a left-over from the time I started my automation project. At the beginning, when I didn’t know about node-red, I used a homemade interface to connect Home Assistant with the LOGO!.
Home Assistant can be used to configure automations and visualize your home. When I got started I tried to configure automations in Home Assistant, but after discovering node red and playing around, Home Assistant is now only used for the soft buttons.
For Apple users: Hey Siri, I’m home!
When everything is set up and running it’s time to make some even more fun. Node-red has a Homekit pallete that makes it possible integrate Homekit into the flows.
With a MQTT broker running it’s easy to create an intgration with Apple Homekit. The service read the status from the earlier configured topic and requests a change of the status in the same way with the topic configured to switch lights.
Making it secure
Right now we created a very insecure and vulnerable setup. But, who will be interested in hacking into your smart home to switch on a light? Well, it’s better to be safe than sorry.
Password protection must be configured and a reverse proxy (nginx) will be used to secure the traffic.