Author Topic: Bridge Amazon Echo to Vera, on github!  (Read 744529 times)

Offline Wekurtz74

  • Full Member
  • ***
  • Posts: 236
  • Karma: +3/-0
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2325 on: January 19, 2018, 08:22:37 pm »
This is a fantastic job that has been done.  Is anyone in contact with the developer?  His website is down(redirect to a weight loss website), but the file  is still available on GitHub.

Sent from my Pixel 2 XL using Tapatalk


Offline integlikewhoa

  • Master Member
  • *******
  • Posts: 5630
  • Karma: +157/-382
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2326 on: January 19, 2018, 11:32:23 pm »
This is a fantastic job that has been done.  Is anyone in contact with the developer?  His website is down(redirect to a weight loss website), but the file  is still available on GitHub.

Sent from my Pixel 2 XL using Tapatalk

Which developer are you talking about? If you read a bit you'll see this has been taken over, not sure if you looking for the right one.

https://github.com/bwssytems/ha-bridge

And downloads here:
https://github.com/bwssytems/ha-bridge/releases

The last update was released a month ago.

Offline Sender

  • Hero Member
  • *****
  • Posts: 973
  • Karma: +552/-467
  • Sr. manager of my Vera
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2327 on: September 08, 2018, 12:27:29 pm »
Hi, is there anyone that quickly knows how to coltrol a "lock"| via alexa and HA bridge (vera)?
Good firmware is more important than good karma. (and this costed me lots of Karma)

Offline jswim788

  • Hero Member
  • *****
  • Posts: 809
  • Karma: +58/-2
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2328 on: September 08, 2018, 01:21:57 pm »
That should not be hard at all since the bridge exposes everything as a Hue light.  There is no issue with it being a 'lock' - Alexa thinks it is a hue bulb.  So you can either manually set up a device in the bridge with any name you want and set 2 actions, 1 to turn it on and 1 to turn it off as http commands.  Something like this:
Code: [Select]
http://ip_address:3480/data_request?id=action&output_format=xml&DeviceNum=6&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0(Might need to change for the port_3480 business)

Or you can use the automatic Vera extraction built into the HA bridge to add your lock.

However, the HA bridge never worked very well for me.  I kept getting duplicate devices so I gave up on it.  Now I use openHAB in conjunction with Vera and the Alexa integration works quite well.  I don't control locks this way, but it should be no issue since you can present the lock as a switch.

Offline Sender

  • Hero Member
  • *****
  • Posts: 973
  • Karma: +552/-467
  • Sr. manager of my Vera
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2329 on: September 08, 2018, 01:36:16 pm »
Hi jswin788, thank you for taking the time to reply. I have the device in habridge and it shows up as a "Doorlock" and not an "On/Off Switch" in "category".

If I "build item" from a category:switch I have to say to alexa: "Alexa turn on <name> and this works ok and vice versa for off.

But I can't use these commands for category:doorlock. Nothing happens, though alexa says "ok".

If I use "alexa open/close/luck/unlock <name>, alexa says "<name> doesn't support that".

If I build item from category:doorlock it becomes a switch in bridge devices... (?)

So how can I use "lock/unlock or open/close" my "doorlock" type of switch via alexa?
« Last Edit: September 08, 2018, 01:38:01 pm by Sender »
Good firmware is more important than good karma. (and this costed me lots of Karma)

Offline jswim788

  • Hero Member
  • *****
  • Posts: 809
  • Karma: +58/-2
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2330 on: September 08, 2018, 02:58:16 pm »
Sorry, this is all from memory and it's been a long time since I used the habridge.  But you won't be able to say "unlock" or "lock" with the habridge since it is fundamentally emulating a hue light bulb which doesn't have any concept of a lock.  It knows on/off, dim, and I believe some color states.  (This could have changed since I last tried to use it.)

It sounds like you can make it work using 'Alexa turn on <name>'?  Is that not good enough?  I don't think you will get it to be better than that using habridge (but I've been proven wrong before  ???).

Or are you saying that is not working?  If it doesn't work, then you can use the manual configuration where you create a device, and give it the HTTP GET type with the request that I mention below (one for on, one for off).  But again this will only respond to "turn on <name>" or "turn off <name>".  It doesn't respond to lock/unlock or open/close since light bulbs don't do that.

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1298
  • Karma: +32/-13
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2331 on: September 10, 2018, 12:57:15 pm »
For my blinds I have to use "On" and "Off" instead of the more practical "Open" and "Close", but we are used to it.

I actually used a Amazon Dash Wand in our shower to open the bathroom blinds this morning.  TMI...
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline Sender

  • Hero Member
  • *****
  • Posts: 973
  • Karma: +552/-467
  • Sr. manager of my Vera
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2332 on: September 10, 2018, 01:00:28 pm »
For my blinds I have to use "On" and "Off" instead of the more practical "Open" and "Close", but we are used to it.

I actually used a Amazon Dash Wand in our shower to open the bathroom blinds this morning.  TMI...

I use "alexa set blind -name- to x  percent" in which 0 is closed and 100 is open. And everything in between also worls well...
Good firmware is more important than good karma. (and this costed me lots of Karma)

Offline wilme2

  • Hero Member
  • *****
  • Posts: 1298
  • Karma: +32/-13
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2333 on: September 10, 2018, 05:33:31 pm »
I use "alexa set blind -name- to x  percent" in which 0 is closed and 100 is open. And everything in between also worls well...

Interesting.  Not sure I can do that with the custom Lua I wrote to control my blinds.  For Alexa, I am using scenes today that are Off and On, that call a Lua function loaded at start-up..  I would have to have a way to pass the percentage from Alexa to a parameter in my Lua function, and translating that percentage to the three intermediate shade positions.  Great idea - let me look at it...
Long Live UI5!  (OK finally made the switch to UI7 in January 2018, and am pretty happy....)

Offline conchordian

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +4/-1
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2334 on: January 12, 2019, 03:27:27 pm »
Does anyone know how to call an item on the bridge, not using Alexa, i.e. from a commandline, or another program?

The Broadlink integration works well, but in order to integrate it with a Vera for automation, I can't see a way for the Vera to talk to the HA Bridge.

Offline rafale77

  • Community Beta
  • Hero Member
  • ******
  • Posts: 1741
  • Karma: +101/-27
  • HA ≠ IoT as a blue sky is cloudless.
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2335 on: January 12, 2019, 05:02:32 pm »
Does anyone know how to call an item on the bridge, not using Alexa, i.e. from a commandline, or another program?

The Broadlink integration works well, but in order to integrate it with a Vera for automation, I can't see a way for the Vera to talk to the HA Bridge.


It is in the documentation on github. The habridge is a hue emulator and has a hue like Rest API server. You need to send http commands to it as if it was a hue hub.

https://github.com/bwssytems/ha-bridge#set-light-state

This can be done in lua. It is all on the forum if you search it. If you need more details, let me know.
« Last Edit: January 12, 2019, 05:04:29 pm by rafale77 »
openLuup (79 devices, 141 scenes, 19 apps) master to VeraPlus (142 zwave nodes, 8 Zigbee nodes, 221 devices,  20 scenes , 2 apps) +  Hubitat (15 Zigbee nodes) + Home-Assistant (API Integrations). Bridged to Siri and Alexa. Homewave. VeraPlus ExtRooted and mios server independent.

Offline conchordian

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +4/-1
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2336 on: January 14, 2019, 10:00:15 am »

https://github.com/bwssytems/ha-bridge#set-light-state

This can be done in lua. It is all on the forum if you search it. If you need more details, let me know.

Some more hints would be great, thanks. When searching the forum I seem to be going round in circles discovering the same curl posts, and commands invoking the hue plug-in, rather than the bridge. There was also mention of something called luasocket, but it is all rather confusing.

PUT   http://host:port/api/<username>/lights/<id>/state

I'm not even sure what the username should be in the line above, as I have no login for the HA bridge!

Offline rafale77

  • Community Beta
  • Hero Member
  • ******
  • Posts: 1741
  • Karma: +101/-27
  • HA ≠ IoT as a blue sky is cloudless.
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2337 on: January 14, 2019, 11:27:33 am »
I did this quite some time ago so I had to dig a little.
I have setup in my lua statup code functions to send various code to various devices which, if they are really simple, did not require me to write a plugin. (example winix wifi air filter which I control with luup code)
For your specific needs I have the following example for an http post function:
note the "HA-Access" is a header for home assistant which I am controlling with this. You may need a different content for the header.

Code: [Select]
function POSTH(path, payload)
    local http = require("socket.http")
    local ltn12 = require("ltn12")
    local resp = {}
    local resp, code, resp_headers, status = http.request
    {
    url = path,
    method = "POST",
    headers =
        {["X-HA-Access"] = "**login credentials**",
        ["Content-Type"] = "application/json",
        ["Content-Length"] = payload:len()
        },
    source = ltn12.source.string(payload),
    sink = ltn12.sink.table(resp)
    }
end


Often times and http get is sufficient and this is an example of code for it (this is a tts call to a sonos http api):

Code: [Select]
function sendtts(msg,del,vol)
local message = string.format("http://127.0.0.1:5005/sayall/%s/%s", msg, vol)
luup.inet.wget (message)
end
« Last Edit: January 14, 2019, 11:30:07 am by rafale77 »
openLuup (79 devices, 141 scenes, 19 apps) master to VeraPlus (142 zwave nodes, 8 Zigbee nodes, 221 devices,  20 scenes , 2 apps) +  Hubitat (15 Zigbee nodes) + Home-Assistant (API Integrations). Bridged to Siri and Alexa. Homewave. VeraPlus ExtRooted and mios server independent.

Offline conchordian

  • Sr. Member
  • ****
  • Posts: 326
  • Karma: +4/-1
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2338 on: January 28, 2019, 11:54:22 pm »
I did this quite some time ago so I had to dig a little.

Thank you for going to the trouble of having a look. I'm making some headway, with your help, and looking at other people's examples, but it doesn't seem to be working.

Below is the closest I've come, and sometimes it will say message has been successfully sent, but then 2 minutes later, the exact same code doesn't work.

I've got all the logs turned on, on the HA bridge, but it doesn't seem to be registering anything, even with a successful message sent in Vera.
EdIT: sometimes it shows up in the HA logs now, which I've included below as well. Still doesn't appear to be working.

Any ideas what I'm doing wrong?

Cheers

Code: [Select]
local http = require("socket.http")
local ltn12 = require("ltn12")

function sendRequest()
local path = "http://192.168.0.11:8092/api/lights/37/state"
  local payload = [[ {"on": true} ]]
  local response_body = { }

  local res, code, response_headers, status = http.request
  {
    url = path,
    method = "POST", 
    source = ltn12.source.string(payload),
    sink = ltn12.sink.table(response_body)
  }

end

This is the log file on the HA bridge, when the command does go through:
Code: [Select]
01-29-2019 15:45:02.840 DEBUG HueMulator POST called on api/* with request <<</api/lights/37/state>>>, and body <<< {"on": false} >>> com.bwssystems.HABridge.hue.HueMulator
01-29-2019 15:45:02.840 DEBUG hue api user create requested: {"on": false} from address: 192.168.0.114 com.bwssystems.HABridge.hue.HueMulator
01-29-2019 15:45:02.840 DEBUG user add toContinue was true, creating user. com.bwssystems.HABridge.hue.HueMulator
01-29-2019 15:45:02.840 DEBUG findWhitelistUserByDeviceType: found a user <3137xxx33c07> for device type <<not given>> com.bwssystems.HABridge.BridgeSecurity
01-29-2019 15:45:02.841 DEBUG hue api user create requested for device type: <not given> and username: 3137xxx33c07 /api/ called com.bwssystems.HABridge.hue.HueMulator
01-29-2019 15:45:03.573 DEBUG Stats: [leased: 0; pending: 0; available: 0; max: 200] com.bwssystems.HABridge.plugins.http.HttpClientPool
01-29-2019 15:45:08.574 DEBUG Stats: [leased: 0; pending: 0; available: 0; max: 200] com.bwssystems.HABridge.plugins.http.HttpClientPool
01-29-2019 15:45:09.221 DEBUG HueMulator GET called on api/* with request <<</api/devices>>>, and body <<<>>> com.bwssystems.HABridge.hue.HueMulator
01-29-2019 15:45:09.221 DEBUG HueMulator GET called on api/* with request <<</api/devices/backup/available>>>, and body <<<>>>
« Last Edit: January 29, 2019, 12:56:51 am by conchordian »

Offline rafale77

  • Community Beta
  • Hero Member
  • ******
  • Posts: 1741
  • Karma: +101/-27
  • HA ≠ IoT as a blue sky is cloudless.
Re: Bridge Amazon Echo to Vera, on github!
« Reply #2339 on: January 29, 2019, 10:51:08 pm »
Well first of all you are trying to send a Put and you are using my code for a post. Second, you do need a username I believe but it will depend on the version of the bridge you are running. I assume here that you also got the port right...

Code: [Select]
local http = require("socket.http")
local ltn12 = require("ltn12")

function sendRequest()
local path = "http://192.168.0.11:8092/api/lights/37/state"
  local payload = [[ {"on": true} ]]
  local response_body = { }

  local res, code, response_headers, status = http.request
  {
    url = path,
    method = "PUT", 
    source = ltn12.source.string(payload),
    sink = ltn12.sink.table(response_body)
  }
openLuup (79 devices, 141 scenes, 19 apps) master to VeraPlus (142 zwave nodes, 8 Zigbee nodes, 221 devices,  20 scenes , 2 apps) +  Hubitat (15 Zigbee nodes) + Home-Assistant (API Integrations). Bridged to Siri and Alexa. Homewave. VeraPlus ExtRooted and mios server independent.