I have a few power sockets that can be switched wirelessly, mainly Energenie devices triggered by my Raspberry Pi. I’ve had a web interface for ages, and some automation around things like sunrise/sunset, but I’d been meaning to add voice control to save me requiring a device to hand.
Obviously Alexa is hosted on Amazon’s servers, so any command from the Echo was going to outside my own network. Marketplace for old domains. I needed to get it back inside, to trigger the code on the Pi, but I wanted to do that without exposing any URLs or potential data breach opportunities.
I found a few tutorials that showed how to do it by setting up your own Alexa Skill in AWS Lambda, combined with Amazon’s IoT option, but this seemed like a lot of effort. Instead, I was trying to find the right combo of services that would knit together. In the end, a combination of IFTTT, Beebotte and a custom Node script running on a local machine did the job.
Integrating with Alexa
IFTTT was a simple selection as it already has Amazon Alexa listed as one of the services it integrates with.
A bit of research also highlighted the ability to accept and hit webhooks. So I could set up an Applet in IFTTT to listen for a command on my Echo and make a call to a URL that included a command.
To do that, simply select Amazon Alexa for the ‘this’ part of the Applet, then authorise integration. Once done, pick a “Say a specific phrase” trigger.
MQTT – Beebotte
Originally, the plan was to self-host a script to send a message via XMPP/Jabber when the URL was hit. I currently have a basic bot set-up by way of a Node script connected and listening for messages. Triggering a message using PHP seemed to be a bit of pain, so I turned to MQTT.
It was something I had been meaning to look into for a while and this proved a useful opportunity. Continue reading…