I wanted the ability to turn on/off my TV using the Amazon Echo. So I decided to build a small IR Blaster using a Raspberry Pi Zero. This had to be remote and small. For this I chose the Pi Zero and for the Wi-Fi connectivity I added the RedBear IoT pHAT to the Pi Zero. The schematics and instructions to get the IR Led working on Raspberry Pi are at Alex's blog.
Interface with Alexa
Once I had the IR Blaster working it was time to interface with Alexa. To communicate directly with the Pi Zero from Echo I decided to emulate an existing smart home device echo supported. I picked WeMo as device to emulate as there was existing Python code and the code only need a slight modification. For this I used Chris's code from Github and made slight modifications so that the Pi Zero would show up as a local WeMo device.
This code is posted below. With the Pi Zero emulating the WeMo device, I was able to add it in the Alexa and I was good to go. Now I can send the command directly to Raspberry Pi from Alex and not having to go through the AWS cloud. Also this is so much faster. I can say “Alexa turn on TV” and the Pi Zero running the modified Chris's code will send out the signal to turn on the TV.
WeMo emulation to send out ir commands from raspberry pi or any device that is setup for lircPython
#!/usr/bin/env python # For a complete discussion, see http://www.makermusings.com """ The MIT License (MIT) Copyright (c) 2015 Maker Musings Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Read More: Pi Zero IR Blaster + Amazon Echo