Integrate deCONZ

This driver is to integrate deCONZ rest api to hubitat work in progress this is to use those trouble zig bee devices that hubitat is not supporting because compatibility stability issues

       updates:
    09/25/20 intial release 
    09/25/20 doubleTap(button) (report it by @Royski)
    09/26/20 add suport for motion sensor and Lights 
    09/27/20 add autodiscover after creation bug fix and code cleaing
    09/28/20 import name from deCONZ on child creation (report it by @kevin)
    09/29/20 add connection drop recover (report it by@sburke781
    10/02/20 add reconect after reboot (report it by @sburke781)
    10/03/20 add refresh funtion call connect () (report it by @sburke781)
    10/04/20 save time and date of connection event/child button fix typo released (report it by@sburke781)
    10/04/20 auto rename from and to deCONZ
    10/05/20 custom name box on setdeCONZname funcion
    05/04/21 fix permit join 
    05/05/21 add State Variables zigbeechannel (request by @sburke781)
    05/06/21 add status, timeToRetry, timeoutCount to Current States variables to be access from rule machine (report it by @akafester)
    05/07/21 add shade support 
    05/08/21 add ChangeZigbeeChannel and ZigbeeChannel variable to Current States (report it by @sburke781)
9 Likes

This is cool

This is very cool! Thanks.

When using Discover, I'm getting this error


dev:1574
2020-09-26 11:00:31.149 am warnCall to on failed: String index out of range: -18

Any advice?

update Got it, had to manually set the IP and port to 80, then Authenticated in deCONZ, and it got the API key :+1:

Found a typo for the addChildDevices

    //log.debug "parse call"
if (json.state && json.state.buttonevent){
    log.debug json.uniqueid
    log.debug json.state.buttonevent
    def children = getChildDevice("child-${json.uniqueid}")
    if (!children){
        if (logEnable) log.debug "Children NOT found creating one"
        children = addChildDevice("jorge.martinez","deCONZ_rest_api_Child", "child-${json.uniqueid}", [name: "Button(${json.uniqueid})", label: user, isComponent: false])
    }

Should be deCONZ_rest_api_Child_Button :+1:

    //log.debug "parse call"
if (json.state && json.state.buttonevent){
    log.debug json.uniqueid
    log.debug json.state.buttonevent
    def children = getChildDevice("child-${json.uniqueid}")
    if (!children){
        if (logEnable) log.debug "Children NOT found creating one"
        children = addChildDevice("jorge.martinez","deCONZ_rest_api_Child_Button", "child-${json.uniqueid}", [name: "Button(${json.uniqueid})", label: user, isComponent: false])
    }

This is really awesome, many thanks for writing this.

I hope you dont mind, but added the required for my Xiaomi wireless buttons, and now I have all of them :slight_smile:

Current States

  • doubleTapped : 3
  • held : 3
  • numberOfButtons : 3
  • pushed : 3

I updated the child section, double tap on those would be an action 4 :slight_smile:
So just updated the commented out section (which was Action 3)

       if (action == 4){
    doubleTap(button)
}

It works brilliantly, and quickly too. These are the only devices which keep getting dropped on HE, but were solid on deCONZ, so I'm putting them back on there so I can use them again :smiley:

1 Like

ok github update with your fixs and add support to the release button and add "isStateChange: true" to support multiple pess on of the same button. update your drivers and check

1 Like

Ditto! Nice job @martinez.mp3

1 Like

Everything seems OK - nothing discovered yet... I'm seeing this though. Is that top line a concern, I assume it's because of SSL ? DeConz is is a HomeAssistant addin.

[debug]failure: Failed to connect to /192.168.1.50:443
[debug]websocketnotifyall = true
[debug]websocketport = 8081
[debug]no error
[debug]GetConfigurationCallBack
[debug]Updating configuration

write your deCONZ hub ip manually and port then continue the set up and see if it work im looking at the discover function now to see if I see something. post back if work

1 Like

Actually, because of Docker I entered it manually the first time - I didn't use discovery , that's probably why. (I also didn't include port)

Using Discovery it picks up a Docker address 172.x.x.x but that maybe appears to be working - let me see how far I get now..

[debug]failure: connect timed out
[debug]server connection= 172.30.33.3:40850
[debug]Sending on GET request to [https://dresden-light.appspot.com/discover]
[debug]Discovering hub

Will now try manual IP entry on main IP with port

It wants 40850 or 8081 here ? Don't think you can include a port it gets appended

[error]WebSocket connect failed

[debug]initialize error: Invalid URL port: "8081:443"
or
[debug]initialize error: Invalid URL port: "40850:443"

open this url on a browser https://phoscon.de/discover what do you get?
use that information to fill up the driver setting page
in my case i got [{"id":"00212EFFFFxxxxxx","internalipaddress":"192.168.86.9","macaddress":"00212EFFFF05B9C6","internalport":80,"name":"Phoscon-GW","publicipaddress":"x.x.x.x"}] I erase public ip

[{"id":"00212EFFFFxxxxxx","internalipaddress":"172.30.33.3","macaddress":"00212EFFFFxxxxxx","internalport":40850,"name":"Phoscon-GW","publicipaddress":"x.x.x.x"}]

172.30.33.3 is a non routable address on my 192.168.1.x network though. It's a Docker internal address
http://192.168.1.50:40850 works though
and I think the websocket on http://192.168.1.50:8081

try:
http://192.168.1.50:8081/api
or
http://192.168.1.50/api
or
http://192.168.1.50:40850/api
one of them should give you:
[{"error":{"address":"/","description":"unauthorized user","type":1}}]
then use that ip and port combination on the hubitat

OK That is the one that gives me the unauthorised and if I use that in the app then it is also forbidden, nor can I get a key.

failure: Expected HTTP 101 response but was '403 Forbidden'

Only if I reduce it to 192.168.1.50 can I get a key.

Now having got that key if I alter it back to 192.168.1.50:40850/api and save I again get forbidden on connect.

If I leave it at 192.168.1.50 I get the failed to connect to 192.168.1.50:443 and if I use 192.168.1.50:40850 it appends 443 on the end i.e. initialize error: Invalid URL port: "40850:443"

Happy to go PM if that helps keep this tidy - assuming your OK with that - thanks for the help so far.

leave public this could help someone in the future
get REST client any will do it I use:
https://chrome.google.com/webstore/detail/yet-another-rest-client/ehafadccdcdedbhcbddihehiodgcddpl

next go to


click on authenticate app

then use the YARC to get the key you got 60 seconds to do it if you miss it you will have to go back and click authenticate app again

NOTE: the type off request have to be post not get
copy the key "username" string and put it on the habitat driver let me know how it go

1 Like

I need to investigate why I'm still getting forbidden

image

[
{
"success": {
"username": "417D302F22"
}
}
]

Saved and on Connect get .. could it be 443 is still getting appended ? Does your app do that anywhere ?

failure: Expected HTTP 101 response but was '403 Forbidden'

hub ip just let the ip there erase the rest leave only 192.168.1.50

failure: Failed to connect to /192.168.1.50:443
image

I just altered this line in your code

//interfaces.webSocket.connect("ws://${settings.ip}:443/")//Connect the webSocket
    interfaces.webSocket.connect("ws://${settings.ip}:8081/")//Connect the webSocket

and that maybe works ??? Apolgies if I'm on the wrong track (8081 is my websocket for Deconz)

in the YARC url http://192.168.1.50:40850/api/417D302F22/config change the post to get
see response
and look for
"websocketport": 443
see if is 443 or any other port