Amazon Echo
derrick.thames
Posts: 9
Hi,
I'm trying to integrate the Amazon Echo to my Netlinx master. I've seen snippets of code on the internet that are using a Raspberry Pi, so I'm assuming my Netlinx master can emulate the same function?
http://www.makermusings.com/2015/07/13/amazon-echo-and-home-automation/
Initially I'm simply trying to see the UPnP request the Echo sends out when you say "Alexa, find devices". In order to do that I:
1. Used Netscan to see what IP address it is set to (either .14 or .44)
2. Inserted the below code and watched in diagnostics. So far I don't see anything coming in.
Anybody have any experience yet?
Thanks so much - Derrick
DEFINE_DEVICE
dvEcho1 = 0:21:0; //Set the IP Address below
dvEcho2 = 0:22:0; //Set the IP Address below
dvEcho3 = 0:23:0; //Set the IP Address below
dvEcho4 = 0:24:0; //Set the IP Address below
dvEcho5 = 0:25:0; //Set the IP Address below
dvEcho6 = 0:26:0; //Set the IP Address below
DEFINE_START //Wasn't sure what port to open so defined multiple ones on different ports
WAIT 200
{
IP_CLIENT_OPEN (3,'192.168.0.151',3663,1)
IP_CLIENT_OPEN (21,'192.168.0.14',1900,3)
IP_CLIENT_OPEN (22,'192.168.0.14',49153,3)
IP_CLIENT_OPEN (23,'192.168.0.14',50000,3)
IP_CLIENT_OPEN (24,'192.168.0.44',1900,3)
IP_CLIENT_OPEN (25,'192.168.0.44',49153,3)
IP_CLIENT_OPEN (26,'192.168.0.44',50000,3)
}
DEFINE_EVENT
DATA_EVENT [dvEcho1]
{
ONLINE:
{
SEND_STRING 0, "'Echo1 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo1 has gone OFFLINE'"
IP_CLIENT_OPEN (21,'192.168.0.14',1900,3)
}
}
DATA_EVENT [dvEcho2]
{
ONLINE:
{
SEND_STRING 0, "'Echo2 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo2 has gone OFFLINE'"
IP_CLIENT_OPEN (22,'192.168.0.14',49153,3)
}
}
DATA_EVENT [dvEcho3]
{
ONLINE:
{
SEND_STRING 0, "'Echo3 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo3 has gone OFFLINE'"
IP_CLIENT_OPEN (23,'192.168.0.14',50000,3)
}
}
DATA_EVENT [dvEcho4]
{
ONLINE:
{
SEND_STRING 0, "'Echo4 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo4 has gone OFFLINE'"
IP_CLIENT_OPEN (24,'192.168.0.44',1900,3)
}
}
DATA_EVENT [dvEcho5]
{
ONLINE:
{
SEND_STRING 0, "'Echo5 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo5 has gone OFFLINE'"
IP_CLIENT_OPEN (25,'192.168.0.44',49153,3)
}
}
DATA_EVENT [dvEcho6]
{
ONLINE:
{
SEND_STRING 0, "'Echo6 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo6 has gone OFFLINE'"
IP_CLIENT_OPEN (26,'192.168.0.44',50000,3)
}
}
I'm trying to integrate the Amazon Echo to my Netlinx master. I've seen snippets of code on the internet that are using a Raspberry Pi, so I'm assuming my Netlinx master can emulate the same function?
http://www.makermusings.com/2015/07/13/amazon-echo-and-home-automation/
Initially I'm simply trying to see the UPnP request the Echo sends out when you say "Alexa, find devices". In order to do that I:
1. Used Netscan to see what IP address it is set to (either .14 or .44)
2. Inserted the below code and watched in diagnostics. So far I don't see anything coming in.
Anybody have any experience yet?
Thanks so much - Derrick
DEFINE_DEVICE
dvEcho1 = 0:21:0; //Set the IP Address below
dvEcho2 = 0:22:0; //Set the IP Address below
dvEcho3 = 0:23:0; //Set the IP Address below
dvEcho4 = 0:24:0; //Set the IP Address below
dvEcho5 = 0:25:0; //Set the IP Address below
dvEcho6 = 0:26:0; //Set the IP Address below
DEFINE_START //Wasn't sure what port to open so defined multiple ones on different ports
WAIT 200
{
IP_CLIENT_OPEN (3,'192.168.0.151',3663,1)
IP_CLIENT_OPEN (21,'192.168.0.14',1900,3)
IP_CLIENT_OPEN (22,'192.168.0.14',49153,3)
IP_CLIENT_OPEN (23,'192.168.0.14',50000,3)
IP_CLIENT_OPEN (24,'192.168.0.44',1900,3)
IP_CLIENT_OPEN (25,'192.168.0.44',49153,3)
IP_CLIENT_OPEN (26,'192.168.0.44',50000,3)
}
DEFINE_EVENT
DATA_EVENT [dvEcho1]
{
ONLINE:
{
SEND_STRING 0, "'Echo1 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo1 has gone OFFLINE'"
IP_CLIENT_OPEN (21,'192.168.0.14',1900,3)
}
}
DATA_EVENT [dvEcho2]
{
ONLINE:
{
SEND_STRING 0, "'Echo2 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo2 has gone OFFLINE'"
IP_CLIENT_OPEN (22,'192.168.0.14',49153,3)
}
}
DATA_EVENT [dvEcho3]
{
ONLINE:
{
SEND_STRING 0, "'Echo3 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo3 has gone OFFLINE'"
IP_CLIENT_OPEN (23,'192.168.0.14',50000,3)
}
}
DATA_EVENT [dvEcho4]
{
ONLINE:
{
SEND_STRING 0, "'Echo4 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo4 has gone OFFLINE'"
IP_CLIENT_OPEN (24,'192.168.0.44',1900,3)
}
}
DATA_EVENT [dvEcho5]
{
ONLINE:
{
SEND_STRING 0, "'Echo5 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo5 has gone OFFLINE'"
IP_CLIENT_OPEN (25,'192.168.0.44',49153,3)
}
}
DATA_EVENT [dvEcho6]
{
ONLINE:
{
SEND_STRING 0, "'Echo6 - ',DATA.TEXT"
}
OFFLINE:
{
SEND_STRING 0, "'Echo6 has gone OFFLINE'"
IP_CLIENT_OPEN (26,'192.168.0.44',50000,3)
}
}
0
Comments
you don't really do anything apart from opening the socket. You do send yourself the message to your termijnal by the "send_string 0"
conversation methods (APIs) are all different. But, typically upon making a connection, something along the lines of either the device says "hello" or it sits there waiting for you to initiate the conversation.
If the device is sitting there waiting for you; then you will probably put something in the ONLINE: event as that is how your code knows that a connection has been established. So you might put a Send_String dvEcho1, 'This is my hello to you' or whatever the conversation starter is.
If on the other hand, the remote device (server) does indeed say howdy first, you will need to watch in the DATA_EVNET>STRING: event and parse for whatever it sends first - prompting you to send your command.
I'm guessing your conversation will go one of those two ways.
You can either do what the guy in that link you shared does and emulate a UPNP responder and multiple socket listener on the AMX master (possibly hard/slow).
Or use the alexa skills kit and a public web server to get hits for data in a chain like echo->amazon->your-public-server->amx.
Either way it's not quite as flexible as I'd like for custom home automation at this point.
When I open the port I get "ONERROR". I'm assuming this is because the Echo doesn't open it's port until you initiate the search for devices?
As this is my first time connecting with a device of this type, I'm assuming systems like Lutron homeworks simply have an open port at all times, and then you connect to it with the login/password?
Initially it would be nice see the string coming from the Echo when you tell it to search for devices. Should I open the port "IP_CLIENT_OPEN (21,'192.168.0.14',1900,3)" right after the Echo starts its search?
I added in this code and got error messages, however at least it seemed like something was trying to come back:
I'm not sure what port the UDP messages are coming in on so I defined 4 ports for 4 different settings:
DEFINE_DEVICE
dvEcho1 = 0:21:0; //Set the IP Address below
dvEcho2 = 0:22:0; //Set the IP Address below
dvEcho3 = 0:23:0; //Set the IP Address below
dvEcho4 = 0:24:0; //Set the IP Address below
Then I opened ports:
DEFINE_START
WAIT 400
{
IP_MC_SERVER_OPEN (21,'192.168.0.17',1900)
IP_MC_SERVER_OPEN (22,'192.168.0.17',50000)
IP_MC_SERVER_OPEN (23,'192.168.0.17',49153)
IP_MC_SERVER_OPEN (24,'192.168.0.17',80)
}
And had string events for seeing what comes back:
DEFINE_EVENT
DATA_EVENT [dvEcho1]
{
ONLINE:
{
SEND_STRING 0, "'Echo1 - ',DATA.TEXT"
}
}
DATA_EVENT [dvEcho2]
{
ONLINE:
{
SEND_STRING 0, "'Echo2 - ',DATA.TEXT"
}
}
DATA_EVENT [dvEcho3]
{
ONLINE:
{
SEND_STRING 0, "'Echo3 - ',DATA.TEXT"
}
}
DATA_EVENT [dvEcho4]
{
ONLINE:
{
SEND_STRING 0, "'Echo4 - ',DATA.TEXT"
}
}
Watching Output diagnostics I got this:
Line 4 (09:41:51):: MCServerOpen IP_ADD_MEMBERSHIP error 0x16
Line 5 (09:41:51):: Memory Available = 32830088 <21456>
Line 6 (09:41:51):: MCServerOpen IP_ADD_MEMBERSHIP error 0x16
Line 7 (09:41:51):: Memory Available = 32814088 <16000>
Line 8 (09:41:51):: MCServerOpen IP_ADD_MEMBERSHIP error 0x16
Line 9 (09:41:51):: Memory Available = 32798088 <16000>
Line 10 (09:41:51):: MCServerOpen IP_ADD_MEMBERSHIP error 0x16
Line 11 (09:41:51):: Memory Available = 32782088 <16000>
Line 12 (09:41:51):: CIpEvent::OnLine 0:21:1
Line 14 (09:41:51):: Echo1 -
Line 16 (09:41:51):: CIpEvent::OnLine 0:22:1
Line 17 (09:41:51):: Echo2 -
Line 18 (09:41:51):: CIpEvent::OnLine 0:23:1
Line 19 (09:41:51):: Echo3 -
Line 20 (09:41:51):: CIpEvent::OnLine 0:24:1
Line 21 (09:41:51):: Echo4 -
Line 15 (10:33:14):: Echo1 - M-SEARCH * HTTP/1.1$0D$0AHOST: 239.255.255.250:1900$0D$0AMAN: "ssdp:discover"$0D$0AMX: 15$0D$0AST: urn:Belkin:device:**$0D$0A$0D$0A
Line 16 (10:33:14):: Echo1 - M-SEARCH * HTTP/1.1$0D$0AHOST: 239.255.255.250:1900$0D$0AMAN: "ssdp:discover"$0D$0AMX: 15$0D$0AST: urn:Belkin:device:**$0D$0A$0D$0A
Line 17 (10:33:17):: Echo1 - M-SEARCH * HTTP/1.1$0D$0AHost:239.255.255.250:1900$0D$0AST:urn:schemas-upnp-org:device:InternetGatewayDevice:1$0D$0AMan:"ssdp:discover"
In order to respond do I now need to open a port via IP_CLIENT_OPEN (dvIPClient.Port,'239.255.255.250',1900,IP_UDP)? I'm not clear on what the (dvIPClient.Port) is on this call? The port where I previously received the broadcast (21)?
Best,
Derrick
you're welcome.
So in your string event for port 1900 UDP you would put something like:
This would tell the echo that you have a wemo switch at IP 192.168.0.150 (substitute the ip of your master) on TCP port 6000 (need a unique port for every virtual switch)
The code you write to listen for switch on/off commands would now need to be written to listen on port 6000 TCP using IP_SERVER_OPEN()
You will have to send one of those reply strings, each with a different port listening on the master for each virtual wemo switch you want to pretend to be.
The code you have listening on port 6000 (or whatever you choose) will initially have to serve the file "/setup.xml" with more details about your fake switch, and then it will need to handle all the other POST requests that the echo will send to that switch --- Congratulations, you're well on your way to writing a web server in NetLinx code.
I think it holds 30 wemo switches and I doubt I'll go over 30 commands.
Thanks again!
Best,
Derrick
1) The ability to pass the raw text from the amazon server speech recognition engine to my server.
The ASK (Amazon skills kit) forces you to spell out every possible combination of words you want to be able to recognize, and if the user triggers one, then your server gets a message. This is far too limiting. Plus it makes you preface all the commands with the tag name of your "skill". Like "Alexa, tell Jarvis to turn on the TV."
or
2) The ability to write an internal app that can get the above data and do things with it inside the local network, like opening a single port to AMX sending requests.
Unfortunately, they seem to be playing favorites with the large manufacturers on this one and they are also probably charging an arm and a leg to get into the platform as an integrated application. Someone like Harmon might be able to get them to allow in integrated application, but independent programmers aren't getting anything in there, yet.
I hear you (no pun intended). Getting the text of the statement would allow us to use our existing speech recognition system exactly as we do for TPControl and Voice Viper, which scans an editable 2,000 item phrase library within the NetLinx in about a second. The size of the library allows 10 versions of every command, so exact phrasing can vary by user or time, and still work. But such a text hand-off from Echo looks unlikely.
However, we are looking at making a single skill that just triggers voice recognition on TPControl to begin, for the sole purpose of not having to press a button to start it. "Alexa, get Cindy," Once we know we should listen, we can start up our CINDY on a nearby Android or iThing with TPControl, and take it from there. Not ideal, but worth the extra hardware if the user really can't press the button... or doesn't want to.
There are several apps for Android that accomplish a hands-free activation, but the most promising of them (UTTER, with offline activation) has had the developer go silent for over a year now. The others seem to be massive battery suckers and likely privacy violation listening and passing everything to Google 24/7. Unacceptable!
Keep in touch if you want to collaborate or share thoughts.
I agree, being able to utilize the voice recognition capability of the Echo and have the raw data would be optimum.
It helps to eliminate the extra invocation to the echo, so you can now set it up to use "Alexa, turn on the lights" instead of "Alexa, tell <myappname> to turn on the lights". This levels the playing field with those other previously "built-in" home control manufacturers who were picked for the beta.
Unfortunately it does not eliminate the need for an "outside the home" server presence to which amazon will relay the user requests.
If you notice in this example diagram there is still no direct control link from the echo right over to the in-home devices:
https://developer.amazon.com/public/...home-skill-api
It might have something to do with where that product lives in the world and where AMX lives. The Echo is kind of a "Resi" product, although not totally. AMX's presence in Resi is pretty muted. I would also add that this kind of product kind of lives in a world all its own too in that there is a trend for manufacturers to not necessarily partner with other things. You can spend a lot of time developing for this platform only to have it totally change on you the next product cycle in 12 months.
In my own time I've spent many hundreds of hours working on things like an IP module for Apple TV/iTunes players where there was no published API but also no one at Apple stopping us from doing it. You'd get it done and working only to have the protocol change one day, thus breaking your code. Another example was with my Autonomics media player. In that case it wasn't the actual manufacturer that broke the module but one of the streaming services served from it. The programmer of the Autonomics software was given resources to fix their web UI but not their control system API. His response was to shrug his shoulders and say, "sucks to be you"
It's a little hard to hang out at the playground when none of the kids really want to play with you.
Cortana will be interesting given the Microsoft connection to corporate IT, but this platform and API is not as mature as the IBM offering and it will be interesting to see it progress. Just before CES, we were announced as the hardware partner for the first consumer Microsoft Cortana device:http://www.zdnet.com/article/harmankardon-readies-a-cortana-powered-speaker/
At CES, we were announced as the hardware partner of the first consumer IBM Watson device: https://www.wired.com/2017/01/lenovos-smart-speaker-marries-alexa-smarts-hardon-karman-sounds/
Additionally, our engineering teams have released speakers with chromecast built in to work seamlessly in a Google Home environment as a wireless audio end point within that eco system. The Harman Connected services team is a core software development partner for Google and I look forward to how this partnership will grow.
There are a number of synergies happening within the Harman engineering community and our trajectory in this space is clear. The JBL Horizon speaker for IBM Watson was designed by the Pro team and the AMX code development efforts behind the current IBM Watson Cognitive Room Experience will serve as a framework for other platforms going forward. I cannot comment on current projects, but I will say that I am excited about the voice control space and what Harman is doing to be a leader in this space for both the Pro and Resi markets.
If HCA only can deliver trigger information based on Alexa's interpretation of the phrases it heard, processed through the skills it has, it's still disappointing... we have a very capable text-parsing engine that runs in the Netlinx and can do a keyword search and match of three input text samples simultaneously through a 1,500 item database match list of phrases and related actions... in under 1 second. This works really well with TPControl's speech-to-text, as well as with Voice Viper. If Alexa could just send us text strings, it would work too.
Collaboration, anyone?
This little software solved my issue of getting Alexa somehow talking to my AMX controller. I agree it is not the most clean way of doing it, but it works. I apologize for not being clear. You can define in the software what word Alexa responds to. You can turn it on or off. So you will always have to start by saying "Alexa, turn on..." or turn off.
I am then sending serial commands out to my NI-3100 from a PC (which I have always running anyways). You can define what you send out, I only send the name of the command in text, like "projector_on". It is quite a bit of work to configure every command, and sure would be easier to get text straight in to AMX without another layer to program.
But I am quite happy how it works for me. It has been very reliable and fast. The light scenes change right before Alexa responds "OK".
Ideally, we hope for a way with Alexa or the Google unit that will be a smart voice gateway with the following capabilities:
1. Hands-free initiation of commands
2. Independent value-add responses (Google search, information, perhaps control of some devices outside the AMX system's control)
3. Ability to transfer AV and AMX-controlled commands to the AMX as text strings, verbatim or ideally simplified (remove "please" and "can you" and "the" etc.) The transfer could be on literal command, such as "Alexa, tell CineTouch...." but better if a different key start word could be used... and/or if whatever command Alexa hears can't be figured out by Alexa, it would be passed to the AMX as text for another look instead of bounced as not understood.
https://github.com/m0ngr31/kodi-alexa
The actual "server" part is stored on the Amazon AWS service. You do need a developer account for it, what [USER="644"]GregG[/USER] is referring to on his earlier posts. I don't know how much better this would be, at least you can have feedback from the object getting controlled. For example I can say "Alexa, ask Kodi which are the latest movies on my list" and I get a reply. Would be interesting to hear how difficult this would be to implement with AMX. Probably too much work because every system would be end up being completely different.