Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details

If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.

Controlling EG from Amazon Echo

If you have a question or need help, this is the place to be.
luma
Posts: 30
Joined: Tue Jan 26, 2010 12:35 am

Controlling EG from Amazon Echo

Post by luma »

I recently received my Amazon Echo which provides limited support for Home Automation devices. Currently only Philips Hue and Belkin WeMo devices are supported directly be Amazon. In looking for a way to talk to SmartThings, I've run across this Java application which emulates the Hue and calls a local URL to trigger actions. It's intended for use with the Vera HA platform but I'm using it for SmartThings and EG. This guide for getting the application running was very helpful in putting together the pieces and providing and interface for issuing REST commands to create devices. You can use the same instructions to create devices which issue events to and EG system runnning the WebServer plugin like this:

Code: Select all

{
"name" : "Roku",
"deviceType" : "switch",
"onUrl" : "http://10.1.2.3/?Living.Room.Roku.On",
"offUrl" : "http://10.1.2.3/?Living.Room.Roku.Off"
}
This will create a Hue light named "Roku". It will be picked up by the Echo when you issue the command "Alexa, discover my devices". Once the Echo has the "light", you can say "Alexa, turn on the Roku" and it will connect to the URL defined in "onURL". In this case I have it connecting to my EventGhost system running the WebServer plugin which will trigger the event "HTTP.Living.Room.Roku.On".

For the moment this only supports "on" and "off" commands, but the author of the bridge tool is adding support for dimming as well. As such, this works best for EG actions that have some semantic relationship to being on/off or bright/dim (soon).
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: Controlling EG from Amazon Echo

Post by techoguy »

this is awesome!

Great find luma!

I have all my insteon lights and SONOS music players tied to EG. I've been looking at ways to connect Echo as well. I was actually going to use the IFTTT and Echo with pushbullet to trigger events in EG (i still might do this for certain commands) but for all my lights, TV (harmony hub actions), and SONOS players, I could use this method which should work much faster than IFTTT. I also have SmartThings but have kind of abandoned it until the new hub comes out. I was getting tired of the delays and errors.

The question now is, Can you access the same phillips hue emulator from the harmony hub app which also controls phillip hue lights? This would be awesome if I can now control my insteon lights with my harmony remote using EG as the translator.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
luma
Posts: 30
Joined: Tue Jan 26, 2010 12:35 am

Re: Controlling EG from Amazon Echo

Post by luma »

techoguy wrote:The question now is, Can you access the same phillips hue emulator from the harmony hub app which also controls phillip hue lights? This would be awesome if I can now control my insteon lights with my harmony remote using EG as the translator.
Just tried it and no, it looks like the emulation isn't good enough to allow the Harmony to pick it up as legit Hue device. I am using HarmonyHubControl to send commands from EG to Harmony but that's a one-way thing and in the wrong direction for your use case. There are others working on Hue emulators for similar reasons, so you might be able to find another project that will successfully present itself to Harmony.
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: Controlling EG from Amazon Echo

Post by techoguy »

Just tried it and no, it looks like the emulation isn't good enough to allow the Harmony to pick it up as legit Hue device
Yeah after a little more digging, the hug emulator isn't really an emulator but a mix of wemo and hue. The UPNP response says it's a WeMo device but the xml says it's Hue. So the harmony remote is probably smart enough to notice that.
http://community.smartthings.com/t/play ... u=techoguy

I have seen other emulators that work with the hub, so I'll have to see if I can find one of those that will work.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
luma
Posts: 30
Joined: Tue Jan 26, 2010 12:35 am

Re: Controlling EG from Amazon Echo

Post by luma »

There's been a new version of the amazon-echo-ha-bridge released with dimmer support here: https://github.com/armzilla/amazon-echo ... tag/v0.1.3

The way dimming support works is that it now supports replaceable tokens in the "onUrl" and "offUrl" values using ${intensity.percent} (0-100 I think) or ${intensity.byte} (0-255). For example, if I create the following emulated light called "Sonos Volume":

Code: Select all

{
"name" : "Sonos Volume",
"deviceType" : "switch",
"onUrl" : "http://10.1.2.3/?Living.Room.Sonos.Volume&${intensity.percent}",
"offUrl" : "http://10.1.2.3/?Living.Room.Sonos.Off"
}
and then say "Alexa, set the Sonos Volume to 70%", the bridge will send the request "http://10.1.2.3/?Living.Room.Sonos.Volume&70" to EG which will trigger an event "HTTP.Living.Room.Sonos.Volume [u'70']".

So far so good. What I don't know is how to take the "70" value I've just been handed and hand that over to the Sonos plugin.
Last edited by luma on Thu May 28, 2015 3:09 am, edited 1 time in total.
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: Controlling EG from Amazon Echo

Post by techoguy »

Hi Luma,

Glad you're following that emulator!
You have the exact same idea I have for integrating Echo and SONOS.

Best of all, my wife is actually using Echo now and won't admit it but likes the seamless integration and ease of use :D

To transfer the dimmer value intensity.percent to sonos, you just need to do this:

Create a Python Command Action (Add Action -> EventGhost -> PythonCommand)
In the text field add this:

Code: Select all

eg.plugins.Sonos.VolumeSet(u'RINCON_XXXXXXXXXXXXX1400', eg.event.payload[0]) 
replace RINCON_XXXXXXXXXXXXX1400 with your SONOS player. This value can be found in a sonos action with the zone player drop down.

Break down of the command:
Any action for any plugin can be called in this way.
eg.plugins. standard for any plugin action and must be included
Sonos - > Plugin name
VolumeSet - > Action
(u'RINCON_XXXXXXXXXXXXX1400', eg.event.payload[0]) - > Variables for the action
u'RINCON_XXXXXXXXXXXXX1400 - > SONOS Player
eg.event.payload[0] - > this is where the payload of the last Event is stored in EG. NOTE that the payload is a list which is why you need [0]
[0] is the first position of the list.

Note, you can get this string and the action variables for any action by adding the action in the GUI, copy the action, then paste into a text editor. This will reveal the plugin name and action variables. (ignore the XML data above and below this line). Also remember to add "eg.plugins." before the string if adding it to a python command or python script.

The other thing to note is if you try to manually activate this macro, the eg.event.payload might be empty or have some other value in it. This can cause an error. This macro should only be triggered by the proper event.
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
luma
Posts: 30
Joined: Tue Jan 26, 2010 12:35 am

Re: Controlling EG from Amazon Echo

Post by luma »

edit: nevermind! I just got home and tried this out and for some reason it's working as expected. Oh man this is going to be cool, now to tie the rest of it together!

Looks like I'm doing something wrong here.

Here is what I have in EG:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="1700">
    <Macro Name="Test set Sonos volume" Expanded="True">
        <Event Name="HTTP.Living.Room.Sonos.Volume" />
        <Action>
            EventGhost.PythonCommand(u"eg.plugins.Sonos.VolumeSet(u'RINCON_BXXXXXXXXXXXX1400', eg.event.payload[0])")
        </Action>
    </Macro>
</EventGhost>
I am sending the command via curl:

Code: Select all

curl http://10.x.x.x/?Living.Room.Sonos.Volume^&10
(note the "^&" thing there is just to escape the ampersand from the windows shell)

EG receives the event like this:

Code: Select all

HTTP.Living.Room.Sonos.Volume [u'10']
and triggers the Action, but the volume doesn't change on the Sonos.

Issuing a manual change via your Sonos plugin works as expected.
luma
Posts: 30
Joined: Tue Jan 26, 2010 12:35 am

Re: Controlling EG from Amazon Echo

Post by luma »

IT'S ALIVE!

I can now do an "Alexa, set the TV to 20%" and it will set the Sonos volume and turn on the TV if it isn't already on. Don't yet have a good way to turn it off with the same commands. Echo really have a problem with recognizing "TV". I tried setting it up as "Tee Vee" and it still has a hard time getting it right, I'm asked to clarify which device I meant basically every time. If I set it to something completely different (say "Bathroom Light") it works extremely well. I cannot use the word "Volume" because "Alexa, set the volume to 20%" is parsed as a request to set the volume on the echo itself.

Still have some work to do, but technoguy's one line of Python was the last bit of glue I needed to make this work. Thanks man!
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: Controlling EG from Amazon Echo

Post by techoguy »

Luma,
I got it working now.
I had the same problems with "volume" in the device name and with the word "TV". I changed my device names to "<Specific Room> music" and "Television" to get it to work better.
I also noticed that the Echo seems to have issues with numbers. If I say "5%" it thinks and sends "50%". Also, when you tell it to "turn on" it sends 100%. These could cause some irritating volume changes so I have disabled volume integration for now. During my testing, I also had to include "lights" in the command to Echo ("Alexa, set the kitchen music lights to 5%") which makes it a little awkward. Hopefully Echo releases their API soon so we can fix this kind of stuff.

Regardless of these little issues, this is still awesome and my wife and I are already using the verbal commands everyday!

I wrote this little code to help with the 100% and making sure the volume isn't accidentally set too high.

Code: Select all

volume = int(eg.event.payload[0])
if volume < 100:
    if volume > 45:
        volume = 45
    eg.plugins.Sonos.VolumeSet(u'RINCON_000XXXXXXXXXX1400', str(volume))
    print "Set Kitchen Volume to ", volume
else:
    eg.plugins.Sonos.Play(u'RINCON_000E58C8DCB201400')
    print "Play Kitchen Music"
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
luma
Posts: 30
Joined: Tue Jan 26, 2010 12:35 am

Re: Controlling EG from Amazon Echo

Post by luma »

I have found that "TV" is recognized pretty well if you enter it as "T.V." with the periods. I'm also seeing issues w/ the Echo parsing the volume levels correctly which can be pretty hard to live with (Sonos at 100% volume is LOUD!). Still, this is pretty damn cool so far!
m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Controlling EG from Amazon Echo

Post by m19brandon »

This is a great find, thanks Luma. I started writing a Amazon Echo app but there SDK sucks, this took an hour to setup any now my wife loves me again.

One error that I get is after every command Alexa tells me this message:
'The device or group name "Kitchen Lights" is not responding at the moment.'

There is a error in the JVM as while. This is only the first line of the stack. Any thoughts?

2015-07-15 20:44:49.669 ERROR 5108 --- [nio-8083-exec-5] com.armzilla.ha.hue.Hue
Mulator : Error calling out to HA gateway

org.apache.http.ConnectionClosedException: Premature end of Content-Length delim
ited message body (expected: 1374; received: 0
krysn95
Posts: 10
Joined: Thu Jul 16, 2015 10:42 am

Re: Controlling EG from Amazon Echo

Post by krysn95 »

Hi Guys,

Maybe this topic is not the best for my post, but I can not find better.

So, one of my biggest dream is a voice control system (just like the amazon echo), but in my language --> Hungarian.

For this, I would like to use a Google speech recognition program (https://chrome.google.com/webstore/deta ... dhkn?hl=hu) what can convert my words for text.

Is it possible to use this text like a plugin in the EG?

For example the recognized text is: Run order 1, and the EG launch the order 1 file if it found this word (prdeer 1) in the text.

I hope it is understandable (sorry for my terrible english)

Here is a picture, about the speech recognizer source code:

Image


Thank you in advance for any help!!!
techoguy
Experienced User
Posts: 157
Joined: Mon Mar 18, 2013 1:32 am

Re: Controlling EG from Amazon Echo

Post by techoguy »

Hi m19brandon,
I actually use that exact phrase: "kitchen lights" But don't get the same issue you see.

Have you confirmed that all the ports that are needed for the emulator are open before starting the JVM?
The Latest SONOS Plugin:
Latest version can be found here: http://eventghost.org/forum/viewtopic.p ... 05f#p30309

EventGhost Lets me automate my home the way I want it, I love using it!
m19brandon
Experienced User
Posts: 177
Joined: Mon Feb 03, 2014 10:36 pm

Re: Controlling EG from Amazon Echo

Post by m19brandon »

I will double check but I believe they are open as I can hit the conf page and the Echo and find the bridge.

I opened an issue on the github project and they say the JVM is getting the 200 success code but erroring out on empty body or payload from the webserver. I need to play with it some more.

Thanks, B
krysn95
Posts: 10
Joined: Thu Jul 16, 2015 10:42 am

Re: Controlling EG from Amazon Echo

Post by krysn95 »

Is it possible to make the next with EG:

If
a concrete webpage is opens in Chrome--> (http://www.example.com)

Than
mark the webpage text --> (simulate ctrl+a)
simulate a right mouse click to a defined place
simulate a left mouse click to a defined place
wait X seconds
close the concrete webpage --> (simulate alt+F4)

(really sorry if this question is lame, but I am totally beginner with this amazing app)

Thank you in advance for every help!
Post Reply