Controlling Smart Homes with KNX and Amazon Alexa
Voice control and smart home is a match made in heaven; unfortunately connecting voice assistants with centrally controlled smart homes is not an easy task. But it can be done, as this blog post explains.
I’ve recently built a summer home for our family, and have been using it as a playground for smart home solutions. Studying new technologies has been my hobby for many years; tinkering on my free time without any schedule pressures nicely balances my work as Exove CEO.
The whole building is wired with KNX, a smart home control standard that provides ability to control lighting, temperature, curtains, and sauna stove among others.
The main reason for selecting KNX was quite mundane. It provides flexibility with the wall switches, as they are not directly connected to the current. Instead, clicking a switch signals the KNX server to do a certain actions that result in turning a light on and off or dimming something.
There are also timers and other programming functionality available to perform more complex tasks, such as automatically turn on outdoor lights when it is dark enough or shut off all electricity and water supply with a push of a button. Our KNX installation is pretty straightforward, as my plan was to bring more intelligence using external systems, such as Alexa.
As KNX is an industry-wide standard, it can include components from various sources and they are interoperable. The system in the building in question is from Berker, and they provide an iOS and Android apps to control the home from the comfort of the livingroom sofa.
However, when the appliances are somewhere else and there are lights on in kitchen, voice control saves the day.
The voice controllers, such as Amazon Alexa or Google Home, support multiple smart home appliances directly. Their approach is very device centric, as is the smart home market in the United States. Each appliance, such as a smart lamp, exposes itself to the voice controller and can be thus managed through device specific skills through the controller.
KNX does not have such support, probably due being a European standard and quite complex one. But fortunately open source saves the day once again. OpenHAB is an open technology based home control system that can connect both to KNX and Amazon Alexa.
As a hobby project, I installed OpenHAB distribution for Raspberry PI called OpenHABian by using very easy to follow guide, and then created the KNX devices one by one into the configuration using the KNX scheme I received from our electrician. I do not dwell into details in this blog post – instead, there will be a more technical blog post later that dives deep under the hood of the system.
After the KNX devices were available to OpenHAB, I could test the configuration using OpenHAB’s user interface. Presto, I could switch lights on and off, dim them, read house temperature, and also move curtains up and down.
From KNX to OpenHab to Alexa
The next step was to make the lights available to Amazon Alexa. OpenHAB can emulate Philips Hue lights and expose the KNX devices as Hue devices to Alexa. There was no configuration except to turn on the emulation on OpenHab and then install Philips Hue skill to Alexa.
The final step was to search for smart home devices in Alexa. With a push of a button, Alexa spent a few seconds scanning the home and then promptly listed all KNX devices as Hue lights. The first test with “Alexa, turn on kitchen light” was success. All other lights worked flawlessly as well. Some of the lights are dimmable in KNX and thus “Alexa, dim hallway lights to 50 percent” works, too.
We have also a Sonos music player in the house. Sonos has released an Alexa support, but it does not work with Spotify. Thus, I installed Sonos module to OpenHab, and configured Sonos on/off functionality as a light switch. Now, Alexa thinks that we have a “Sonos” named light, and to stop music, I can just ask Alexa to switch it off by saying “Alexa, turn off Sonos”.
I made a short video about controlling the lights and Sonos with voice; it is available below.
The music played by Sonos is Amerika by Rammstein.
Besides having the lights controllable by voice, I can also access the OpenHab control panel and API outside of the house. KNX vendors have proprietary solutions for this, but as an open technology guy I’d prefer to do it with open solutions. The first application is most probably a simple mobile app that I can use to turn on outdoor lights, so I don’t need to fumble in darkness. The house is built on countryside and there is absolutely no light during autumn and winter evenings.
The Next Steps
There are other aspects of KNX that I’ve not yet explored, such as it has thermostats and it controls the central heating in each of the rooms. Also sauna – house being in Finland, it has a sauna – temperature and the stove temperature can be measured through KNX. I’m planning to hook the temperatures to OpenHab at least, but maybe also to Alexa.
I will also explore grouping of lights, so I could turn all living room lights on and off at once – currently I need to use five commands. Outdoor lights are other prime examples, there are four different sets of lights currently, and there will be more when we have the garden lights installed.
I’ve deliberately omitted a couple of switches from Alexa. The restroom light is an obvious omission in a family with three children – as both Alexa and the light switch are outside of the toilet, this would be a constant prank with the kids. I won’t also connect sauna stove to Alexa as a switch. One never knows whether the sauna door is open or closed – it does not have sensors, at least not yet – and thus warming the stove might be waste of energy. And it is also a fire hazard, if someone has let clothes to dry in sauna.
The system, despite being composed of several individual components, is stable and works well. The location of Alexa in the corner is suboptimal, as you need to almost yell to be heard from the other side of the room. But this is easily fixed by moving it to a more central location.
After using the solution for a couple of weekends, I’ve grown to use it quite frequently. Sitting on a sofa or preparing food in the kitchen are the typical situations when I command the house through Alexa.