Page 1 of 1

HOW TO: Amazon's Alexa Voice Commands with Domoticz

Posted: Thursday 05 November 2015 23:32
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

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

Posted: Friday 06 November 2015 1:03
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)

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

Posted: Friday 06 November 2015 10:23
by bbqkees
This seems like a very nice thing.

Do you need the Amazon Echo or are you using another input method?

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

Posted: Friday 06 November 2015 10:23
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?

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

Posted: Friday 06 November 2015 14:27
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.

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

Posted: Friday 06 November 2015 14:29
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

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

Posted: Friday 06 November 2015 15:05
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

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

Posted: Friday 06 November 2015 16:36
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.

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

Posted: Friday 06 November 2015 17:24
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

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

Posted: Friday 06 November 2015 17:48
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.

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

Posted: Monday 14 March 2016 3:56
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

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

Posted: Wednesday 28 September 2016 23:22
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