Chapter 6. Home Automation with Alexa
"Communication must be HOT. That's Honest, Open, and Two-Way."
As we progress through this book, the skills we create are evolving too. We started with a simple Hello World Skill and went on to create an SMS sender, a trivia game, a skill that talks about cryptocurrencies, and in this chapter, we will be working on Ambience Manager, which can tell us the ambience parameters, such as the temperature and humidity, of our homes.
We will be designing this skill by covering the following topics:
- Introduction to Home Automation and Ambient Sensors
- Designing the Ambience Manager Skill
- Developing the Mobile App
- Developing the Ambience Manager Skill
This chapter will be covering a lot of ground since our Ambience Manager Skill will be communicating with an ambient sensor, hence it will also involve the details regarding the ambient sensor as well as a mobile app, which will help us in uploading the temperature data to the cloud.
Introduction to Home Automation and Ambient Sensors
For introductory purposes, home automation is a concept whereby a user can control standard home fixtures such as lights, music systems, televisions, and even climate, using an array of intelligent sensors rather than the traditional flipping of switches for each individual fixture. Home automation intends to keep the physical interaction of the user with the actual hardware as minimal as possible. In the recent present and the not-so-distant past, the concept of home automation was built on top of mobile operating systems (mostly Android or iOS), where the user was able to control the whole house using just a mobile device or a tablet rather than interacting with the switches of each individual device present in the house.
With the advent of Interactive Voice Assistants, the concept of home automation has transcended to the level where a user can control a home with just their voice. The actual concept of home automation is very broad and...
Designing the Ambience Manager Skill
Our Ambience Manager Skill will have at least five moving parts, including a User that interacts with Amazon Echo, which in turns communicates with the AWS Lambda, which in turn fetches the temperature information from the Firebase cloud. The temperature information will be pushed to the Firebase cloud via the Mobile Device, which reads it from the Ambient Sensor. The flow of information is shown in the following diagram:
Figure 6.2: Data flow in Ambience Manager Skill
The ambient sensor will communicate the ambient parameters, that is, temperature and humidity, to a mobile app over BLE.
This will eventually upload the ambient parameters to the Firebase backend.
Note
Firebase is a real-time database by Google. To learn more about Firebase, visit https://firebase...
Developing the Mobile App
We will be creating an Android app that will communicate with the ambient sensor over BLE.
If you do not know much about developing Android apps and BLE, don't worry, you can simply download the source code from the link provided toward the end of this section. Alternatively, you can check out the Android Developer website regarding the development of Android apps.
The following are the prerequisites for this section:
- Android:
- Latest Android Studio
- An up-to-date Android device (preferably a Samsung Galaxy S8, since it has support for Bluetooth 5, otherwise any device with an API Level of 23 (Android M) is fine)
- Basic familiarity with Java, Android, Android Studio, and BLE
- Hardware:
- Texas Instruments CC2650 STK SensorTag
We'll begin by creating an empty project. Please choose a name for it.
For the purpose of consistency, and since...
Developing the Ambience Manager Skill
As always, we will be making use of the Alexa Skills Kit (ASK) Console to configure the Ambience Manager Skill:
Figure 6.17: Alexa Skills portal
- After signing in, click on the
Alexa Skills Kit
menu item on the top-left, and from the menu, select Get Started
| Alexa Skills Kit
:
Figure 6.18: Alexa Skills Portal – signing in
- On the screen that appears next, click on the
Start a Skill
button, located in the center of the screen:
Figure 6.19: Alexa Skills Portal – starting a skill
- This should land you on the ASK Console:
Figure 6.20: Alexa Skills Portal – ASK Console
Click on the Create Skill
button located at the bottom of the screen.
- The next screen is the
Create a new skill
screen, which will require a SkillName
to proceed further:
Figure 6.21: Naming the skill
Please name the skill Ambience Manager
and click on the Next
button.
We hope you enjoyed creating the Ambience Manager Skill. This skill had a lot of moving parts that were not Alexa-specific, such as Firebase, the ambient sensor, and the mobile app. We also covered the One-Shot Launch, and skill debugging via CloudWatch.
As with the previous skills, the Ambience Manager Skill still has room for improvement, such as handling humidity data and the introduction of additional intents.
We have left the improvements as an exercise for the user to hone the skill even further.
We also hope that you are now a little more confident with your knowledge regarding Alexa skills and can't wait to see what you create next.
In the last chapter, we will explore the future of Voice-Based Assistants.