The internet of things (IoT) has taken the fast track from a “what if?” future technology to an essential part of today’s world powering many crucial aspects of our existence. The technology’s existing and potential applications are broad enough to span nearly every field of human activity, with innovation and improvements taking place on a daily basis.
As the technology was expanding towards its today’s ubiquitous presence, HTEC has established strong expertise and hands-on experience working on a variety of projects involving IoT. One of those projects included integrating a voice-controlled device into an automated home system.
One of the most visible applications of IoT, outside of large industrial systems, is in the area of home automation. HTEC has been operating in this area for more than five years, through a collaboration with a company providing customized home automation solutions based on the KNX standard — an international open standard enabling communication between devices that make up a home automation system.
Over the years, the collaboration has resulted in a number of software solutions created for the partner company’s hardware products, as well as the KNX framework itself. One of the said solutions is the development of a mini operating system designed to run the central control panel of an automated home powered by KNX. This mini OS is called YOUVI.
With the rise in popularity of virtual assistant devices, the client was interested in their integration into a home automation system. As our previous work on the project was limited to the closed local network of an automated home, this was new territory for us. It required us to step outside the boundaries of the local network and incorporate third-party services via a cloud.
The virtual assistant chosen for the project was Amazon Alexa. The integration of cloud-based technology was a whole different ballgame compared to our previous work on the project. The first step involved researching the Amazon Web Services (AWS) and voice-controlled devices in order to figure out how they work and whether our system could support the integration.
The popularity of Amazon Alexa was not the sole selection criteria. The platform is also supported by extensive documentation and support for precisely what we wanted to do. After several months of research and testing out a variety of potential solutions, the team determined that the integration was feasible and settled on a course of action deemed most optimal.
Enter the cloud
The virtual assistant device of the Alexa system does not play a processing role, it is merely an intermediary — a smart speaker capable of receiving and sending out audio input. It doesn’t actually handle any of the processing of voice commands, which actually takes place on Amazon cloud servers. Therefore, the local KNX network needed to somehow communicate with AWS.
The team knew beforehand that the introduction of third-party services into the system could lead to unpredictable challenges during development. This was the first time we were exiting the controlled environment of a local network and attempting to get it to communicate with external services. The process involved countless variables and we were braced for unforeseen circumstances, but it turned out to be reasonably smooth sailing, with no greater amount of trial-and-error than you would expect on any development project.
The way Alexa works is that the smart speaker captures the voice command and forwards it to Alexa Voice Service — the system processing the audio input. Once the voice command is processed, the system then sends out a command back to the device. Let’s visualize!
There were two main challenges to the integration of Alexa with a KNX-enabled home:
- How to make Alexa “speak” KNX
In order for home automation devices to perform voice-commanded actions, the commands needed to be “translated” into a language that they understand. In order to enable this communication, we needed to create an Alexa skill. Alexa’s basic functionalities are relatively limited, but they are expanded through skills, which serve an identical role as apps to smartphones — extensions performing certain tasks. Skills can be created by independent developers and added to the Alexa Skill Store. The team had developed a skill called YOUVI Smart Home in order to serve as a bridge between our KNX framework and Amazon. On the Amazon side, the voice command is transformed into a predefined interface in JSON format. This is received by the YOUVI skill and transformed into an interface that our framework can understand. In order to enable the YOUVI skill, the user must, of course, register. Through this step, the Amazon account is linked with the existing YOUVI account, which brings us to our second challenge.
- How to locate your smart home
There is no direct communication between Alexa and YOUVI. The integration requires an intermediary tasked with locating the source of the requested action and distributing the processed information to the right address. We have resolved this challenge by developing a cloud component that serves both as an authenticator and a router. Developed in ASP.NET, the component is an OAuth2 server receiving both the account information and the translated command. It then identifies the YOUVI account and sends the command to the corresponding core system.
Once the command ultimately reaches YOUVI, its processing is no different than the processing of commands originating within the local network, with the command being forwarded to the appropriate actuator. From a slightly simplified view, this is the information flow:
Less is more
At a first glance, the YOUVI Smart Home skill may seem like a simple piece of software, containing no more than 300 lines of code. This fact hardly illustrates the degree of time and thought invested in making both the code and the solution architecture as generic and flexible as possible. With the hectic pace of technological innovation, it is important to anticipate changes and make your software ready for new integrations further down the road.
A lot of thought has been given to breaking down the whole process and recognizing the key individual components in order to design the optimal architecture and create a flexible structure that could potentially work with other platforms. In the practical sense, this specific integration was done for Alexa, but the structure allows for integration with other devices that would include only minimal, platform-specific changes.
For the broader software engineering community, it might be important to know that Amazon has done a lot of work to enable and involve third-party developers through thorough documentation and a developer-friendly environment.
Into the future
IoT technology already plays a big part in our reality, and it will only continue to do so in the years to come. The technology finds an abundance of applications both in the consumer and enterprise sectors. HTEC prides itself not only on its technical ability to implement sophisticated solutions but also on its know-how in envisioning how these solutions can transform businesses and answer the ever-growing challenges.