HOW TO: Amazon's Alexa Voice Commands with Domoticz
Posted: Thursday 05 November 2015 23:32
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
-- 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