Playing around with Amazon Echo (technical interface discussion)

From a Cnet article on the expansion of the Alexa API. Hopefully ST will work to integrate quickly!

In addition, Amazon says that the Alexa Voice Service that powers Amazon Echo will now be available to third-party device manufacturers.
That means that it might not be long before you start seeing Alexa
showing up in more devices than just Echo. Amazon gives the example of a
Wi-Fi alarm clock with Alexa built-right in, and also mentions that the
smart home brand Wink is looking into borrowing Alexaā€™s smart home
know-how.

1 Like

Iā€™m not a programmer, but it does seem like it should be pretty easy to link ST to the echo with this new release from Amazon.

https://developer.amazon.com/appsandservices/solutions/alexa/alexa-skills-kit

mine isnt working I followed the guide but alexa isnā€™t discovering my devices

Im having the exact same issues. it seems like my devices get created, I get a good response from the web service but the Virtual hub is never discovered on my network.

Mine actually started discovering one or two items for a few minutes after posting this, I needed to clean up some duplicated so I deleted the folder and restarted. After doing that and re-adding all of my endpoints its back to not discovering. I can see in the console that it is querying my emulator app though,

Letā€™s get the party started! I know a few smart developers around here, can someone dive into teaching Alexa new Smartthings tricks, please, with sugar on top.

1 Like

Apologies if this is the wrong place to ask this question but I am trying to use the emulator to get Echo to open a URL which will control a device. The problem is that I tried to run the .jar (after downloading version 8 java) to my Mac and I get:
java -jar -Djava.net.preferIPv4Stack=true ./amazon-echo-bridge-0.1.1.jar --upnp.config.address=192.168.3.100
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:744)

also

java -version
java version "1.7.0_45"
Javaā„¢ SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpotā„¢ 64-Bit Server VM (build 24.45-b08, mixed mode)

The problem appears to be related to Java versions that are present but how to fix?

That doesnā€™t seem to be Java 8 when I do java -v I get:

java -version
java version ā€œ1.8.0_45ā€
Javaā„¢ SE Runtime Environment (build 1.8.0_45-b14)
Java HotSpotā„¢ 64-Bit Server VM (build 25.45-b02, mixed mode)

Quite so. However, Iā€™ve done the install of Java 8 and Oracle verifies it. So it must be a copy that the browser is using. The question is how to get that version for use from the cmdline.

If you go to System Preference:

You can click on java, and manage the runtime environment or update to anew version:

And if I go to System Preferences/Java it shows I have v 1.8

Well it seem that you terminal is linking to Java 1.7, you can either find a way to make the terminal use 1.8 or find the location of 1.8 and use it directly: (macos - What is path of JDK on Mac ? - Stack Overflow)

On my system /usr/bin/java is a symlink to ā€œ/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/javaā€ and in ā€œ/System/Library/Frameworks/JavaVM.framework/Versions/ā€ there is different version and I can do ā€œ/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Commands/java -versionā€ which get me:

java version ā€œ1.6.0_65ā€
Javaā„¢ SE Runtime Environment (build 1.6.0_65-b14-466.1-11M4716)
Java HotSpotā„¢ 64-Bit Server VM (build 20.65-b04-466.1, mixed mode)

If there is a version 1.8 you might be able to use the absolute path instead of ā€œjavaā€

OK. The problem was I installed Java 1.8 JRE but not the full SDK so the Browser and the sys prefs said I was using 1.8 but the cmdline was still using v1.7. I installed the SDK and now the .jar runs fine. Now my problem is registering the the new device. When I try the Post (using Postman), I get:

{
  "timestamp": 1435439647972,
  "status": 415,
  "error": "Unsupported Media Type",
  "exception": "org.springframework.web.HttpMediaTypeNotSupportedException",
  "message": "Content type 'text/plain;charset=UTF-8' not supported",
  "path": "/api/devices"
}

Did you put ā€œContent-Typeā€ to ā€œapplication/jsonā€ in the header of the Postman request?
If I removed mine I get the same response than yours.

I am using Postman (a Chrome App) to construct the Post. Iā€™m not sure I am using it correctly. In particular, after selecting POST and entering the URL of the java server, I enter the body of the POST but Iā€™m not sure that I entering the Header properly. I simply pasted the Header as shown in the instructions above into the area labelled ā€œHeaderā€ but there is also an area labelled ā€œvalueā€. Not sure If I am doing this correctly. It looks like this: http://imgur.com/ji2xPuX

Nah on header on the left you put ā€œContent-Typeā€ and on the right ā€œapplication/jsonā€ the rest of the header settings arenā€™t needed.

OK. Probably getting closer but now I get this: http://imgur.com/N3VIIfV

Almost for some reason on the left field you have ā€œContent-Type: Application/jsonā€ when it suppose to be only ā€œContent-Typeā€ if you look at my previous screenshot you will see the difference.

Thanks for your patience. Now I get this result:

{
  "timestamp": 1435449494008,
  "status": 400,
  "error": "Bad Request",
  "exception": "org.springframework.http.converter.HttpMessageNotReadableException",
  "message": "Could not read JSON: Can not instantiate value of type [simple type, class com.armzilla.ha.api.Device] from String value ('name'); no single-String constructor/factory method\\\n at [Source: java.io.PushbackInputStream@68ad00b7; line: 1, column: 1]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not instantiate value of type [simple type, class com.armzilla.ha.api.Device] from String value ('name'); no single-String constructor/factory method\\\n at [Source: java.io.PushbackInputStream@68ad00b7; line: 1, column: 1]",
  "path": "/api/devices"
}

OK! Not sure what the problem was (perhaps a spurious character in the body) but I reentered it all and it now works! Now able to control HAI Omnipro devices via HaikuHelper. The available vocabulary is a bit limited but fine for certain device types. Thank you for your help!