Amazon Echo to Domoticz Bridge: switches, sensors & more

Alexa, Google Home and Siri

Moderator: leecollings

Post Reply
User avatar
beckdac
Posts: 3
Joined: Thursday 17 December 2015 1:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Seattle, Earth
Contact:

Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by beckdac »

Code is here: https://github.com/beckdac/alexa_domoticz_bridge

Video example is here: https://www.youtube.com/watch?v=BCLQecMM_tg

This setup allows me to make requests through my Amazon Echo (Alexa) to query domoticz about what switches and sensors are available, turn switches on and off and get the temperature from sensors by name and interact with the thermostat. The video shows a pretty typical interaction. The latency is lower than I was expecting, which is nice. Each request goes from the Echo, to Amazon which makes a web service call to my server which does further web service / JSON calls to the domoticz server and then back. A lot of hops but response time is sub second.
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by nayr »

Thank you!

The is probably the only way I can get my wife to do anything with with the automation system..

Curious, is it possible to send announcements to Alexa? ie, "Mailbox was just accessed" or "Landry is finished" and have her announce them to the occupants..
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
User avatar
beckdac
Posts: 3
Joined: Thursday 17 December 2015 1:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Seattle, Earth
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by beckdac »

Apropos spouses... My wife and kids had no interest in using the web browser interface or hand held device apps to use the house automation, but as soon as the Echo came into play, they have become quite involved. Now it is non-stop wife and kids: Turn off this light, turn on that one, turn down the thermostat, turn up the thermostat... I dare say the previously uninterested have discovered a new way to use 'the house' (the Alexa phrase we use) for psychological warfare.

About announcements... Sadly, not yet. Push notifications (similar to what we are familiar with from phones) is not yet available on Alexa, though is reportedly coming soon. I have a second project where I can ask Alexa what's up and she will tell me what notifications are awaiting. Unfortunately, that relies on asking her regularly versus unprompted interaction and it isn't very polished.

If it could be addressed as a bluetooth speaker announcements could be accomplished with a TTS + bluetooth plugin for domoticz. Sadly, this is also not possible, at this time. One thing you might want to look at is Jasper Project: https://jasperproject.github.io/ which I've used in the past. There is a reason I moved away from it, but it still has potential.
darrepac
Posts: 133
Joined: Tuesday 04 February 2014 21:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Isère, France
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by darrepac »

One thing you might want to look at is Jasper Project: https://jasperproject.github.io/ which I've used in the past. There is a reason I moved away from it, but it still has potential.
What's the reason? (I plan to test it in the coming weeks)
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

Congratulations for this wonderful piece ow work! Thank you :)

I'm wondering if it would somehow be possible to avoid routing all the commands through the amazon server and solve that with some local server instead. The benefits are obvious:
1. Faster response time
2. No problem when the Internet is down
3. Less security exposure

Thanks!
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by nayr »

Thats not how the Echo operates, at this point in time.. Amazon does not offer an offline/standalone version.

Sadly all the best voice systems alive right now are cloud based and owned by big privacy sucking mega corps, the standalone versions may be Okay.. but okay is not good enough, I hate arguing with a voice system.. my Volkswagen's voice system drives me bonkers and its quite good given my experiences, it lacks really good noise cancellation so on some stretches of road its useless.. Other times I encounter names are impossible to trigger correctly unless its dead silent and you talk like a robot.

Logically it makes sense, with a big cloud based voice processing system its getting trained by tens of thousands of people continuously.. its going to be dramatically better than any standalone system.
Last edited by nayr on Monday 25 January 2016 10:37, edited 1 time in total.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

Well, I did find a project that can make the Echo work with home automation devices locally (without using Amazon servers):
http://www.instructables.com/id/Hacking ... azon-Echo/

But I don't quite understand how it works and it does not seem to be as easy and versatile as the Amazon Echo to Domoticz Bridge.
However it seems that it's possible to do things in the LAN, without using Amazon servers.

Indeed the cloud has great potential because it's trained by everybody, but the advantages of a local service that I've mentioned above cannot be underestimated.
User avatar
nayr
Posts: 354
Joined: Tuesday 11 November 2014 18:42
Target OS: Linux
Domoticz version: github
Location: Denver, CO - USA
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by nayr »

thats using uPnP media interface to discover its self to the Echo and allow Voice searches to trigger events, its still quite dependent on Amazon's cloud servers and will not work offline.

Its basically faking to be a Media Server and using the ability of the Echo to discover and search local media servers as an easy interface.. alot less capable than the exposed API through amazon.. however it is simpler.
Last edited by nayr on Monday 25 January 2016 10:45, edited 1 time in total.
Debian Jessie: CuBox-i4 (Primary) w/Static Routed IP and x509 / BeagleBone with OpenSprinkler / BeagleBone Planted Aquarium / 3x Raspbery Pi2b GPIO Slaves
Elemental Theme - node-domoticz-mqtt - Home Theatre Controller - AndroidTV Simple OSD Remote - x509 TLS Auth
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

I see... thank you!
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

In the readme file for the Echo to Domoticz bridge it says this:
Overlay onto the Amazon Alexa Skills Kit SDK & Samples. Start by downloading and unpacking the Amazon Alexa Skills Kit SDK & Samples zip file. More information about the Amazon Alexa Skills Kit SDK here: Amazon Apps and Services
Developer Portal. Replace files in the SDK with files from this repository.
I wonder if it means to download this:
https://github.com/amzn/alexa-skills-kit-java
or something else?

I'm also wondering, since this all seems to be Java, if it has some prerequisites, like install some Java-related stuff on the Domoticz machine?

It already fails during rebuild, saying "mvn: command not found".

Can you please provide a few steps for a complete guide to get the Echo to Domoticz Bridge working?

Thank you!
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

Ok, so I figured out that mvn is a thing called Maven and I've installed it on my Raspberry Pi. I can now successfully start the rebuild script, but I get 4 compilation errors. It seems to me that some dependencies might be missing. Can you please help me figure it out?

Code: Select all

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[10,23] package minecrafthelper does not exist
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[86,64] cannot find symbol
  symbol:   class HelloWorldSpeechlet
  location: class Launcher
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[87,64] cannot find symbol
  symbol:   class MinecraftSpeechlet
  location: class Launcher
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[89,64] cannot find symbol
  symbol:   class SessionSpeechlet
  location: class Launcher
[INFO] 4 errors
[INFO] -------------------------------------------------------------
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Skipping Alexa Skills Kit Samples
[INFO] This project has been banned from the build due to previous failures.
[INFO] ------------------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:28 min
[INFO] Finished at: 2016-01-29T08:34:12+02:00
[INFO] Final Memory: 14M/34M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.3:compile (default-compile) on project alexa-skills-kit-samples: Compilation failure: Compilation failure:
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[10,23] package minecrafthelper does not exist
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[86,64] cannot find symbol
[ERROR] symbol:   class HelloWorldSpeechlet
[ERROR] location: class Launcher
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[87,64] cannot find symbol
[ERROR] symbol:   class MinecraftSpeechlet
[ERROR] location: class Launcher
[ERROR] /soft/AmazonEcho/echo_to_domoticz_dridge/alexa-skills-kit-java-master/src/main/java/Launcher.java:[89,64] cannot find symbol
[ERROR] symbol:   class SessionSpeechlet
[ERROR] location: class Launcher
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

I managed to figure it out, the building part at least... This is how to do it:

1. Download the Alexa Skills Kit (Java) zip file from https://github.com/amzn/alexa-skills-ki ... master.zip
2. Download the Domoticz to Amazon Echo Bridge zip file from: https://github.com/beckdac/alexa_domoti ... master.zip
3. Unpack both zip files into a directory (let's call this directory EchoDomoticzBridge for the sake of this example).
4. Overwrite everything in the directory "alexa-skills-kit-java-master" with the files from "alexa_domoticz_bridge-master". In other words copy the contents of the Domoticz bridge into the directory of the Alexa Skills Kit and overwrite everything. You will now have a directory "EchoDomoticzBridge/alexa_domoticz_bridge-master".
4. Go into the directory "EchoDomoticzBridge/alexa_domoticz_bridge-master" which now contains the merged result. Copy the "hellowrold", "minecrafthelper" and "session" subdirectories from samples/src/main/java to src/main/java (next to the "domoticz" sub-directory).
5. In the same src/main/java directory open the Launcher.java file and find the line "import domoticz.DomoticzSpeechlet;" near the beginning of the file. Add 3 more imports: "import minecrafthelper.MinecraftSpeechlet;", "import helloworld.HelloWorldSpeechlet;" and "import session.SessionSpeechlet;"
6. Go back to the merged root directory ("EchoDomoticzBridge/alexa_domoticz_bridge-master"), where the rebuild script is and start the rebuild script (./rebuild). It should now compile fine.

Now I'm no Java developer and I've used Maven for the first time in my life, so perhaps there's a better way to do it, but this works too.

Running it is a different thing, though... I tried to start the run executable. It gave me a warning (I don't know if it matters or not):

Code: Select all

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[WARNING]
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:606)
        at org.codehaus.mojo.exec.ExecJavaMojo$1.run(ExecJavaMojo.java:297)
        at java.lang.Thread.run(Thread.java:724)
Caused by: java.io.FileNotFoundException: /home/dacb/certificate/java-keystore.jks (No such file or directory)
        at java.io.FileInputStream.open(Native Method)
        at java.io.FileInputStream.<init>(FileInputStream.java:146)
        at org.eclipse.jetty.util.resource.FileResource.getInputStream(FileResource.java:282)
        at org.eclipse.jetty.util.security.CertificateUtils.getKeyStore(CertificateUtils.java:43)
        at org.eclipse.jetty.util.ssl.SslContextFactory.loadKeyStore(SslContextFactory.java:863)
        at org.eclipse.jetty.util.ssl.SslContextFactory.doStart(SslContextFactory.java:269)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:118)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:100)
        at org.eclipse.jetty.server.SslConnectionFactory.doStart(SslConnectionFactory.java:64)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:118)
        at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:100)
        at org.eclipse.jetty.server.AbstractConnector.doStart(AbstractConnector.java:259)
        at org.eclipse.jetty.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:81)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at org.eclipse.jetty.server.Server.doStart(Server.java:303)
        at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:69)
        at Launcher.main(Launcher.java:92)
        ... 6 more
After that it just went silent, no output. Maybe it's running?
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

No, it's not running. It wants some kind of private certificate, but I don't know for what it needs it and where to get it from.
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

Ok, I have figured out the second error related to the certificate and to the Java keystore.
You need to generate a self-signed certificate and put it into the appropriate Java keystore, then ediot your pom.xml accordingly.

The process is decribed here (look for the section named "Create a Private Key and Self-Signed Certificate for Testing"):
https://developer.amazon.com/public/sol ... lexa-skill
and here (look for the section named "Setting Up an SSL/TLS Java KeyStore"):
https://developer.amazon.com/public/sol ... a-keystore

I now only have one error but I'm guessing that it doesn't matter?

Code: Select all

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

Fixed the slf4j error too. You have to add the following dependency to the pom.xml:

Code: Select all

 <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.6.4</version>
    </dependency>
Now, when I start the run script, I get the following output, which probably means that the server is working:

Code: Select all

[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Alexa Skills Kit Samples 1.0
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> exec-maven-plugin:1.2.1:java (default-cli) > validate @ alexa-skills-kit-samples >>>
[INFO]
[INFO] <<< exec-maven-plugin:1.2.1:java (default-cli) < validate @ alexa-skills-kit-samples <<<
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:java (default-cli) @ alexa-skills-kit-samples ---
593 [Launcher.main()] WARN com.amazon.speech.speechlet.servlet.SpeechletServlet - No timestamp tolerance has been configured, disabling timestamp verification
641 [Launcher.main()] WARN com.amazon.speech.speechlet.servlet.SpeechletServlet - No timestamp tolerance has been configured, disabling timestamp verification
654 [Launcher.main()] WARN com.amazon.speech.speechlet.servlet.SpeechletServlet - No timestamp tolerance has been configured, disabling timestamp verification
659 [Launcher.main()] WARN com.amazon.speech.speechlet.servlet.SpeechletServlet - No timestamp tolerance has been configured, disabling timestamp verification
683 [Launcher.main()] INFO org.eclipse.jetty.server.Server - jetty-9.0.6.v20130930
893 [Launcher.main()] INFO org.eclipse.jetty.server.handler.ContextHandler - Started o.e.j.s.ServletContextHandler@6714db{/,null,AVAILABLE}
2499 [Launcher.main()] INFO org.eclipse.jetty.server.ServerConnector - Started ServerConnector@1ae9b8b{SSL-HTTP/1.1}{0.0.0.0:4443}
Not sure what that timestamp warning means, though...
mrayn
Posts: 3
Joined: Sunday 21 February 2016 16:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by mrayn »

Trying to get this to work as it's very nearly the exact thing I am wanting to do. I can't even get the maven set up and working though.

Anyone having any luck with it? I tried getting maven to build the OP's project and couldn't. I even went back to the files straight from amazon and can't get maven to build those either.
mrayn
Posts: 3
Joined: Sunday 21 February 2016 16:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by mrayn »

I was able to get it all installed and have it running locally. Went back and checked my java environment variable, set it, and reinstalled everything. I then went through the amazon tutorial and tested on of those skills locally. After this is copied over his files and rebuild and fixed compile errors until it built.

Next step is to hook it up to an Alexa skill. I'm assuming you put HTTPS for the endpoint but I'm not sure what URL this is making when I'm running it.

I'm currently trying https://<domain>:4443/domoticz but it doesn't seem to work. It seems to be the correct page but just not working. Manually navigating to it returns a 405 "HTTP method GET is not supported by this URL" while a curl call returns 404.

Any help on this would be appreciated!
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

Unfortunately, getting this project up and running is a huge effort. It took me quite a few days to completely figure it out. It's working now, though, so I may be able to help with specific questions. The URL I use is https://<domain>/domoticz (no prt specified here, it defaults to 443 automatically). Note that in my local router I have a mapping from port 443 to an internal port 4443 because 4443 is the port specified in one of the source files for the Domoticz to Echo bridge.
mrayn
Posts: 3
Joined: Sunday 21 February 2016 16:39
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by mrayn »

BazsoDombiAndras wrote:Unfortunately, getting this project up and running is a huge effort. It took me quite a few days to completely figure it out. It's working now, though, so I may be able to help with specific questions. The URL I use is https://<domain>/domoticz (no prt specified here, it defaults to 443 automatically). Note that in my local router I have a mapping from port 443 to an internal port 4443 because 4443 is the port specified in one of the source files for the Domoticz to Echo bridge.
Wonderful! That seemed to do the trick. Have you figured out how to get it to start everytime the pi boots? or to restart if it crashed for some reason?

I'm probably going to have to do some recoding on this, my domoticz switches all have an underscore in them, you can't include an _ in the utterance. (at least no on testing)
User avatar
BazsoDombiAndras
Posts: 56
Joined: Thursday 08 January 2015 9:52
Target OS: Raspberry Pi / ODroid
Domoticz version: v4.10717
Location: Cluj-Napoca, Romania
Contact:

Re: Amazon Echo to Domoticz Bridge: switches, sensors & more

Post by BazsoDombiAndras »

I have modified the run script so that it works with the directory from which it is run, not with the current Linux directory. This makes it possible to call it from elsewhere. So I could add it to /etc/rc.local to be called on startup.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest