DeCONZ, ZHA and Zigbee components and compatible hardware

Hi!

I am just beginning to learn about Home Assistant and experimenting with some Xiaomi devices, but (since I live in Sweden) I don’t want to have non CE 220v devices plugged in. So, I want to bypass the Xiaomi Gateway and connect directly to the (Xiaomi, for now) devices via the zigbee protocol.

I have read in various threads in the forum about how to make this work with for example Dresden RaspBee and deConz RestAPI, and even though I much appreciate the effort from the developers to make this work, I am curious about the possibilities of doing this without the need for the RestAPI in between.

I have also read about the zha component, but as I understand it, this is specifically for the HUSBZB-1 device (not available in Europe).

To try to get somewhere, I have purchased both RaspBee and I have a CC2530 chip on the way. And since these are GPIO-devices (and since Home Assistant has a GPIO-zigbee component), wouldn’t it be possible to use it for these devices?

The documentation (https://home-assistant.io/components/zigbee/) says “ZigBee integration for Home Assistant allows you to utilize modules such as the XBee as wireless General Purpose Input/Output (GPIO) devices.”. I interpret it as it is possible, but I really don’t know where to go from here.

So I guess what I am wondering is:

  1. Is it possible to use the zha-component for other hardware (available in Europe) than HUSBZB-1?
  2. What needs to be done (configuration/development or otherwise) to be able to utilize RaspBee or CC2530/31 with the zigbee GPIO component?
  3. Is there any other way to get Home Assistant to communicate with zigbee devices (via RaspBee, CC2530 or other) without the need for third party api’s or gateways?

I am a developer myself (C# “unfortunately” in this context, so no Python or low level programming, yet, at least), but I am happy to contribute if I can.

1 Like

Check out the telegesis stick on m.nu

1 Like

Great tip! Thanks. Ordered straight away.
I have searched (and searched and searched) a lot in this forum about zigbee solutions, but I managed to miss this one. :disappointed:

But ok. Lets see if I understand this correctly.
The telegesis stick speaks EZSP (same as HUSBZB) and that is what the zha component implements?
That is why the RaspBee and the CC2530 can’t be used with this component, since they have different protocols? Right?
But what is the “zigbee” component for then? It sounds like it is for “all” GPIO-devices, but how does it know what protocol to use?

And: I have read about the deconz component you (as I understand?) are developing, and that is close to release. Cool! Will there still be need to add devices via the api-page, or is everything done from inside HA?

I know next to nothing about the ZHA and the Zigbee component. Just saw about the Telegesis stick a month ago (right after I bought the Conbee) on swedish home automation group on facebook.

I’m looking into how to integrate it even better with HASS but I also need to have a discussion upstream so that it is ok to do web interface for it. Adding you can do today, since I expose the network API to deCONZ which includes adding new devices, but you need to restart HASS to add them afterwards.

1 Like

A little update; I got the Telegesis stick, flashed it, and although I can see that there is communication, nothing shows up in Home Assistant.

Thinking of giving the RaspBee a shot. Feels like there is a lot more development going on there.
But I have seem to lost the bookmark to the component. Could you post it here maybe?

The component isn’t released yet. I’m satisfied with it but still awaiting approval from hass maintainers.

It is not hard to get it going from the PR

https://github.com/home-assistant/home-assistant/pull/10321

1 Like

Tnx!

Cloned it and ran install_deconz.sh, but I get an error when building the deconz-rest-plugin.
Building on the hassbian image. Anything you have encountered?

EDIT: The stdlib.h does exist in /usr/include/c++/6/

Switched to a new branch 'mybranch'
Info: creating stash file /tmp/deconz/deconz-rest-plugin/.qmake.stash
make -f Makefile.Release
make[1]: Entering directory '/tmp/deconz/deconz-rest-plugin'
/usr/lib/arm-linux-gnueabihf/qt5/bin/uic de_web_widget.ui -o ui_de_web_widget.h
g++ -c -pipe -Wno-attributes -Wall -Wno-attributes -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DDECONZ_DLLSPEC=Q_DECL_IMPORT -DARCH_ARM -DARCH_ARMV7 -DUSE_WEBSOCKETS -DGW_SW_VERSION=\"2.04.86\" -DGW_API_VERSION=\"1.0.4\" -DGIT_COMMMIT=\"5ada281972dda315fcc59d9fe5b2aca7786b9d6f\" -DGW_MIN_RPI_FW_VERSION=0x26190500 -DGW_MIN_DERFUSB23E0X_FW_VERSION=0x22030300 -DGW_DEFAULT_NAME=\"deCONZ-GW\" -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SERIALPORT_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include -I../.. -I../../common -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWidgets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtGui -isystem /usr/include/arm-linux-gnueabihf/qt5/QtSerialPort -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWebSockets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtNetwork -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore -Irelease -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o release/authentification.o authentification.cpp
g++ -c -pipe -Wno-attributes -Wall -Wno-attributes -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DDECONZ_DLLSPEC=Q_DECL_IMPORT -DARCH_ARM -DARCH_ARMV7 -DUSE_WEBSOCKETS -DGW_SW_VERSION=\"2.04.86\" -DGW_API_VERSION=\"1.0.4\" -DGIT_COMMMIT=\"5ada281972dda315fcc59d9fe5b2aca7786b9d6f\" -DGW_MIN_RPI_FW_VERSION=0x26190500 -DGW_MIN_DERFUSB23E0X_FW_VERSION=0x22030300 -DGW_DEFAULT_NAME=\"deCONZ-GW\" -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SERIALPORT_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include -I../.. -I../../common -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWidgets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtGui -isystem /usr/include/arm-linux-gnueabihf/qt5/QtSerialPort -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWebSockets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtNetwork -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore -Irelease -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o release/atmel_wsndemo_sensor.o atmel_wsndemo_sensor.cpp
g++ -c -pipe -Wno-attributes -Wall -Wno-attributes -O2 -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DDECONZ_DLLSPEC=Q_DECL_IMPORT -DARCH_ARM -DARCH_ARMV7 -DUSE_WEBSOCKETS -DGW_SW_VERSION=\"2.04.86\" -DGW_API_VERSION=\"1.0.4\" -DGIT_COMMMIT=\"5ada281972dda315fcc59d9fe5b2aca7786b9d6f\" -DGW_MIN_RPI_FW_VERSION=0x26190500 -DGW_MIN_DERFUSB23E0X_FW_VERSION=0x22030300 -DGW_DEFAULT_NAME=\"deCONZ-GW\" -DQT_NO_DEBUG -DQT_PLUGIN -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_SERIALPORT_LIB -DQT_WEBSOCKETS_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -isystem /usr/include -I../.. -I../../common -isystem /usr/include/arm-linux-gnueabihf/qt5 -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWidgets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtGui -isystem /usr/include/arm-linux-gnueabihf/qt5/QtSerialPort -isystem /usr/include/arm-linux-gnueabihf/qt5/QtWebSockets -isystem /usr/include/arm-linux-gnueabihf/qt5/QtNetwork -isystem /usr/include/arm-linux-gnueabihf/qt5/QtCore -Irelease -I. -I/usr/lib/arm-linux-gnueabihf/qt5/mkspecs/linux-g++ -o release/bindings.o bindings.cpp
In file included from /usr/include/c++/6/bits/stl_algo.h:59:0,
                 from /usr/include/c++/6/algorithm:62,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qglobal.h:94,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qatomic.h:41,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qrefcount.h:43,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qbytearray.h:44,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qcryptographichash.h:44,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/QCryptographicHash:1,
                 from authentification.cpp:11:
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
                         ^
compilation terminated.
In file included from /usr/include/c++/6/bits/stl_algo.h:59:0,
                 from /usr/include/c++/6/algorithm:62,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qglobal.h:94,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/QtGlobal:1,
                 from de_web_plugin_private.h:13,
                 from atmel_wsndemo_sensor.cpp:11:
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
                         ^
Makefile.Release:421: recipe for target 'release/authentification.o' failed
make[1]: *** [release/authentification.o] Error 1
make[1]: *** Waiting for unfinished jobs....
compilation terminated.
Makefile.Release:438: recipe for target 'release/atmel_wsndemo_sensor.o' failed
make[1]: *** [release/atmel_wsndemo_sensor.o] Error 1
In file included from /usr/include/c++/6/bits/stl_algo.h:59:0,
                 from /usr/include/c++/6/algorithm:62,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qglobal.h:94,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qnamespace.h:43,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qobjectdefs.h:48,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/qobject.h:46,
                 from /usr/include/arm-linux-gnueabihf/qt5/QtCore/QObject:1,
                 from de_web_plugin.h:15,
                 from bindings.cpp:11:
/usr/include/c++/6/cstdlib:75:25: fatal error: stdlib.h: No such file or directory
 #include_next <stdlib.h>
                         ^
compilation terminated.
Makefile.Release:456: recipe for target 'release/bindings.o' failed
make[1]: *** [release/bindings.o] Error 1
make[1]: Leaving directory '/tmp/deconz/deconz-rest-plugin'
Makefile:38: recipe for target 'release' failed
make: *** [release] Error 2
cp: cannot stat 'libde_rest_plugin.so': No such file or directory
Cleaning up

My dev environment is an old hassbian install. Didn’t encounter that issue, many others but not that one :slight_smile:

A small “brasklapp” though, that script isnt verified completely. Im gonna rewrite to python later. It might not work a 100%

Ok.

I changed all references in the script to deconz version 2.04.94, and now it builds.

Have added config

deconz:
  host: 192.168.0.90

and put pydeconz folder (from github) in /custom_components/

But the log says: “Setup failed for deconz: Component not found.”. And if I rename the pydeconz folder to deconz, HA complaints about setup missing.

Any advice on how to get it working? :slight_smile:

It’s not a custom component. You need to put it in HASS site packages components. You also need to add the different sensoe/light /scene deconz files as well for it to work. You will also need to remove the import from discovery in the init file unless you add the changes to the discovery component

Ok, I see. Still learning :slight_smile: I will give it a try.
Any hopes of this PR beeing merged to Home Assistant anytime soon? (As in next release perhaps? :wink: )

I pinged the maintainers yesterday. It is a big PR so it takes a while to review and they have a lot on their plate. So no promises unfortunately

It’s always good to learn new things :slight_smile:

But of course :slight_smile:

So, I have made the changes from the PR, but I couldn’t find the files:

  • .coveragerc
  • CODEOWNERS
  • requirements_all.txt

Are those changes needed?

However, I got everything up and running. Unlocked gateway and deConz is now in state configured. Wohoo!
Now what? :smiley:

How do I add devices? In the zha component there was a “permit join” service to call (which I never really got working, but anyways…).
The deconz component has configure service, but I don’t know if it is this you are referring to with the “network api” you mentioned earlier.

As of now I only have a Xiaomi Aqara Human Body Sensor, a Xiaomi Switch and a Xiaomi (Philips) Smart Bulb, but I have a couple of more things on the way.

Great work! You should get a registration prompt in the gui to generate a key for communication with deconz. After that it should be plugmplay.

Those other files are for development only.

Hehe, thanks! But the great work is really yours! I’m just copying it :wink:
Thanks a million for the effort!

Yeah, I got a configure-prompt in the GUI, clicked on it, unlocked the Gateway in the deCONZ WebUI, and then clicked the button “I have unlocked the Gateway” (or something like that) in Home Assistant. And when I look in the “History” tab in Home Assistant, the deCONZ-component is now in state “deCONZ” (was: “configure” before).

EDIT: Haven’t seen any key, but I guess that i handled in the background?

But, I can’t figure out how to pair my sensors? You mentioned that:

Adding you can do today, since I expose the network API to deCONZ which includes adding new devices, but you need to restart HASS to add them afterwards.

I have restarted, but how do I do it? I guess I should make a service call or something?

Aah, there is a service that you can use that you can do any API call to deconz with.

There are a couple of examples in the documentation PR https://github.com/home-assistant/home-assistant.github.io/pull/3967

You can just as well just add the sensors and lights directly in deconz, when you add new devices you have to restart hass to load them.

Yes the key is not something you need to know any details about. It should all just work after you’ve registered hass with deconz.

State deconz? Sounds weird, mind taking a screenshot?

Ok, I will check the examples. Thanks for all help!

Maybe I’m using the wrong terms, but here is the screenshot:

HACapture

Was “configure”, and now it just says “deCONZ”. Probably nothing wrong.

Ok, I seldomely check that tab.

What happens if you restart hass? Any printouts in the logs?

@Robban not trying to hijack this thread but just wanted to say that I got your component up and running in my test environment with a RaspBee last night and all seems to be going well so far, very nice work. I’m going to annoy my wife tonight and move some of the lights in my production environment over to the test system and use it for a while to see if I can’t break something :smile: .

On the Docker front, I’ve been working on getting stable images up and running but it’s more challenging than I thought and I will probably need to work with Manu to figure out exactly what deCONZ is doing to access and initialize the serial port for Conbee and RaspBee. When running in a container, the gateway device isn’t always recognized, and sometimes a gateway reset is required to get a channel and network id to populate. It’s hard for me to debug since I don’t have access to the deconz source, so working with Manu is going to be my only option. In my ideal world there would be a Hassio addons ready to go when your component gets merged, we will see how that goes.

On the GUI front, I have been doing some thinking about this. Not sure if you’re familiar with how the Zwave component does it, but it adds an option to the Configuration menu for Zwave, and in that Zwave submenu there are buttons exposed for different Zwave functions (Adding and removing nodes, etc.). I haven’t checked all of the function buttons, but it seems like all the buttons call Hass services (so e.g. the button Add Node calls the service zwave.add_node). Assuming that all of the relevant functions can be invoked through the deconz rest API, then wrapping them in HA services seems like a fairly clean way to go.

Ok, so I have “fipplat runt lite” and here’s the status:

I can’t add my Xiaomi devices in the deconz “Wireless Light” portal (running on the same Raspberry PI as Home Assistant). Or at least, so I thought. Nothing shows up in the (deconz-)portal, but the logs in Home Assistant says:

2017-12-08 16:08:07 INFO (MainThread) [homeassistant.loader] Loaded deconz from homeassistant.components.deconz
2017-12-08 16:08:09 INFO (MainThread) [homeassistant.setup] Setting up deconz
2017-12-08 16:08:09 DEBUG (MainThread) [pydeconz.utils] Sending {} to http://192.168.0.101:80/api/17586E8298
2017-12-08 16:08:09 DEBUG (MainThread) [pydeconz.utils] HTTP request response: {'schedules': {}, 'rules': {}, 'lights': {}, 'config': {'devicename': 'RaspBee', 'networkopenduration': 60, 'proxyport': 0, 'timeformat': '12h', 'starterkitid': '', 'panid': 60818, 'mac': 'b8:27:eb:8c:98:05', 'portalstate': {'signedon': False, 'incoming': False, 'communication': 'disconnected', 'outgoing': False}, 'ntp': 'synced', 'portalconnection': 'disconnected', 'timezone': 'Etc/GMT', 'dhcp': True, 'gateway': '192.168.0.1', 'factorynew': False, 'UTC': '2017-12-08T15:08:09', 'swupdate2': {'autoinstall': {'updatetime': '', 'on': False}, 'bridge': {'state': 'allreadytoinstall', 'lastinstall': ''}, 'lastinstall': '', 'install': False, 'checkforupdate': False, 'state': 'allreadytoinstall', 'lastchange': ''}, 'name': 'deCONZ-GW', 'swupdate': {'url': '', 'updatestate': 0, 'devicetypes': {'lights': [], 'bridge': False, 'sensors': []}, 'text': '', 'notify': False, 'checkforupdate': False}, 'websocketport': 443, 'proxyaddress': 'none', 'netmask': '255.255.255.0', 'backup': {'errorcode': 0, 'status': 'idle'}, 'bridgeid': '00212EFFFF013E81', 'uuid': '7619f723-36b3-4549-acd0-83a34cfdcacf', 'replacesbridgeid': None, 'zigbeechannel': 15, 'websocketnotifyall': True, 'portalservices': False, 'localtime': '2017-12-08T15:08:09', 'linkbutton': False, 'internetservices': {'remoteaccess': 'disconnected'}, 'whitelist': {'17586E8298': {'last use date': '2017-12-08T15:08:09', 'name': 'pydeconz', 'create date': '2017-12-08T11:33:53'}, 'AB5A6DAEFC': {'last use date': '2017-12-08T12:01:07', 'name': 'deCONZ WebApp', 'create date': '2017-12-08T11:33:20'}, 'AD97B94311': {'last use date': '2017-12-08T14:57:35', 'name': 'deCONZ WebApp', 'create date': '2017-12-08T14:42:32'}}, 'swversion': '2.4.94', 'ipaddress': '192.168.0.101', 'datastoreversion': '60', 'apiversion': '1.0.4', 'modelid': 'deCONZ'}, 'groups': {}, 'sensors': {'2': {'state': {'presence': False, 'lastupdated': '2017-12-08T14:05:41'}, 'type': 'ZHAPresence', 'name': 'Presence 2', 'ep': 1, 'config': {'duration': 60, 'on': True, 'reachable': False}, 'etag': '12bb25ea010166b1768a698ccdadc644', 'manufacturername': 'LUMI', 'uniqueid': '00:15:8d:00:01:e0:30:03-01-0406', 'modelid': 'lumi.sensor_motion.aq2'}, '1': {'state': {'dark': False, 'daylight': False, 'lux': 16, 'lightlevel': 12042, 'lastupdated': '2017-12-08T14:04:41'}, 'type': 'ZHALightLevel', 'name': 'LightLevel 1', 'ep': 1, 'config': {'tholddark': 12000, 'tholdoffset': 7000, 'on': True, 'reachable': False}, 'etag': '12bb25ea010166b1768a698ccdadc644', 'manufacturername': 'LUMI', 'uniqueid': '00:15:8d:00:01:e0:30:03-01-0400', 'modelid': 'lumi.sensor_motion.aq2'}, '3': {'state': {'lastupdated': '2017-12-08T14:02:46', 'buttonevent': 1002}, 'type': 'ZHASwitch', 'name': 'lumi.sensor_switch 3', 'ep': 1, 'mode': 1, 'config': {'on': True, 'reachable': False}, 'etag': '12bb25ea010166b1768a698ccdadc644', 'manufacturername': 'LUMI', 'uniqueid': '00:15:8d:00:01:b1:86:3d-01-0006', 'modelid': 'lumi.sensor_switch'}}}
2017-12-08 16:08:09 DEBUG (MainThread) [pydeconz.config] Deconz config loaded {'_swversion': '2.4.94', '_zigbeechannel': 15, '_ipaddress': '192.168.0.101', '_linkbutton': False, '_apiversion': '1.0.4', '_websocketport': 443, '_name': 'deCONZ-GW', '_modelid': 'deCONZ', '_panid': 60818, '_networkopenduration': 60, '_uuid': '7619f723-36b3-4549-acd0-83a34cfdcacf'}
2017-12-08 16:08:09 DEBUG (MainThread) [pydeconz.deconzdevice] Presence 2 created as {'_async_callback': [], '_swversion': None, '_reachable': False, '_modelid': 'lumi.sensor_motion.aq2', '_on': True, '_sensor_class': None, '_etag': '12bb25ea010166b1768a698ccdadc644', '_type': 'ZHAPresence', '_presence': False, '_battery': None, '_dark': None, '_uniqueid': '00:15:8d:00:01:e0:30:03-01-0406', '_ep': 1, '_name': 'Presence 2', '_sensor_unit': None, '_sensor_icon': None, '_manufacturername': 'LUMI'}
2017-12-08 16:08:09 DEBUG (MainThread) [pydeconz.deconzdevice] LightLevel 1 created as {'_async_callback': [], '_swversion': None, '_modelid': 'lumi.sensor_motion.aq2', '_on': True, '_sensor_class': None, '_etag': '12bb25ea010166b1768a698ccdadc644', '_type': 'ZHALightLevel', '_battery': None, '_reachable': False, '_uniqueid': '00:15:8d:00:01:e0:30:03-01-0400', '_lightlevel': 12042, '_ep': 1, '_name': 'LightLevel 1', '_sensor_unit': None, '_sensor_icon': None, '_manufacturername': 'LUMI'}
2017-12-08 16:08:09 DEBUG (MainThread) [pydeconz.deconzdevice] lumi.sensor_switch 3 created as {'_async_callback': [], '_swversion': None, '_sensor_unit': None, '_modelid': 'lumi.sensor_switch', '_on': True, '_sensor_class': None, '_etag': '12bb25ea010166b1768a698ccdadc644', '_type': 'ZHASwitch', '_battery': None, '_reachable': False, '_uniqueid': '00:15:8d:00:01:b1:86:3d-01-0006', '_ep': 1, '_name': 'lumi.sensor_switch 3', '_buttonevent': 1002, '_sensor_icon': None, '_manufacturername': 'LUMI'}

And I have a “Precense 2”-sensor in HA, but it is unreachable.

24

Haven’t looked into your examples yet.

EDIT: Forgot to mention, the devices I have been trying to add is a “Xiaomi Smart Wireless Switch” (the small round one) and the “Xiaomi Aqara Human Body Sensor” (with luminance sensor also).