Author Topic: Bridge Amazon Echo to Vera, on github!  (Read 509000 times)

Offline Ramias

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +7/-5
Re: Bridge Amazon Echo to Vera, on github!
« Reply #15 on: April 25, 2015, 07:23:47 pm »
What logs?  Just the output to the console when I execute Java?

I dumped that to a text file but did not see the strings you posted.

What ports other than 8080 do/does this need on my host machine?

I had to stop the SSDP Discovery Service on Windows to free up 1900 UDP (that Java then took when I relaunched it) but I suspect there are more.

There is a unicast/udp port that the app binds to to respond back to the SSDP discovery, default is 50000. You can override using the parameter --upnp.response.port=PORT however i dont think this is the case because the app should have bailed if there were any port conflicts. 

Can we try adding the following parameters to see if we are getting ssdp discovery packets?
--logging.level.com.armzilla.ha.upnp=DEBUG --logging.file=ha.log

Looks like we were posting at the same time.

Here are my two logs from my Windows machine.  I was not able to PM attachments.

Offline Ramias

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +7/-5
Re: Bridge Amazon Echo to Vera, on github!
« Reply #16 on: April 25, 2015, 10:43:00 pm »
Not sure what changed. It this works on windows now.  Ports 1900 and 50000 UDP and 8080 TCP.

Just turned the kitchen lights on and off.

Now... How to build the syntax to populate my other lights and devices (and I assume scenes) to get voice control there :)

This is great work.

Offline Ramias

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +7/-5
Re: Bridge Amazon Echo to Vera, on github!
« Reply #17 on: April 25, 2015, 11:37:47 pm »
I figured I'd post something for those who want to test this out.  This is just a collection of the steps I did to get this to work in my Windows environment.  Many thanks to Arm for sharing this with us.

1.  Download the JAR file.  https://github.com/armzilla/amazon-echo-ha-bridge/releases
2.  Of course, make sure your machine is ready for this.  In my case, Windows and make sure it has the correct Java version installed.
3.  (Optional) You can do some advanced troubleshooting on Windows.  From a CMD prompt, run netstat -ano | find "8080", netstat -ano | find "1900", netstat -ano | find "50000".  You want the response to come up blank.  If it comes up with something else, the number in the last column is the process ID of whatever has that port.  You can use Tasklist to try to find it and shut that service down.  SSDP Discovery could be one of them.
4.  From a CMD Prompt, start the program with this (obviously with your own server's IP address):

Code: [Select]
java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.1.0.jar --logging.level.com.armzilla.ha.upnp=DEBUG --logging.file=ha.log --upnp.config.address=192.168.0.X >log.txt
the --logging and the >log.txt are optional and just pump out some log files.

5.  Make sure you don't have any firewall issues blocking these ports.  Troubleshooting that is outside of this scope.
6.  Make sure things are running by trying to browse to http://192.168.0.X:8080/api/devices.  You should just get some text as a response (but not an error message).
7.  Then, you need to upload your instructions for your Vera devices.  I found this tool here to help with that:  http://www.swensensoftware.com/im-only-resting
In that tool, the URL field is just http://192.168.0.X:8080/api/devices and Method is post. 
I found I had to populate the header box so I just put in this:
Code: [Select]
X-Application-Context: application:8080
Transfer-Encoding: chunked
Date: Sat, 25 Apr 2015 21:14:21 GMT
Server: Apache-Coyote/1.1
Content-Type: application/json; charset=UTF-8

Then in the Body, I put this (you will need your Vera IP, a name you use for the device on the Echo, and the device number (found on the Advanced tab of the device in Vera):
Code: [Select]
{
"name" : "kitchen light",
"deviceType" : "switch",
  "onUrl" : "http://Vera_IP:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=126",
  "offUrl" : "http://192.168.0.70:3480/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=126"
}
8.  Once you've done this and it was submitted correctly, then "Alexa, discover my devices" and then you can say "Alexa turn off kitchen light".
9.  You can use the Vera app on your phone to trigger discovery, or forget previously discovered devices if you have a collision.

Offline Z-Waver

  • Master Member
  • *******
  • Posts: 4431
  • Karma: +247/-120
Re: Bridge Amazon Echo to Vera, on github!
« Reply #18 on: April 26, 2015, 09:03:43 am »
Since the Echo already supports wemo and the Philips Hue I simply wrote something to a fake a Hue gateway.
The Echo does the following to turn on a Wemo device or a Hue bulb:
  • Echo sends out a UPNP discovery request over multicast
  • The Wemo/Hue responds back with a URL for the service descriptor
  • Echo reads the service descriptor and stores that on device
  • When the Echo detects the keyword "Alexa, turn on my <device name>" it looks up the discovered device and changes it state
This more than implies that this is entirely local and that there isn't a plethora of traffic and processing between Echo and Amazon. While that is certainly my desire, I very much doubt that this is the case with Echo, or ever will be.

Can you confirm that this is all local and internet free, or did you simply choose to 'pay no attention to the man behind the curtain'?
Did some leg work for you.  Captured traffic at the router to see the Echo's communication to the outside world.  Please poke any holes you see with my test methodology.

https://youtu.be/CFz15cIvoB0
Thanks for this. It definitely appears to be the case that voice translation and command issuance is completely local without cloudy intervention.

I'm very surprised, impressed, and pleased.

Offline EOppie

  • Jr. Member
  • **
  • Posts: 95
  • Karma: +1/-0
Re: Bridge Amazon Echo to Vera, on github!
« Reply #19 on: April 27, 2015, 10:54:45 pm »
Hey guys, trying to get this running on my Synology NAS...but this is a bit over my head.

Here is the error I got:

SERVE-E> java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.1.0.jar --logging.level.com.a
rmzilla.ha.upnp=DEBUG --logging.file=ha.log --upnp.config.address=192.168.0.X >log.txt
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/armzilla/ha/SpringbootEntry : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:163)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:136)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
        at java.lang.Thread.run(Thread.java:745)

Offline Ramias

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +7/-5
Re: Bridge Amazon Echo to Vera, on github!
« Reply #20 on: April 27, 2015, 10:57:58 pm »
Try without the >log.txt.( that is for windows)  Also make sure it is your server's IP not 192.168.0.x.

Also what version of Java are you using?


Offline arm

  • Sr. Newbie
  • *
  • Posts: 29
  • Karma: +12/-2
Re: Bridge Amazon Echo to Vera, on github!
« Reply #21 on: April 27, 2015, 11:08:23 pm »
Hey guys, trying to get this running on my Synology NAS...but this is a bit over my head.

Here is the error I got:

SERVE-E> java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.1.0.jar --logging.level.com.a
rmzilla.ha.upnp=DEBUG --logging.file=ha.log --upnp.config.address=192.168.0.X >log.txt
Exception in thread "main" java.lang.UnsupportedClassVersionError: com/armzilla/ha/SpringbootEntry : Unsupported major.minor version 52.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
        at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
        at org.springframework.boot.loader.LaunchedURLClassLoader.doLoadClass(LaunchedURLClassLoader.java:163)
        at org.springframework.boot.loader.LaunchedURLClassLoader.loadClass(LaunchedURLClassLoader.java:136)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
        at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:46)
        at java.lang.Thread.run(Thread.java:745)

That is a java version issue.  The target language level is java8 and you will have problems running it if you cannot upgrade the java version on your NAS to java8.  Can you run java -version and see what the version is? 

Offline Gklmdawson

  • Full Member
  • ***
  • Posts: 111
  • Karma: +4/-0
Re: Bridge Amazon Echo to Vera, on github!
« Reply #22 on: April 27, 2015, 11:27:41 pm »
Would this setup also work to bridge the harmony remote through the Phillips hue emulator? I'd love to control vera from my harmony remote.

Offline EOppie

  • Jr. Member
  • **
  • Posts: 95
  • Karma: +1/-0
Re: Bridge Amazon Echo to Vera, on github!
« Reply #23 on: April 27, 2015, 11:39:35 pm »
Thanks everyone for the awesome help!

I followed the instructions here: http://pcloadletter.co.uk/2011/08/23/java-package-for-synology/

and I believe I updated Java to the newer version.

Of course, I now think something else is messed up:

SERVE-E> java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge-0.1.0.jar --logging.level.com.a
rmzilla.ha.upnp=DEBUG --logging.file=ha.log --upnp.config.address=192.168.0.161         
-ash: java: not found

Did I screw up Java?

Offline integlikewhoa

  • Master Member
  • *******
  • Posts: 5574
  • Karma: +150/-367
Re: Bridge Amazon Echo to Vera, on github!
« Reply #24 on: April 28, 2015, 12:01:16 am »
Where do we put the File and do we do anything with it after we download it?

I'm getting the following error.

C:\Windows\system32>java -jar -Djava.net.preferIPv4Stack=true amazon-echo-bridge
-0.1.0.jar --logging.level.com.armzilla.ha.upnp=DEBUG --logging.file=ha.log --up
np.config.address=192.168.1.100 >log.txt
Error: Unable to access jarfile amazon-echo-bridge-0.1.0.jar


EDIT: I got past that part buy just running the file. I can check the browser and I get the info on my light.

I'm currently stuck on getting Echo to "DISCOVER" my deivces. Keeps saying shes not finding it. Firewall off I checked I will not swear "run netstat -ano | find "8080", netstat -ano | find "1900", netstat -ano | find "50000"." and stoped a few things till it was clear, then ran the java and still no luck yet.
« Last Edit: April 28, 2015, 01:09:41 am by integlikewhoa »

Offline mpalensh

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Re: Bridge Amazon Echo to Vera, on github!
« Reply #25 on: April 28, 2015, 12:24:54 am »
Hello all - I've also got this up and running on Windows, and I'm also trying to get it running on my Synology NAS - but it looks like Synology only works up to Java 7, so I've put that on hold for the time being.

I'm able to get the Echo to turn a light on/off by saying "Alexa turn off office light" - it works great.  However, after the light changes state, the top LED spins for about 10 seconds and then the Echo responds "Sorry, but I'm unable to reach the device".  Is this something wrong in my config?
« Last Edit: April 28, 2015, 12:32:49 am by mpalensh »

Offline Ramias

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +7/-5
Re: Bridge Amazon Echo to Vera, on github!
« Reply #26 on: April 28, 2015, 06:28:06 am »
I created a "light switch" for my "kitchen light" and another called "sonos" and a third called "audio".  The last two call the same scenes that turn my sonos on or off. 

I can say "Alexa, turn on kitchen lights" but for the other two I must say "Alexa, switch on sonos". I suspect "sonos" and "audio" are reserved words with Alexa.

Offline Ramias

  • Sr. Member
  • ****
  • Posts: 275
  • Karma: +7/-5
Re: Bridge Amazon Echo to Vera, on github!
« Reply #27 on: April 28, 2015, 06:31:14 am »
Hello all - I've also got this up and running on Windows, and I'm also trying to get it running on my Synology NAS - but it looks like Synology only works up to Java 7, so I've put that on hold for the time being.

I'm able to get the Echo to turn a light on/off by saying "Alexa turn off office light" - it works great.  However, after the light changes state, the top LED spins for about 10 seconds and then the Echo responds "Sorry, but I'm unable to reach the device".  Is this something wrong in my config?

Seems like Alexa or the Java server is not getting a response from your Vera when it calls the URL.  Can you paste in the code you uploaded for your light?

Also just for kicks try going to the Vera app on your phone, settings, hue lights, and forget everything.  Then rediscover. 

Offline mkrieger

  • Newbie
  • *
  • Posts: 8
  • Karma: +0/-1
Re: Bridge Amazon Echo to Vera, on github!
« Reply #28 on: April 28, 2015, 11:27:55 am »
First off - AWESOME! Thanks so much for this great bridge - it really helps things out.

I got things running, but I get the same response as the previous poster. "Sorry, I couldn't reach the device or group name Living Room". The lights do turn on and off.

In the logs, I see this error:
org.springframework.util.InvalidMimeTypeException: Invalid mime type "json": does not contain '/'

One slight departure of what I'm doing is instead of controlling individual lights, I'm using it to control a Vera scene. My code I uploaded is as follows:
{
"name" : "Living Room",
"deviceType" : "switch",
  "onUrl" : "http://192.168.1.24:3480/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=1",
  "offUrl" : "http://192.168.1.24:3480/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=2"
}

Perhaps the java app isn't getting the right response?

Offline integlikewhoa

  • Master Member
  • *******
  • Posts: 5574
  • Karma: +150/-367
Re: Bridge Amazon Echo to Vera, on github!
« Reply #29 on: April 28, 2015, 12:28:48 pm »
I still can't seem to get ECHO to "Discover" my devices despite the port clearing, disabling SSDP and no firewall.

If I knew PI would go smoother I would test with that.