User Tools

Site Tools


2016:ha:control_openhab_with_alexa

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
2016:ha:control_openhab_with_alexa [2016/05/11 14:34] 75.177.137.22016:ha:control_openhab_with_alexa [2016/05/11 16:45] (current) – [CONTROL OPENHAB ITEMS USING Alexa] 75.177.137.2
Line 1: Line 1:
-===== CONTROL OPENHAB ITEMS USING THE AMAZON ECHO =====+===== CONTROL OPENHAB ITEMS USING Alexa ===== 
 +Original blog is here: 
 +  * {{:2016:ha:alexa_openhab_echo.htm|Controlling OpenHab Items with Alexa}}
 ==== INTRODUCTION ==== ==== INTRODUCTION ====
 Having a digital personal assistant, like Jarvis from Iron Man, is the ultimate geek dream.  Over the past few years, most of the major tech companies have attempted to turn this dream into reality.  Apple has Siri, Microsoft has Cortana, and Google has Google Now.  Even some smaller companies have tried their hand:  SoundHound recently launched their Hound app which focuses on natural language processing and a speedy response to your queries.  All of these companies have something in common, though.  They’re all focused on using your mobile phone as the input device. Having a digital personal assistant, like Jarvis from Iron Man, is the ultimate geek dream.  Over the past few years, most of the major tech companies have attempted to turn this dream into reality.  Apple has Siri, Microsoft has Cortana, and Google has Google Now.  Even some smaller companies have tried their hand:  SoundHound recently launched their Hound app which focuses on natural language processing and a speedy response to your queries.  All of these companies have something in common, though.  They’re all focused on using your mobile phone as the input device.
Line 36: Line 38:
 This is where the Postman Chrome extension comes into handy.  We need to upload our configuration data in JSON format using a RESTful API.  Don’t freak out!  It’s not that hard.  I’ll walk you through it. This is where the Postman Chrome extension comes into handy.  We need to upload our configuration data in JSON format using a RESTful API.  Don’t freak out!  It’s not that hard.  I’ll walk you through it.
  
-When you open Postman, you need to make sure the settings are correct.  You need to make sure you’re in POST mode, have the correct address filled in. It should be http://<ip address>:8080/api/devices)and have raw data and JSON selected.  Questions?  Refer to the picture below!  I’ve highlighted all of the critical areas.\\+When you open Postman, you need to make sure the settings are correct.  You need to make sure you’re in POST mode, have the correct address filled in. It should be  
 +<code> 
 +http://<ip address>:8080/api/devices) 
 +</code> 
 +and have raw data and JSON selected.  Questions?  Refer to the picture below!  I’ve highlighted all of the critical areas.\\
 {{:2016:ha:postman-settings.png?400|}}\\ {{:2016:ha:postman-settings.png?400|}}\\
 Now we need to post the data.  Refer below for an example of a setting I’m using.  Lights is an OpenHAB Group that turns all of my lights either on or off.  “All the lights” is the string that your Echo will react to.  Make sure this is a good description for your light or item.   Now we need to post the data.  Refer below for an example of a setting I’m using.  Lights is an OpenHAB Group that turns all of my lights either on or off.  “All the lights” is the string that your Echo will react to.  Make sure this is a good description for your light or item.  
Line 51: Line 57:
 } }
 </code> </code>
-{{:2016:ha:postman-rest-call.png400|}}\\ +{{:2016:ha:postman-rest-call.png?400|}}\\ 
-When you are finished making your changes, click “Send” on Postman.  It will scroll down and show you some output from the HA Bridge so you know it worked.  You’ll need to scroll back up and repeat the process for each and every device you want to control with your Amazon Echo.+When you are finished making your changes, click “Send” on Postman.  It will scroll down and show you some output from the HA Bridge so you know it worked.  You’ll need to scroll back up and repeat the process for each and every device you want to control with your Amazon Echo.\\
 {{:2016:ha:postman-output.png?300|}}\\ {{:2016:ha:postman-output.png?300|}}\\
-When you’re finally done uploading devices, go to Chrome or your browser of choice and navigate to http://<Amazon HA Bridge IP>/api/devices.  You should see all of your loaded devices there.+ 
 +When you’re finally done uploading devices, go to Chrome or your browser of choice and navigate to \\ 
 +<code> 
 +http://<Amazon HA Bridge IP>/api/devices.   
 +</code> 
 +You should see all of your loaded devices there.\\
 {{:2016:ha:loaded-devices.png?400|}}\\ {{:2016:ha:loaded-devices.png?400|}}\\
 ==== STEP 3: LOAD SETTINGS INTO YOUR AMAZON ECHO ==== ==== STEP 3: LOAD SETTINGS INTO YOUR AMAZON ECHO ====
  
-On your phone, launch the Echo app.  Open the Settings page and scroll all the way down where it says “Connected Home”.  Click the button that says “Add new devices” and wait!  The Echo should find all of the devices you uploaded into the Echo HA Bridge.  Congrats!  Now you can tell your Echo to “turn the kitchen light on” or “turn all the lights on”, or whatever you configured!  Kick back and tell Alexa what you want her to do while you’re watching TV, entertaining friends, or doing the dishes!+On your phone, launch the Echo app.  Open the Settings page and scroll all the way down where it says “Connected Home”.  Click the button that says “Add new devices” and wait!  The Echo should find all of the devices you uploaded into the Echo HA Bridge.  Congrats!  Now you can tell your Echo to “turn the kitchen light on” or “turn all the lights on”, or whatever you configured!  Kick back and tell Alexa what you want her to do while you’re watching TV, entertaining friends, or doing the dishes!\\ 
 ==== Comments ==== ==== Comments ====
  
Line 162: Line 174:
 1) The only real way to do it is to open the Echo App, go to Settings–>Connected Home, and scroll to the bottom. Hit “Forget All Devices” (don’t worry, it will preserve persistent devices like *actual* HUE hardware). Then you can start over with posting the soft devices. 1) The only real way to do it is to open the Echo App, go to Settings–>Connected Home, and scroll to the bottom. Hit “Forget All Devices” (don’t worry, it will preserve persistent devices like *actual* HUE hardware). Then you can start over with posting the soft devices.
  
-2) Definitely fully-qualified *localhost* URLs (not on port 8080), with codes in place of special characters.+2) Definitely fully-qualified *localhost* URLs (not on port 8080), with codes in place of special characters.\\ 
 <code> <code>
 Example: “onUrl” : “http://localhost/ph-cgi/formula?formula=ph_macroparm(%27IRR_ON_MANUAL%27,6,15,0,0,0)” Example: “onUrl” : “http://localhost/ph-cgi/formula?formula=ph_macroparm(%27IRR_ON_MANUAL%27,6,15,0,0,0)”
 </code> </code>
 +
 Aaron, this is really nice!! thanks for the write-up!! Aaron, this is really nice!! thanks for the write-up!!
-I now have my first insteon light switch working now with the echo and openhab..+I now have my first insteon light switch working now with the echo and openhab..\\
  
 I am not sure how to edit the device list. Is there an easy way to edit the api/devices? I am not sure how to edit the device list. Is there an easy way to edit the api/devices?
Line 176: Line 190:
 Thanks again. Thanks again.
  
-Reply +Reply\\ 
-Aaron Tinsley says:+Aaron Tinsley says:\\
    
 Jay, Jay,
Line 183: Line 197:
 No problem! I’m glad it helped. As far as editing the device list for the Bridge, the honest answer is I don’t know. I did my initial setup and have mostly left it alone since then. I may pore over the source code and look for the answer. The only time I’ve spent in the source code thus far was to figure out how to change the listening port. No problem! I’m glad it helped. As far as editing the device list for the Bridge, the honest answer is I don’t know. I did my initial setup and have mostly left it alone since then. I may pore over the source code and look for the answer. The only time I’ve spent in the source code thus far was to figure out how to change the listening port.
  
-All of the commenters have made one thing clear… I’m way behind some of you in home automation! Good luck with your sprinkler system!+All of the commenters have made one thing clear… I’m way behind some of you in home automation! Good luck with your sprinkler system!\\
  
-  +Other people probably figured out how to have Alexa dim lights without needing it explained to them, but I thought I would comment and potentially save someone some time:
-Spencer says: +
- +
  
-So getting *someprogress here, but had few questions about the mechanics of device entry:+As of 0.1.3, the Echo-HA-Bridge supports dimming. In the Configurator page, use these URLs:\\ 
 +<code> 
 +On URL: http://:8080/CMD?Light=${intensity.percent} 
 +Off URL: http://:8080/CMD?Light=OFF 
 +</code> 
 +I got it working tonight with 0.2.1 and OpenHAB 1.7.1, both running on Windows 10.\\ 
 +**Controlling TV**\\ 
 +I’m going bananas over this :) Probably to much fiddling around. I got Openhab to work with my LG TV. Wehn I try Armzilla to connect Echo it either gives me blanc page while testing or XML error. In my items file in openhub I have:\\ 
 +<code> 
 +Group TV_Living “Tv Room” (LgTv) 
 +Switch LgTvPower “Power Command” (GF_Living) {lgtv=”ON:Tv Room:POWER”} 
 +Switch LgTvMute “Mute” (GF_Living) {lgtv=”ON:Tv Room:KEY_MUTE, OFF:Tv Room:KEY_MUTE”} 
 +Number LgTvVolume “lgVolume [%.1f]” (GF_Living) {lgtv=”INIT:Tv Room:VOLUME_CURRENT, INCREASE:Tv Room:VOLUME_UP, DECREASE:Tv Room:VOLUME_DOWN, *:Tv Room:VOLUME_SET”} 
 +Number LgTvChannel “Channel [%.1f]” (GF_Living) {lgtv=”INIT:Tv Room:CHANNEL_CURRENTNUMBER, INCREASE:Tv Room:CHANNEL_UP, DECREASE:Tv Room:CHANNEL_DOWN, *:Tv Room:CHANNEL_SET” } 
 +String LgTvChannelName “Channelname [%s]” (GF_Living) {lgtv=”INIT:Tv Room:CHANNEL_CURRENTNAME”} 
 +String LgTvGetChannels “getchannels [%s]” (GF_Living) {lgtv=”INIT:Tv Room:GET_CHANNELS, ON:Tv Room:GET_CHANNELS”} 
 +String LgTvGetApps “getapps [%s]” (GF_Living) {lgtv=”INIT:Tv Room:GET_APPS, ON:Tv Room:GET_APPS”} 
 +String LgTvAppExecute “excuteapp” (GF_Living) {lgtv=”*:Tv Room:APP_EXECUTE”} 
 +String LgTvAppTerminate “terminateapp” (GF_Living) {lgtv=”*:Tv Room:APP_TERMINATE”} 
 +Switch LgTvConnStatus “connstatus ” (GF_Living) {lgtv=”*:Tv Room:CONNECTION_STATUS”} 
 +</code> 
 +Can anyone please give me an example URL I should use to get this working? Openhab, Armzilla and Lovely Alexa so she will start Netflix :)\\
  
-1) So let’s say you make a boo boo” while entering a device…is there a way to delete” it from the bridge?+I tried:\\ 
 +<code> 
 +
 +“name” : “Netflix”, 
 +“deviceType” : “switch”, 
 +“onUrl” : “http://127.0.0.1:8080/CMD?TV_Living=excuteapp”, 
 +offUrl” http://127.0.0.1:8080/CMD?TV_Living=terminateapp 
 +
 +</code> 
 +But also: 
 +<code> 
 +http://localhost:8080/rest/items/LgTvAppExecute?jsoncallback=callbackapp 
 +</code> 
 +In my sitemap I have: (works great via webpage)\\ 
 +<code> 
 +Switch item=LgTvAppExecute label=”AppExecute” mappings=[Netflix=Netflix] 
 +Switch item=LgTvAppTerminate label=”AppTerminate” mappings=[Netflix=Netflix] 
 +</code> 
 +I must say, I have 0 coding experience :)\\
  
-2) Alsodoes Postman want fully-qualified URLs with codes, or will it accept quotes, spaces, etc. verbatim?+Kind regards,\\ 
 +Frank\\
  
-Thanks,+Aaron Tinsley says:\\
  
--S+Frank,\\
  
- +Your URL should directly address the itemnot the group it’s inI haven’t tried controlling string items (just switch items)but you can try this.\\
-Spencer says: +
- +
-Learned a lot in this process and am answering my own questions for those who may have similar questions: +
- +
-1) The only real way to do it is to open the Echo Appgo to Settings–>Connected Home, and scroll to the bottomHit “Forget All Devices” (don’t worryit will preserve persistent devices like *actual* HUE hardware). Then you can start over with posting the soft devices. +
- +
-2) Definitely fully-qualified *localhost* URLs (not on port 8080), with codes in place of special characters.+
 <code> <code>
-Example: “onUrl” : “http://localhost/ph-cgi/formula?formula=ph_macroparm(%27IRR_ON_MANUAL%27,6,15,0,0,0)”+http://localhost:8080/CMD?LgTvAppExecute=[value]
 </code> </code>
-Aaron, this is really nice!! thanks for the write-up!! +[value] should be a URL-encoded stringTo URL encode a stringgo to this linktype your string in the “Plain” box, and then hit the button that says “URLEncode”. It will output the URL-encoded string in the Encoded” box.\\
-I now have my first insteon light switch working now with the echo and openhab.+
- +
-I am not sure how to edit the device list. Is there an easy way to edit the api/devices? +
-or is it easier to clear the data folder and start over? +
- +
-Now if I could just get my insteon sprinklers setup in openhabI will be set to go!! +
- +
-Thanks again. +
- +
-  +
-Aaron Tinsley says: +
-  +
-Jay, +
- +
-No problem! I’m glad it helped. As far as editing the device list for the Bridgethe honest answer is I don’t know. I did my initial setup and have mostly left it alone since then. I may pore over the source code and look for the answer. The only time I’ve spent in the source code thus far was to figure out how to change the listening port. +
- +
-All of the commenters have made one thing clear… I’m way behind some of you in home automation! Good luck with your sprinkler system! +
- +
-Spencer says+
- +
-Hi Gang, +
- +
-So getting *some* progress here, but had a few questions about the mechanics of device entry: +
- +
-1) So let’s say you make a boo boo” while entering a device…is there a way to “delete” it from the bridge? +
- +
-2) Also, does Postman want fully-qualified URLs with codes, or will it accept quotes, spaces, etcverbatim? +
- +
-Thanks, +
- +
-Spencer says: +
- +
-Learned a lot in this process and am answering my own questions for those who may have similar questions: +
- +
-1) The only real way to do it is to open the Echo App, go to Settings–>Connected Home, and scroll to the bottom. Hit “Forget All Devices” (don’t worry, it will preserve persistent devices like *actual* HUE hardware). Then you can start over with posting the soft devices. +
- +
-2) Definitely fully-qualified *localhost* URLs (not on port 8080), with codes in place of special characters. +
- +
-Example: onUrl” : “http://localhost/ph-cgi/formula?formula=ph_macroparm(%27IRR_ON_MANUAL%27,6,15,0,0,0)” +
- +
-Thanks for the tutorial! +
- +
-Other people probably figured out how to have Alexa dim lights without needing it explained to them, but I thought I would comment and potentially save someone some time: +
- +
-As of 0.1.3, the Echo-HA-Bridge supports dimming. In the Configurator page, use these URLs: +
- +
-On URL: http://:8080/CMD?Light=${intensity.percent} +
-Off URL: http://:8080/CMD?Light=OFF+
  
-I got it working tonight with 0.2.1 and OpenHAB 1.7.1, both running on Windows 10. 
  
2016/ha/control_openhab_with_alexa.1462991684.txt.gz · Last modified: 2016/05/11 14:34 by 75.177.137.2