Amazon Echo Skill EchoToEventGhost

If you have a question or need help, this is the place to be.

Re: Amazon Echo Skill EchoToEventGhost

Postby kkl » Wed Dec 14, 2016 4:43 am

Statikk wrote:...or have her reply with a phrase of my choosing?


Yes, m19brandon described this in the first post. He's programmed it so that anything after "Return Msg:" in the response is what Alexa says. Here's a simple example that just echos back whatever you say:

Capture9.JPG
kkl
Experienced User
 
Posts: 305
Joined: Wed May 04, 2011 9:32 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby jimbowen » Mon Dec 19, 2016 11:04 pm

I've signed up to say thanks to m19brandon and everyone else who has contributed to this thread. As has been mentioned, the AWS portals have change a bit since the beginning of the thread so just wanted to try and give something back to the community and offer some advice (up to you if it's good or bad!):

1) Create the AWS Lambda first, the ARN address is in the top right hand corner of the screen. Don't worry about modifying the node.js script just yet.

2) Create your Echo Skill, referencing the ARN of the Lamba probe. The Skill ID is listed under your title, this can then be copied to your Lambda's node.js script as the Application ID.

3) The skill platform is phasing out the 'LITERAL' command (and flat out is not configurable with the UK language), this requires the use of Custom Slots which the procedure in this thread doesn't cover as I imagine it wasn't needed at the time of writing. This also impacts your Utterances structure (I couldn't work out a better way, but I'm sure there is).
Loosely put, you need something along the lines of the following:

- Create a Custom Slot called 'Commands'
- The Custom Slot will then contain your 'action' words in every iteration, e.g. 'living room lights off', 'TV on downstairs' etc
- In place of the 'LITERAL' intent, you would then have a 'slot type' of your custom slot title, e.g. Commands:
Code: Select all
  "intents": [ {
    "intent": "Turn",
    "slots": [
      {
       "name": "Action",
       "type": "Commands"
      }
     ]
  } ]

- Your Utterances will then reference the 'intent' name, which in the example above is "Turn" (you can have multiple intents referencing the same name and type).
E.g.
Code: Select all
Turn {Action}

In doing so, your {Action} of 'TV on downstairs' is sent as a complete string to EventGhost.
Before using this method I had a hard time getting the payload to differentiate my words, so I couldn't easily use on/off for my devices! There is probably a better way...disclaimer: I'm completely new to AWS, Echo and EventGhost.

4) In EventGhost, as many have mentioned in this thread, the key Python command is:
Code: Select all
eg.TriggerEvent(eg.event.payload[0][0:55].prefix=eg.event.suffix'

This can then be used to fully extract your Custom Slot command as an Event in your macro.

A few notes:
- If you can't get the Lambda to connect then you have something blocking access, I was stumped for a few hours until I realised PeerBlock on my EventGhost server was stopping connectivity from AWS, be careful of any hardware or software firewalls!
- If your Custom Skill test is failing, then you copy the code from the 'Service Request' field, go to your Lambda probe and go to 'Actions > Configure Test Event' and paste in the Service Request. I had no end of trouble connecting via AWS even though remote web browsers were connecting fine, this just allowed me to ensure the Lambda was OK.
- I'd recommend getting a dynamic DNS account somewhere, or if you have a private domain name you can use a script to update your dynamic WAN IP to a host record using your domain provider's API.
- A custom skill requires an invocation command, I'm trying to piece this together to use the Smart Home API to avoid this, I'm getting nowhere fast so will report back if/when I eventually get this going.

This has got my setup fully functional using IP/IR/RF devices (no truly 'smart' devices or IFTTT integrated). I use iRule on Android and iOS to control devices, so in case anyone needs an example Python script for EventGhost to control Global Cache here's an example:
Code: Select all
import socket
from time import sleep
import sys
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
HOST = '192.168.201.4'
PORT = 4998
sock.connect((HOST, PORT))
sock.settimeout(2)

sock.sendall("sendir,1:1,1,38000,3,1,341,171,21,22,21,22,21,64,22,21,21,22,21,22,21,22,22,21,22,63,22,63,22,21,22,63,22,63,22,63,22,63,22,63,22,21,22,21,22,21,22,63,22,21,22,21,22,21,22,21,22,63,22,63,22,63,22,21,22,63,22,63,22,63,22,63,22,1524,341,86,22,3799"+"\r")

msg = sock.recv(4096)
print msg
sock.close()

Code: Select all
,3,
represents the IR blaster location, and
Code: Select all
+"\r"
is carriage return to enact the command, finally
Code: Select all
sock.close()
is required to gracefully close the connection - I found iRule was blocked due to EventGhost until I started to close the commands.
jimbowen
 
Posts: 1
Joined: Mon Dec 19, 2016 10:02 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby martikainen » Sat Dec 24, 2016 12:40 pm

This might have been answered already but I didnt find any direct answer.

I've set up the function and its working really good! Thanks for that!

I have one utterance i use, "Alexa, tell Jarvis to play music"

That triggers a macro in eventghost that put's on my reciever, change input channel to a bluetooth device I've attached to it.
After that has been done i would like to trigger Alexa to connect to that given bluetooth device, and also be able to have her disconnect when i say "Alexa, tell jarvis to stop music" (which then turns off the reciever).

The reason for this is that I use the reciever in my home theatre, and when I'm not listening to music i dont want alexa to be connected to the bluetooth device since I can't communicate properly with her.

The only workaround I've thought of is to have a On/off switch on the bluetooth device that enables it when i tell jarvis to play music, and I'm guessing Alexa would autoconnect to the bluetooth device when it becomes available, and disconnect from it when it's unavailable. Haven't tested this yet tough, and i would rather see the possibility to tell alexa via eventghost to connect to the bluetooth device.
martikainen
 
Posts: 5
Joined: Thu Aug 13, 2015 11:22 am

Re: Amazon Echo Skill EchoToEventGhost

Postby kkl » Sat Dec 24, 2016 5:51 pm

I don't know of a built-in function for doing this, but I believe that using the utilities Devcon or Devmanview might do what you want. Discussed briefly in this thread.
kkl
Experienced User
 
Posts: 305
Joined: Wed May 04, 2011 9:32 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Wed Dec 28, 2016 3:34 am

I am glade this is still useful, at home this is how we control everything to the point where I am paying about $0.01 (300-400 request) a month in AWS charges.

Sorry the guide is out date. The code is still good.

Amazon has been changing the Lambda and Alex app sites almost month, thus I am going to work on editing the guide but be very vague to allow for AWS future changes.
m19brandon
Experienced User
 
Posts: 171
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby rdgerken » Fri Dec 30, 2016 8:38 pm

Does anyone know how to delay Alexa from looking at the response from the webserver? I have an issue where my API calls to other services take so long, that the response is not set in time for Alexa to have the proper response data. I just need her to wait another second or two.

TIA
Ryan
rdgerken
Experienced User
 
Posts: 85
Joined: Fri Sep 21, 2012 7:41 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Fri Dec 30, 2016 11:28 pm

Open your lambda function under the AWS console. Then change to the configuration tab, toward the bottom expand the advance setting section. Lastly up your timeout. I have set mine to 6 seconds.

Note Amazon will charge for the total CPU time of the Lambda request. So delays in the response will count in that total time. It is not much but you may go from free to a few pennies a month. Pay for only what your use Amazon model $$.
m19brandon
Experienced User
 
Posts: 171
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby rdgerken » Sat Dec 31, 2016 12:38 am

Brandon,

Thanks for the quick response! Loving the setup btw... works awesome!

Ryan
rdgerken
Experienced User
 
Posts: 85
Joined: Fri Sep 21, 2012 7:41 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Sat Dec 31, 2016 2:29 am

I had a similar issue. I use wit.ai to convent the spoken string into clear intents and actions. Something their REST responses take 2-3 seconds and was forced to increase my timeout settings. I happy that this is workaround out.
m19brandon
Experienced User
 
Posts: 171
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby alonmalka » Sun Jan 08, 2017 10:30 am

Hi Guys,

First I would like to thank M19brandon for all his great work.
I really need your help.
I am trying to setup the Echo to EG. I think I have made a lot of progress but I still have problems and would like some help to figure out what I am doing wrong.
I created the Lambada function in this way:
1. Select Blueprint - Blank function
2. Configure Triggers - Chose Alexa Skills kit
3. Configure Function: Name: EchotoEvent
Description: None
Runtime: Node js 4.3
Code Entry Type: Upload a zip file - upladed Brandon's file after renaming it to index.JS and zipping it.
Environment variables: Left empty - (have no idea)
Lambda function handler and role - Handler, Role, Role name, Policy templates - what should I choose here???
Advanced settings - Should I touch something here??
I updated the IP, Event name and port in the code and port forward the port for the webserver.


Now I Created Alexa Skill:
Imagephoto hosting sites

Imagefree image hosting

Imagescreen capture windows 7

Imageimage upload with preview

Imagefree screen capture

And this is what happened when I test it:
Imageimage

and this is what happens when I test it in Lambada:
Image

Can Someone help me with this?

Thanks,
Alon
alonmalka
 
Posts: 19
Joined: Wed Dec 04, 2013 10:07 am

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Sun Jan 08, 2017 3:46 pm

In the index.js (EchoToEG_SampleEvent.xml) file, what is line 10 set to
var Echo_App_ID = "amzn1.echo-sdk-ams.app.############";

It should match your "Application Id" found in your developer.amazon.com console > Your skills > edit

Hope that helps.
m19brandon
Experienced User
 
Posts: 171
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby alonmalka » Sun Jan 08, 2017 6:16 pm

Yes that was it!!
I guess with all the attempts I have made I probably didn't copy the updated line.

So now I can get the event in event ghost.
How do I import the Marco_AmazonEchoRcv to my EG setup?

Thanks,
Alon
alonmalka
 
Posts: 19
Joined: Wed Dec 04, 2013 10:07 am

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Mon Jan 09, 2017 2:41 am

It depends on what you wanted to do. I would recommend using my example macro as a demo, it does not do anything without your code being linked to in the JumpTo.

The easiest thing to do is create blank Python Script Macro, drag in the HTTP.EchoToEG.
Add any code you want to the script.
Set the payload to a variable and then added a bunch of if then statements.
cmd = eg.event.payload[0]

There are some examples on page 1 of this thread.
m19brandon
Experienced User
 
Posts: 171
Joined: Mon Feb 03, 2014 10:36 pm

Re: Amazon Echo Skill EchoToEventGhost

Postby alonmalka » Mon Jan 09, 2017 11:14 pm

Hi,

I am using the following code in EG in order to search for the words "irobot" and "on" and then activate the irobot.
Code: Select all
if 'irobot' in cmd and 'on' in cmd :
   print 'irobot will start'
   eg.globals.ibl1_msg = 'Return Msg: OK Done, iRobot is starting'
   eg.plugins.Webserver.SetValue(u'bb_response', u'{eg.globals.ibl1_msg}', False, False)
   eg.TriggerEvent('irobot');


The thing is sometimes Alexa thinks I am saying robot and then it does nothing.
How can write in Python:
Code: Select all
if or('irobot','robot') in cmd and 'on' in cmd : etc...



I can add another Else if (elif) but I prefer to minimize the number of ifs.
Any ideas?

Thanks Guys.
alonmalka
 
Posts: 19
Joined: Wed Dec 04, 2013 10:07 am

Re: Amazon Echo Skill EchoToEventGhost

Postby m19brandon » Tue Jan 10, 2017 12:20 am

Just use robot and on. I have hundreds of lines of if then else statements and I use Wit.ai to simplify it it even more.
m19brandon
Experienced User
 
Posts: 171
Joined: Mon Feb 03, 2014 10:36 pm

PreviousNext

Return to General Support

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 5 guests

cron