HouseBot and Amazon Echo

Simple advice that you may find useful. Feel free to discuss or add your own.
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

HouseBot and Amazon Echo

Post by ScottBot »

It is possible to have your Amazon Echo control HouseBot. There is no native support (EDIT: There is now a native Alexa Smart Home Skill for HouseBot. Look for it in your Alexa app :!: ) for this in HouseBot, however, due to a hack that makes a running piece of software look like an automation bridge, it's possible to trick the system into working. The setup is a little convoluted, but if you're a die-hard DIYer, it should be fun.

The steps below will build this out from HouseBot to Echo.

Create External Control Device
Create an External Control Device in HouseBot. Specify a unique port for this device. Do NOT use the ASCII protocol. Password is optional (not used in this example). External control devices are an easy and flexible way to control HouseBot from other systems.

Configure Webserver
Configure a webserver (either running on the HouseBot server machine, or on a machine that has network access to the HouseBot server) to use the HB_Control program via CGI. The online help for the External Control Device goes into more specifics on the setup, but much of the setup will depend on the webserver you are using. Essentially, you need a URL that points to the webserver to execute HB_Control.exe (or HB_Control.cgi, if you rename it).

Test this setup before going any further. You need to understand the URL format to fully configure the system at the end, so this will give you a good opportunity to make sure the webserver/cgi and external control device is setup correctly.

Generally, you should be able to enter a URL such as the one below and have it change the value of a Property in HouseBot.

Code: Select all

http://192.168.1.2:8000/cgi-bin/HB_Control.cgi?I=127.0.0.1&O=9876&C=SPV&D=Hall%20Light&P=Power%20State&V=On
      Webserver IP:Port/path   /HB Control EXE?HB Control Parameters (below)
      I = HouseBot server IP address
      O = Port configured in External Control Device (step 1)
      C = SPV (Set Property Value).  Other actions can also be used
      D = Device to control
      P = Property of Device to control
      V = Value to set
Note: be sure to encode the url correctly. For example, spaces in device and property names should be replaced with %20.

You can use any of the different control options that the external control offers. For example, you could also execute a Task by creating a device in the echo bridge and using the On and Off URLs to call different execute task urls.

Install the Amazon Echo Bridge
The source and setup information for the bridge can be found in GitHub. The readme says that there is a pre-built jar file, but it's not in the current repository. I had to build it with Maven following the instructions in the readme. You will need to make sure you have Java installed to run it and the JDK to build it.

Build the jar file on the machine that is running HouseBot. It can run on any machine on the network, but to keep things simple (and follow these setup instructions) put it on the HouseBot machine.

Create a batch/command file (and add it to the startup group) to run the Echo Bridge with the following command.

Code: Select all

java -jar "<path to jar>\amazon-echo-bridge-0.2.1.jar" --upnp.config.address=192.168.1.100 --server.port=8081
Note that the actual .jar filename may be different depending on the version of source that you are using.
--upnp.config.address should be set to the IP address of the machine that it is running on.
--server.port can be set to any available port.

Configure Bridge
After the Echo Bridge process has started and fully initialized, you can enter the URL below to access the device settings for the bridge.

Code: Select all

http://localhost:8081/configurator.html
You can substitute 'localhost' with the IP of the machine that the process is running on if you are not running a browser on the same machine.

This is the configuration page where the associations between the device name that you will ask Alexa/Echo to control and the URLs that will execute the action are setup. It only supports Off and On (and Dim) commands, but you can be a little creative and do anything that the External Control Device supports.

For example, to turn on the 'Foyer Light' (assuming you have a Device setup in HouseBot named 'Foyer Light'), you would enter Foyer Light in the Name field. The On URL would be something like:

Code: Select all

http://192.168.1.100:8000/cgi-bin/HB_Control.cgi?I=127.0.0.1&O=9876&C=SPV&D=Foyer%20Light&P=Power%20State&V=On
The Off URL would be something like:

Code: Select all

http://192.168.1.100:8000/cgi-bin/HB_Control.cgi?I=127.0.0.1&O=9876&C=SPV&D=Foyer%20Light&P=Power%20State&V=Off
These should be the same URL formats that were tested with the webserver after the CGI was setup.

Test each of the URLs using the buttons on the configuration page to make sure they work as expected. Click the Add Device button to add the device to the bridge. Do this again for each device you want to be able to control using the Echo.

Discover Devices
After all of the devices have been setup in the bridge, have the Echo re/discover the devices by saying "Alexa, discover my devices" (or by using the app). After the discovery process is complete, you can control the devices. For example, to turn on the Foyer Light, you would just say "Alexa, turn on the Foyer Light".

There are a lot of technical details in this post, and it's possible that I forgot things or copied something down wrong. I realize that with the different processes, IP & Ports, URLs, etc., it can be confusing to setup initially. If you have any questions, feel free to ask in this post.
Scott
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

Fascinating. I had wondered whether it would be possible to interface with an Echo. Now I know. Well done Scott. Over my head from an implementation standpoint (Maven? Build a Jar file..?) but cool just the same. :D
Steve
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: HouseBot and Amazon Echo

Post by ScottBot »

Hopefully things can be simplified moving forward. I'm working on an External Control Device option that would remove the requirement for the webserver. I could probably package up the jar file for a single unzip-installation too.
Scott
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

That would be great, and just the incentive I need to get an Echo. May get one in anticipation of a HB plugin or comparable cobble-together. See what you've done? :D
Steve
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

I spent a little time wandering through the "cottage industry" that has popped up in support of the Echo. There is a LOT going on out there. The Echo has GOT to be an addition to the HB family of plugins. To me, the ability of HB to work with Echo is the biggest thing since the creation of the Android swremote. Once the procedure to link the two becomes more turnkey, postings placed on the various Echo forums about Housebot-with-Echo will generate interest in HB.
Steve
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

I found what appears to be the prebuilt jar file here:
https://github.com/armzilla/amazon-echo ... e/releases
Have not done anything further on the echo/HB integration yet due to other non-HB stuff. But I was concerned about going down another rabbit hole trying to create the echo ha jar.
The Echo is an interesting if not yet a fully baked device. One recent comment on an Echo forum indicated what sounded like a lack of full commitment by Amazon to support and develop the Echo platform to what it's potential. I guess we'll see.
Steve
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: HouseBot and Amazon Echo

Post by ScottBot »

Steve Horn wrote:...One recent comment on an Echo forum indicated what sounded like a lack of full commitment by Amazon to support and develop the Echo platform to what it's potential. I guess we'll see.
I know they are somewhat serious about it. They have 100 million dollar fund to back *some* development.

It's also cool the way it's implemented. The real Alexa is just a software solution residing in the cloud that anyone can develop against. The Echo is just one possible endpoint. So it will be interesting to see what other endpoints are developed.
Scott
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

Interesting.. And somewhat reassuring. The reply I received was in part a response to a post I made about the need to be able to handle multiple additions to the ONE shopping list in one request, I.e. "Alaexa, add bacon and beans to my shopping list." The reply, apparently from a former echo developer, indicated that "they" really didn't plan on developing for more complex requests. He followed that up with the statement about funding being cut for the echo program. You're right though, a lot of potential there just waiting to be used. I guess we need to stay tuned. "Alexa, what you got up your sleeve?" :D
Steve
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: HouseBot and Amazon Echo

Post by ScottBot »

Another cool tool that extends Alexa is ifttt (if this then that). You can install it on your phone and setup various event triggers from Alexa. It's also still a little limited, but I'm sure will continue to add trigger (IF) types for Alexa as time goes on.
Scott
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

I had read a bit on that and it's on the list of things to pursue. Still need to get back to HB-Echo integration... When other chores get out of the way.
Steve
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

I downloaded a pre-built jar file from here https://github.com/armzilla/amazon-echo ... e/releases, built a BAT file, put it in the startup folder, rebooted and tried going to the configurator html. got Error - connection refused. Downloaded and installed Java 8 runtime, went to that directory and manually entered the BAT file command (java -jar....) using command.com. Got gobs of stuff back, none of it looked positive, and same result - err connection refused. Not sure what else to try at this point.
Steve
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: HouseBot and Amazon Echo

Post by ScottBot »

Can you tell what it's trying to connect to that is giving the error? You might want to just fully disable your firewall and try it to see if there's a blocked port or something. It does output quite a bit of info/garbage when it's starting up

My startup looks like this:
java -jar "<path to jar>\amazon-echo-bridge-0.2.1.jar" --upnp.config.address=192.168.1.100 --server.port=8082

The IP is the address of the computer it's running on, and the port is the admin/config/HTTP port. Maybe try connecting to it on the admin port in your browser to see if there are any indications of the issue there.
Scott
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

Tried as you suggested - shutting down Windows Firewall. And as a precaution turned off antivirus stuff. Also looked in Chrome settings to see if there is anything that would block specific ports. Same result.
I as able to capture the string of Java stuff during the Jar processing. The only thing that looked REALLY odd (as most of it looked just normally odd to me) was this:

2015-11-26 15:02:21.511 ERROR 1144 --- [pool-1-thread-1] com.armzilla.ha.upnp.Up
npListener : UpnpListener encountered an error. Shutting down

java.net.BindException: Address already in use: Cannot bind
....


I have no idea what that means, but thinking it might be an issue with the port I assigned, I changed it to several others, all with the same result.

Any ideas? The only other thing I could come up with is for you to try using the jar file at the address I found, posted above and here:
https://github.com/armzilla/amazon-echo ... e/releases. I would assume that your created jar results in the same as this one. But maybe not. I'll also look further online to see if others have had any success or issues with that jar.
Steve
ScottBot
Site Admin
Posts: 2786
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Re: HouseBot and Amazon Echo

Post by ScottBot »

Here's the same snippet from my output

Code: Select all

2015-11-27 13:18:51.512  INFO 9824 --- [pool-1-thread-1] com.armzilla.ha.upnp.UpnpListener        : Starting UPNP Discovery Listener
2015-11-27 13:18:51.774  INFO 9824 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8082 (http)
2015-11-27 13:18:51.777  INFO 9824 --- [           main] com.armzilla.ha.SpringbootEntry          : Started SpringbootEntry in 13.167 seconds (JVM running for 13.998)
The error may have to do with port 1900, if you look at the code. It's possible that you have some other service running on the same computer that is listening on the same UPNP port.
Scott
Steve Horn
HouseBot Guru
Posts: 747
Joined: Wed Apr 02, 2003 8:10 pm
Location: Pelham AL

Re: HouseBot and Amazon Echo

Post by Steve Horn »

Appears to be 4 services running as part of svchost PID 1916, which is using port 1900 according to a netstat -ao.
They are:
upnphost
SSDP discovery
Function Discovery Resource publication
Windows Connect Now Config Registrar

After fooling with the security, I was able to stop each one, one at a time and rerun the bat file. No help.

Found from netstat that Java SE (pid 3328) was also listening on 1900. Stopped it too. Same result.

Seems to me that all or almost all of the above would be needed to make all this work.
Haven't given up. But I'm close.

Edit: am going to try running the jar on a separate Windows sandbox machine. If that works I'll just leave it there. Stupid, but at least it will work.

Another edit/update: Was able to run the jar on a sandbox PC without errors. Built one device in the configurator, Echo discovery was successful and now Alexa can control one HB device. OK! Takes two PCs to do it but OK! :D
Steve
Post Reply