deConz / RaspBee integration

Hi,
I am looking into replacing my IKEA trådfri gateway and Hue Gateway with the RaspBee because it seems much cooler especially that it supports IKEA remotes and i can use them for whatever i want and also because it supports Websockets so i don’t have to bother with polling the Philips Gateway when there is motion on my hue motion sensor BUT i am in doubt whether the websockets will work in HASS hue component which i understand should support the RaspBee gateway, any ideas ?

@ako @Lapatoc @petepriority @thundergreen what’s your take on this ?

/donnib

2 Likes

I didn’t know about the websockets capability until now. That sounds really cool!
As I see it, it seems that HA does not have any easy way to handle this. However, I don’t think it would be hard to implement. If I have some time I might play around with it this week.

@petepriority yes that’s a major deal getting rid of the polling and eventually the other gateways. I think the range on this gateway is much better (at least i’ve heard). I’ve ordered an RaspBee so i am looking forward to move over to it this week.

+1 interested in your results. Even more if you can test with some xiaomi devices. (I’m looking for a way to replace xiaomi gateways)

Very interested as well…

The only thing that doesn’t sound too good is what I found on Amazon. One customer said this in his review:

I don't like it because the software that controls this is a GUI software where this chip is for a raspberry pi. A linux software that serves a light should be running as a background and not a GUI software which you have to load up before it works. I bought this chip just to use it to update my FLS-pp lights. I have no intention to use it as replacement of a hue hub.

I could also imagine to replace my xaomi and hue hub with such solution. In this case it would be great if the emulate hue software could emulate all functions to run apps like hue disco…

I just mashed together a simple websocket client in python. It works!
Here’s the output after using my Hue dim remote

# on
{"e":"changed","id":"1","r":"lights","state":{"on":true},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":1002,"lastupdated":"2017-07-24T17:11:16"},"t":"event"}
{"e":"changed","id":"1","r":"groups","state":{"any_on":true},"t":"event"}
{"e":"changed","id":"21098","r":"groups","state":{"any_on":true},"t":"event"}
# off
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":4000,"lastupdated":"2017-07-24T17:11:18"},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":4002,"lastupdated":"2017-07-24T17:11:18"},"t":"event"}
# brighter
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":2000,"lastupdated":"2017-07-24T17:12:16"},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":2002,"lastupdated":"2017-07-24T17:12:16"},"t":"event"}
# dimmer
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":3000,"lastupdated":"2017-07-24T17:12:17"},"t":"event"}
{"e":"changed","id":"1","r":"sensors","state":{"buttonevent":3002,"lastupdated":"2017-07-24T17:12:17"},"t":"event"}

Here’s the script. Nothing fancy:

import websocket

def on_message(ws, message):
    print(message)

def on_error(ws, error):
    print(error)

def on_close(ws):
    print("### closed ###")

def on_open(ws):
    print("### opened ###")


if __name__ == "__main__":
    websocket.enableTrace(True)
    ws = websocket.WebSocketApp(
        "ws://192.168.178.23:443/",
        on_message = on_message,
        on_error = on_error,
        on_close = on_close
    )
    ws.on_open = on_open
    ws.run_forever()

That’s true, unfortunately. I run mine in a vncserver session which works fine.

cool, do you have any xaomi component to test?

Sorry, I only have Philips devices.

I finally got myself some Tradfri devices, including a motion sensor. I’ve written a fairly basic websocket component and a binary_sensor platform for deconz. You can find it here: https://github.com/PetePriority/home-assistant/tree/deconz
If you want to test it, get the homeassistant/components/deconz.py and the homeassistant/components/binary_sensor/deconz_motion.py and put them into the custom_components/ and custom_components/binary_sensor/ folders in your configuration directory, respectively. You will also have to change the line

import homeassistant.components.deconz as deconz

to

import custom_components.deconz as deconz

in the deconz_motion.py file.

In your configuration, load the deconz websocket component:

deconz:
  host: "127.0.0.1"
  port: "443"

the configuration values shown are the defaults. Modify according to your setup.

Find the id of your motion sensor (see https://dresden-elektronik.github.io/deconz-rest-doc/sensors/) and add a binary sensor:

binary_sensor:
  - platform: deconz_motion
    sensors:
      <id>: <sensor name>

This should get you going. You will need a current beta of deconz, which you can find here: https://www.dresden-elektronik.de/rpi/deconz/beta/
The code is not very clean, and this might not be the best way to have done it. Also, the websocket component will stop working if it loses connection. I might add this when I find the time. Any suggestions are welcome!

2 Likes

I also made one, you can find it here : https://bitbucket.org/mihaicph/deconz-custom-module/overview

2 Likes

@DanielGalle & @petepriority you do NOT need a GUI just run deConz like this:

xvfb-run deCONZ-autostart.sh

I also created a docker image which I use on my pi. It works perfectly without any display adapter or vnc session.

Have a look here: https://github.com/razem-io/docker-deconz

1 Like

The betas support headless mode via the parameter -platform minimal. They also come with a systemd service file. You can find the betas here: https://www.dresden-elektronik.de/rpi/deconz/beta/

3 Likes