HOW TO: Amazon's Alexa Voice Commands with Domoticz

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
jbreed
Posts: 10
Joined: Saturday 18 July 2015 15:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by jbreed »

Purpose: Use Amazon's Alexa skill to send JSON commands to the Domoticz server.
-- Edit: I'm using an Amazon Echo as the hardware, which stays listening for the wake word--
Before starting: Get a free Amazon developer account and create a free aws account for hosting the lambda service. Also, you will need to port-forward the domoticz port to your hosting server if behind a NAT along with correlating firewall rules for those who have firewalls (Cisco ASA, PIX, Palo Alto, etc)
https://www.youtube.com/watch?v=i3B_Uo8Uz0w
See the attached word document for my quick writeup to include the code to use on your lambda service as a start


What is an Alexa Skill? An alexa skill is essentially your application. The skill is called by telling, or asking, alexa with correlation to the invocation name.

Example: Alexa, tell my home to turn on the bedroom lights.

'Alexa' is the wake word

'Tell', or 'Ask' correlates to a skill will follow

'my home' is the invocation name I used for setting mine up. You could technically call it bob, or whatever. I just didn't want to have to tell Alexa to tell Bob.. lol

'to turn on the kitchen lights' is looked at through the sample utterances section. Considering I said 'to turn on' it matched a LightsOn intent and the word 'bedroom' will align with the {Light} section of the sample utterance. Bedroom would need to be listed in my custom list to be able to be passed as a variable over to the lambda service for THIS CASE. You can have all sorts of variables types such as AMAZON.DATE, or whatever. See here for more information: https://developer.amazon.com/public/sol ... -interface


Your sample utterances are used to match up to your intents. With your intents you can establish variables to be used inside of the phrases that are passed to Lambda as JSON variables you can access. In my current setup you can see I gave the name of the slot as "Light" so in the utterance I have that spot filled in with {Light} meaning that word in that phrase will be set. In my example I used a list/array of possible Light options to store into that slot/JSON variable. You can modify this however you like and in the lambda javascript code you can use a simple if statement to run a specific rest url if it was called AND call a specific intent based on the phrase that was picked up. See the image below. Also, checkout the word document for my quick layout of a how-to. As you go through this feel free to update it to something that may be clearer. Did this in 10 minutes!



Also, be sure to modify the lambda code to fit your intents and slot options you pass to the intents. Review the JSON API as a reference for creating the commands based on the variable you pass to it. My next step is to add the rest of my lights, then create an intent for handling thermostat setpoint's.

Regards,
Justin
Attachments
Alexa_Setup_Domoticz.docx
How-To-Alexa-Domoticz
(300.57 KiB) Downloaded 774 times
Amazon Skill Setup
Amazon Skill Setup
Screen Shot 2015-11-05 at 4.26.13 PM.png (308.65 KiB) Viewed 10344 times
Last edited by jbreed on Friday 06 November 2015 14:33, edited 2 times in total.
jbreed
Posts: 10
Joined: Saturday 18 July 2015 15:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by jbreed »

I'll clean up the instructions and comment up the code at a later point. It's pretty simple to understand, but if anyone has questions don't hesitate to shoot them my way.

I like using Alexa mainly because it stays plugged in and is always listening. I tried the google now method using tasker for my android watch, but found Alexa to have more capability with the utterances and not having to shake my watch to get it to start listening. I have a remote that essentially extends the mic so I can be elsewhere in the home and with the remote say commands (remote is currently mounted by my bed lol)
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by bbqkees »

This seems like a very nice thing.

Do you need the Amazon Echo or are you using another input method?
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
Shyam
Posts: 46
Joined: Sunday 11 May 2014 22:11
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by Shyam »

jbreed wrote:I'll clean up the instructions and comment up the code at a later point. It's pretty simple to understand, but if anyone has questions don't hesitate to shoot them my way.

I like using Alexa mainly because it stays plugged in and is always listening. I tried the google now method using tasker for my android watch, but found Alexa to have more capability with the utterances and not having to shake my watch to get it to start listening. I have a remote that essentially extends the mic so I can be elsewhere in the home and with the remote say commands (remote is currently mounted by my bed lol)
Would you be able to give more details (hardware etc...) on your setup for voice control please?
Raspberry Pi B+
Rfxcomm rfxtrx433
LigthwaveRF
Byron Door Bell
Accenta Gen4 Security System Integration
HomeEasy PIR
Nest Thermostat
Geofencing
Pushover
Blog: http://www.shyambhundia.com
jbreed
Posts: 10
Joined: Saturday 18 July 2015 15:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by jbreed »

bbqkees wrote:This seems like a very nice thing.

Do you need the Amazon Echo or are you using another input method?
I'm currently using the Amazon Echo and also have a handheld remote that is paired to it that has a mic in it (so if in another room with the door closed I can use the remote).

I know they offer a development kit for those looking to integrate Alexa into your own hardware suite. If someone takes the time and compiles it for Domoticz to work directly on a Raspberry that would be awesome. That way you can add however many microphones you want around your whole home to have it so it can hear you anywhere.

Another cool thing with this is you can have it hold a conversation with Alexa where it maintains a session and you shoot text which in turn gets output of your Echo (or whatever). I currently have it silent unless it failed to send a command, but you can make it confirm it worked. Oh and unless you come up with a tricky method of masking curse words it will beep them out lol.
jbreed
Posts: 10
Joined: Saturday 18 July 2015 15:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by jbreed »

Amazon Echo:
http://www.amazon.com/gp/product/B00X4W ... atdqwe3p_b

Remote:
http://www.amazon.com/Voice-Remote-for- ... cho+remote

With the remote you are not required to use the wake work "Alexa" considering you have to press a button to have the microphone listen.

I believe the Echo has 7 microphones built into it and it can easily hear you across the room. My wife and daughter like it for the simple fact of other things as well such as playing Amazon Prime music and integration with Pandora. The speaker quality is similar to a bluetooth speaker. Again, this would be way more dynamic if integrated onto a Raspberry Pi with unlimited microphones mounted around the area.



For those looking to integrate the voice service into a piece of hardware. See this:
https://developer.amazon.com/public/sol ... ce-service
locogek
Posts: 28
Joined: Thursday 15 October 2015 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by locogek »

Great stuff! But you need the echo? Would be great to build it in to the raspberry. Maybe a nice idea to make remotes with mysensors. I think there are a lot of people wanna help to integrate this.

Verstuurd vanaf mijn ONE A2003 met Tapatalk
jbreed
Posts: 10
Joined: Saturday 18 July 2015 15:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by jbreed »

locogek wrote:Great stuff! But you need the echo? Would be great to build it in to the raspberry. Maybe a nice idea to make remotes with mysensors. I think there are a lot of people wanna help to integrate this.

Verstuurd vanaf mijn ONE A2003 met Tapatalk
No, you do NOT need an Echo, but I'm currently using it. They have a developers kit for those wanting to put voice services using their own microphones that I linked in my last post. I haven't dug into that yet, but it would be pretty awesome to have a Mic in every room and have ceiling mounted speakers in each room that Alexa can respond through. You can do two-way communication such as:

Alexa, tell my home to turn on a light
Response: Which light do you want to turn on?
Your response to Alexa: the kitchen

With this you can make it more dynamic capabilities if you choose. You can even create an intent to do something such as the following:
"Alexa, ask my home what the temperature is in the living room" and have it grab the response from Domoticz and respond with it via text to voice.
locogek
Posts: 28
Joined: Thursday 15 October 2015 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by locogek »

Ok nice! I did a bit more research on Alexa. There is a application written in Java. What you can try is install a Java compiler on the raspberry and run it.

Verstuurd vanaf mijn ONE A2003 met Tapatalk
jbreed
Posts: 10
Joined: Saturday 18 July 2015 15:00
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by jbreed »

locogek wrote:Ok nice! I did a bit more research on Alexa. There is a application written in Java. What you can try is install a Java compiler on the raspberry and run it.

Verstuurd vanaf mijn ONE A2003 met Tapatalk
Awesome! Let me know how that turns out.

Currently, it appears the Echo ONLY supports English. It can translate words, but only speaks English.
carldickson
Posts: 3
Joined: Sunday 06 September 2015 6:43
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by carldickson »

Hi,

I have got this going but there is no response from Alexa, the switches change but not voice confirmation.

I used your code with only changing the urls.

Thanks
Dageezah
Posts: 8
Joined: Wednesday 06 November 2013 9:18
Target OS: Linux
Domoticz version:
Contact:

Re: HOW TO: Amazon's Alexa Voice Commands with Domoticz

Post by Dageezah »

Did you manage to get Alexa to respond?

I am in the same boat at present - all working controlling the house (and is pretty good at it as well) but no response.. although not really a problem as when you ask to turn the lights off the response is that the lights actually go off, but it would be nice to have a voice response as well..

Scrap this - must have been a bug - just suddenly started working the next morning
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest