IoT is one of the industry’s latest buzzwords. The technology’s possible applications are almost as broad as the entire field of human activity, and we are seeing new and exciting developments emerge at an accelerating rate.
HTEC team worked on one such project — the integration of a voice-controlled virtual assistant into a home automation system.
Home automation is one of the most dynamic areas of IoT’s consumer-focused applications. We have been active in it for the past seven years, ever since we started a collaboration with a client providing KNX-based home automation solutions (KNX is an international open standard used for communication between different devices in a home automation system). Throughout our collaboration, we have developed and implemented a broad range of software solutions for clients’ hardware products and the KNX framework in general, including the development of our own framework (a mini OS, if you will) called YOUVI which runs the central control panel of a KNX-enabled home.
All of our previous work for the client remained firmly within the boundaries of a closed local network that enables direct two-way communication between various devices in a home automation system. Integration of a voice-controlled system (Amazon Alexa, to be specific), however, requires third-party services. This meant that we would have to step out of the local network and into the cloud.
It is not uncommon that new members of the HTEC team are tasked with researching and testing the feasibility of a potential solution in order to hit the ground running. This was precisely the case with our colleague Mladen Doslic. Fresh out of college and onto his first job, Mladen was entrusted with exploring the unfamiliar waters of Amazon Web Services (AWS), cloud technologies and voice-controlled devices.
It was my task to research how it all works and see whether our system can support voice control. Incorporating cloud technologies added a whole different dimension to the work on the project, so it was all a bit overwhelming at first. I spent several months researching and testing out different ideas and finally concluded that the integration could probably be done with relative ease. — Mladen Doslic, Software Engineer at HTEC Group
The team had chosen to focus solely on Amazon Alexa not only because it is the most popular platform on the market, but also because it has extensive documentation and support for integration with home automation systems. Armed with sufficient knowledge and confidence and excited to get down to business, the team got the green light from the client and project “Alexa” was a go.
Stepping into the Cloud
The central device of the Alexa virtual assistant is merely a medium, a smart speaker that can receive and broadcast audio information. All of the voice command processing doesn’t actually take place within the device but on Amazon cloud servers. This meant that we would have to find a way to make the local KNX network communicate with the cloud.
Whenever you’re introducing a new component into the system you can never truly predict the full extent of the development process. For the first time, we added a third-party service to our system, one that involves a number of different processes and technologies. With so many variables there’s always a high probability that unexpected difficulties will emerge. As expected on any project, there was some trial-and-error, but the integration process went glitch-free for the most part.
When you give out a voice command to Alexa, it sends the audio information to the Alexa Voice Service, which processes the audio input and returns a command back to the device, like this:
Connecting Alexa to a KNX home presented us with two main challenges:
- Converting voice commands into Smart Home commands
We solved this issue by creating an Alexa skill. And, what is an Alexa skill? Well, Alexa has a fairly limited set of basic functionalities. This set is expanded by enabling “skills” — extensions that perform specific tasks, like apps on smartphones. Just like apps, skills can be created by third-party developers and added to the Alexa Skill Store, where users can choose and enable them. Our Alexa skill, called PEAKnx YOUVI after our KNX framework, serves as a bridge between the Amazon and YOUVI interfaces. A voice command gets processed and transformed into a predefined interface in JSON format. This information is then received by our YOUVI skill, which transforms it into a YOUVI interface. In short, YOUVI Smart Home skill translates Alexa commands into KNX commands. Additionally, enabling this skill requires you to register, which links your Amazon account with your YOUVI account and helps with the second challenge.
- Locating the smart home
Since Alexa does not communicate directly with YOUVI, we needed to create an intermediary that would locate the request source and send the translated information to the proper destination. For this purpose we developed a cloud component from scratch, serving both as an authenticator and a router. The cloud component, developed in ASP.NET, is essentially an OAuth2 server which receives both the account information and the translated command, then identifies the YOUVI account and sends the command to the corresponding core system.
The command received by the YOUVI framework is then processed like any other and sent to the right actuator. Few details aside, the informational flow looks like this:
We spent a lot of time thinking about the optimal architecture, breaking down the process to identify key individual components and creating a flexible structure that would work with different platforms. We have only done the full integration for Alexa, but, in theory, this structure allows us to integrate any other existing or future devices with minimal, platform-specific adjustments. — Ivan Spasojevic, Delivery Lead at HTEC Group
The wave of the future
Over the last few years, technological developments have shown that voice controlled devices will play a major part in our shared future. One of the things team members were most impressed with in working with Alexa is the extent of Amazon’s effort to enable and involve third-party developers. The environment is very developer-friendly and lengthy documentation walks you through every step of the way, allowing even developers with the most elementary knowledge of some of the most popular programming languages (Java, Python, JS, etc.) to create their own solutions.
Therefore, if you’re even a little bit interested in this emerging technology, this might be a good time to try and make something of your own. Our colleagues will be right there with you, excited to see what the future holds.
Going Smart, Together
Do you have an IoT project in mind? Reach out to us to see how we can help build innovative solutions.