OpenMQTTGateway icon indicating copy to clipboard operation
OpenMQTTGateway copied to clipboard

Feature Request: Zigbee Support

Open jwillmer opened this issue 7 years ago • 53 comments

Zigbee is becoming the de facto standard in home automation. It would be great if OpenMQTTGateway could support this protocol. Below I have a write up about the most promising solution at the moment. I think with some work it would be possible to write an interface for the serial communication of the CC253X hardware.

There is a zigbee2mqtt bridge for Raspberry Pi already. It is using zigbee-shepherd that runs on node.js. It all is build around the CC253X USB stick. The cc-znp library offers a firmware for serial communication with the Zigbee chip. A good explanation about the hardware setup can be found zigbee2mqtt wiki.

Additional references:

jwillmer avatar May 18 '18 22:05 jwillmer

Any plans on this? I am currently looking into extending my little home automation setup at home, and I would really love to have a ESP8266- or Arduino-based MQTT bridge linking all non-Wifi devices to a Home Assistant instance, so Zigbee support in MQTT would be perfect.

I actually would be willing to pay money for this, as in setting a substantial bounty for this to be implemented. if necessary via a platform like Gitcoin or so.

I think that indeed, a TI chip would be easiest - something like the CC2530. There are pretty cheap to get even in a module that includes an actual antenna (search via Google for "CC2530 module"), and using the Z-Stack by TI seem to be farely straightforward to use:

https://e2e.ti.com/support/wireless-connectivity/zigbee-and-thread/f/158/t/218226

One can even flash a CC2530 without the CCDebugger, using an Arduino or even an ESP8266:

https://koenkk.github.io/zigbee2mqtt/information/alternative_flashing_methods.html

hihp avatar Jan 24 '19 10:01 hihp

Surely zigbee will be an ultimate feature for OMG. Thanks for proposing support it is appreciated. At this time I don't know yet how I will go into this. For the next release 0.9.1 I will concentrate on Lora and autodiscovery features. Once this is stable zigbee will be an excellent candidate for the next steps.

1technophile avatar Feb 24 '19 15:02 1technophile

I see the Nordic nRF52 chips such as nRF52840 support ZigBee, BLE5 and Thread. The new TI chips CC2652R, CC1352R, CC1352P also. The Nordic also have built-in USB, while the TI support sub-GHz radio.

snovotill avatar Mar 15 '19 09:03 snovotill

I guess instead of copying what zigbee2mgtt does would be cool to merge effort on building gateway framework that merge zigbee2mgtt and OMG all together

podarok avatar Aug 05 '19 17:08 podarok

This is a really interesting idea. I found this thread since I recently purchased a TI cc1352p based board for zigbee2mqtt but I am really interested by the sub-1GHz (inc 433 and 868 mhz) of this chipset and wondered on the possibility of OMG type capability in parallel with Z2M. It has the possibility to be an absolutely killer home automation hub.

james-fry avatar Oct 18 '19 08:10 james-fry

I recently purchased a TI cc1352p based board for zigbee2mqtt but I am really interested by the sub-1GHz (inc 433 and 868 mhz)

It seems an interesting board, Could you share a link to the board you bought?

1technophile avatar Oct 20 '19 05:10 1technophile

Sure. I bought this board: http://www.ti.com/tool/LAUNCHXL-CC1352P

It’s about $50 + tax

There are two versions of the board with different RF tuning for either 2.4ghz or sub 1ghz. I purchased the P-2 version which is more suited for 2.4 for zigbee. That’s said both boards will operate with both bands.

Support for this chipset was only added for zigbee2mqtt in the past week. There is an active github issue thread if you are interested: https://github.com/Koenkk/zigbee2mqtt/issues/1429

james-fry avatar Oct 20 '19 08:10 james-fry

FYI, Tasmota firmware for ESP8266 recently added bridge support for Zigbee via TI CC2530 chip that is flashed with a custom Texas Instruments Z-Stack firmware from Zigbee2mqtt project by Koenkk

https://tasmota.github.io/docs/#/Zigbee

Z2T (Zigbee to Tasmota) concept allows you to make your own Zigbee to WiFi bridge

https://www.cnx-software.com/2019/12/23/tasmota-open-source-firmware-now-supports-zigbee-connectivity/

"Basically all you need is ESP82xx hardware connected to a Texas Instruments C2530 based Zigbee device over a serial. Note that C2531 based device won’t work since they are connected over USB. Normally, C2530 firmware is flashed through CC Debugger tool, but in this case, you don’t need to purchase extra hardware since Z-Stack firmware flashing can be performed through any ESP8266 board running CCLib instead. Once it’s done flash Zigbee2Tasmota Tasmota firmware to your ESP82xx board or device, and you need to configure the system for communication between the Zigbee module and ESP8266. This is all explained in detail in the documentation."

Gamester17 avatar Feb 02 '20 11:02 Gamester17

integrating Z2T in home assistant is difficult and involves lots of custom translating stuff for the moment. PITA.

wimpie007 avatar Feb 07 '20 07:02 wimpie007

FYI, Itead has just launched Sonoff ZBBridge as an inexpensive Sonoff Zigbee Bridge (which is somewhat based on a similar concept/idea as the product that they have in their Sonoff RF Bridge)

  • https://www.cnx-software.com/2020/04/16/sonoff-zbbridge-wifi-to-zigbee-gateway/

This new Sonoff ZBBridge (and their existing Sonoff RF Bridge) uses ESP8266 ("ESP8266EX") for WiFi and bridge/gateway/controller software, so the main difference is that they use different types of MCU for the RF radio module part.

  • https://www.itead.cc/sonoff-zbbridge.html

According to the teardown on notenoughtech.com it sounds as if it the new Sonoff ZBBridge is based on Silicon Labs EFR32 (Mighty Gecko) for Zigbee 3.0 radio module support

  • https://notenoughtech.com/home-automation/sonoff/sonoff-zigbee-bridge-preview/

Please consider porting OpenMQTTGateway to the new Sonoff Zigbee Bridge (Sonoff ZBBridge).

As you probably already know, Tasmota does something similar with Zigbee2Tasmota (Z2T) but by connecting an ESP8266 to a Texas Instrument CC2530 module instead however it too is using a serial communication protocol, see:

https://tasmota.github.io/docs/Zigbee/

EZSP (EmberZNet Serial Protocol) interface that Silicon Labs uses is also well documented and already used by open source projects, see example Home Assistant's ZHA integration component via zigpy and bellows:

  • https://github.com/zigpy/bellows

  • https://www.home-assistant.io/integrations/zha/

  • https://www.silabs.com/community/wireless/zigbee-and-thread/knowledge-base.entry.html/2017/05/25/build_an_ezsp-spiho-2VE8

  • https://www.silabs.com/documents/public/user-guides/ug100-ezsp-reference-guide.pdf

Z Smart System also has a Java device driver for Ember based serial dongles (among other dongles):

  • https://github.com/zsmartsystems/com.zsmartsystems.zigbee
    • https://github.com/zsmartsystems/com.zsmartsystems.zigbee/tree/master/com.zsmartsystems.zigbee.dongle.ember
    • https://github.com/zsmartsystems/com.zsmartsystems.zigbee/tree/master/com.zsmartsystems.zigbee.dongle.ember.autocode
    • https://github.com/zsmartsystems/com.zsmartsystems.zigbee/tree/master/com.zsmartsystems.zigbee.console.ember

For reference, Z Smart System also has a sniffer library written in Java which uses same serial interface:

  • https://github.com/zsmartsystems/com.zsmartsystems.zigbee.sniffer

Hedda avatar Apr 20 '20 08:04 Hedda

One workaround for Home Assistant users could be to simply present a Zigbee radio module as a remote adapter to Home Assistant's ZHA (their Zigbee Home Automation integration component)?

  • https://www.home-assistant.io/integrations/zha/

You could use something like ser2net to allow ZHA to remote connect to it via serial over network, like:

  • https://www.zigbee2mqtt.io/how_tos/how_to_connect_to_a_remote_adapter.html

Then you need a radio library for zigpy that works with the serial protocol used. For example with that Sonoff ZBBridge you would need a zigpy radio library for EZSP protocol used by Silicon Labs EFR32

  • https://github.com/zigpy/zigpy

Hopefully, their bellows radio library should already be compatible or could be made to be if updated

  • https://github.com/zigpy/bellows

zigpy devs already do something similar to connect remotely with ESP8266 based "ZiGate Pack WiFi"

  • https://zigate.fr/produit/zigate-pack-wifi-v1-3/
  • https://github.com/fairecasoimeme/ZiGate/
  • https://github.com/zigpy/zigpy-zigate

As proof-of-concept you could do this with a CC2530 remote to zigpy-cc from a ESP8266 using ser2net

https://github.com/zigpy/zigpy-cc

Hedda avatar Apr 20 '20 08:04 Hedda

"As proof-of-concept you could do this with a CC2530 remote to zigpy-cc from a ESP8266 using ser2net" I use a esp8266 with CC2530 already to connect to a zigbee2mqtt instance. Espeasy with serial server. Works like a treat.

wimpie007 avatar Apr 20 '20 09:04 wimpie007

the new chipset seems promising!! (range!)

wimpie007 avatar Apr 20 '20 09:04 wimpie007

Do you think that you could maybe use the serial bridge from esp-link for a serial forwarding feature?

  • https://github.com/jeelabs/esp-link
    • https://github.com/jeelabs/esp-link/tree/master/serial

Hedda avatar Apr 20 '20 12:04 Hedda

oxan might have a "stream server" solution for ESPHome firmware in https://github.com/esphome/feature-requests/issues/660

Hedda avatar Apr 20 '20 14:04 Hedda

The best way could be to share a common arduino zigbee driver on all these projects, I have some zigbee devices around and a CC2530, this will be the occasion to play in the next months

1technophile avatar Apr 20 '20 14:04 1technophile

@1technophile problem with that is that there are so many different Zigbee modules

Maybe better to port zigpy and its radio libraries or would that be overkill?

  • https://github.com/zigpy/zigpy

  • https://github.com/zigpy/

Hedda avatar Apr 20 '20 14:04 Hedda

If we cover the CC2530 on an ESP you don't think it would be sufficient?

1technophile avatar Apr 20 '20 14:04 1technophile

The zigbee2mqtt project is beginning to move away from the cc2530. The cc2530 is a low power (CPU) device and has limitations as a zigbee coordinator.

james-fry avatar Apr 20 '20 14:04 james-fry

The zigbee2mqtt project is beginning to move away from the cc2530. The cc2530 is a low power (CPU) device and has limitations as a zigbee coordinator.

Thanks, good to know.

What would be the ideal component in your point of view?

1technophile avatar Apr 20 '20 15:04 1technophile

As james-fry wrote; Zigbee2mqtt is long moving towards more powerful Zigbee 3.0 compatible radio modules with support for CC2652, a.k.a CC26X2R1 (CC2652P, CC2652R, and CC2652RB chips) and CC1352 (CC1352P chips), but more importantly to consider is that even Zigbee2mqtt is now also moving towards hardware-independent support, with support for ConBee, ConBee II, and RaspBee support now already available in Zigbee2mqtt.

It would also not work on Sonoff ZBBridge as I requested because it contains a Silicon Labs EFR32MG21 Zigbee 3.0 radio module support. EFR32MG21 is one of the latest chip in EFR32 Gecko Series 2 MCU

  • https://www.cnx-software.com/2020/04/16/sonoff-zbbridge-wifi-to-zigbee-gateway/

Regardless, zigpy has radio libraries to support for all of those mentioned radio modules and more.

  • https://github.com/zigpy/

Hedda avatar Apr 20 '20 15:04 Hedda

For details, you need to check out this thread https://github.com/Koenkk/zigbee2mqtt/issues/1429

Guys there recommend different CC1352 and CC2652 based modules if you have to choose one today.

  • The benefit is that CC1352 and CC2652 just users a newer version of the same serial protocol and command set as the CC253x series of chips.
  • The downside is that the total cost building complete ESP8266 gateway with CC1352 or CC2652 based module will still have a higher price than just buying a Sonoff ZBBridge as a finished product.

Again, Sonoff ZBBridge is a prepackaged product at less than $17 so will be hard to beat that price

Hedda avatar Apr 20 '20 20:04 Hedda

The CC1352P-2 is I think especially interesting for omg as it can also do sub 1ghz as well a 2.4ghz (zigbee)

james-fry avatar Apr 20 '20 22:04 james-fry

I also believe that those sub 1GHz modules do not do two or more frequencies at the same time(?) as I believe that you set it to one specific frequency (like 2.4GHz, 915MHz or 868MHz, 315MHz or 433MHz) to use it(?)

Are sub 1GHz even used by any Zigbee application profiles part of the Zigbee 3.0 spec in any case?

https://www.unifore.net/home-alarm-system/introduction-to-zigbee-3-0-zigbee-ha-protocol.html

  • Zigbee Home Automation (Zigbee HA)
  • Zigbee Light Link (Zigbee LL)
  • Zigbee Building Automation (Zigbee BA)
  • Zigbee Retail Services (ZigBee RS)
  • Zigbee Health Care (Zigbee HC)
  • Zigbee Telecommunication services (Zigbee TS)

Or is sub 1GHz only used by Zigbee application profiles that are not part of the Zigbee 3.0 spec?

  • Zigbee Smart Energy (Zigbee SE)

Hedda avatar Apr 21 '20 06:04 Hedda

Anyway, the CC2652P looks like the best chip based on chip specification, with CC2652R and CC2652RB chips having the second-best chip specifications, however, CC1352P based modules are much more readily available today.

Both CC1352P and CC2652P/CC2652R/CC2652RB chips can be bought directly to TI but there appear not to be any complete CC2652 based modules available yet, while there already are already CC1352P modules available from example Ebyte.

http://www.ebyte.com/en/product-view-news.aspx?id=766

Search for article: "E79-400DM2005S" on sites like eBay or Aliexpress to find Ebyte CC1352P module.

Again, CC1352 and CC2652 just users a newer version of the same serial protocol and command set as the CC253x series of chips, so if you get it working on either C1352 or CC2652 then it should not be too much work updating the solution to work on all.

See zigpy-znp https://github.com/zha-ng/zigpy-znp and zigpy-cc https://github.com/zigpy/zigpy-cc

Hedda avatar Apr 21 '20 06:04 Hedda

To get the equivalent SMD module from Silicon Labs then might want to look at EFR32MG1B Series 1.

Ebyte's E180-ZG120A and E180-ZG120B are Zigbee 3.0 module based on EFR32MG1B SoC:

  • http://www.ebyte.com/en/product-view-news.aspx?id=842

EFR32MG1B Series 1 is a 20dbm powerful Zigbee 3.0 radio capable SoC / chip in Silicon Labs EFR32 family which I understand also used the Ember / EZSP interface so could be made compatible with zipy's bellows radio library if flashed with the right firmware? So I guess main question is which exact firmware to use?

  • https://www.silabs.com/wireless/zigbee/efr32mg1-series-1-socs
  • https://www.silabs.com/documents/public/data-sheets/efr32mg1-datasheet.pdf

E180-ZG120B (and the previous E180-ZG120A) modules are sold on eBay and Aliexpress at low prices.

  • https://www.aliexpress.com/wholesale?catId=0&SearchText=%22E180-ZG120B%22

Example:

  • https://www.aliexpress.com/item/4000473346234.html

Ebyte also have this inexpensive development board called "E180-ZG120B-TB" based on that module:

  • http://www.ebyte.com/en/product-view-news.aspx?id=896
    • http://www.ebyte.com/en/downpdf.aspx?id=896
  • http://www.cdebyte.net/test-board/zigbee-3-0-module-usb-test-board-kits.html

This development is sold for less than $9 US-dollar on Aliexpress or about twice that on eBay UK:

  • https://www.aliexpress.com/item/4000538003718.html
  • https://www.ebay.co.uk/itm/EFR32-Zigbee-3-0-Test-Board-USB-Port-2-4GHZ-E180-ZG120B-TB-Test-Kit/233517910970

Looks like you can just remove some jumpers to disable the USB converter to use the serial directly.

Again see bellows for zigpy's Silicon Labs library https://github.com/zigpy/bellows

Hedda avatar Apr 21 '20 07:04 Hedda

Almost any ESP8266 development board (like a NodeMCU or a Wemos D1 Mini) with a Silicon Labs EFR32MG based Zigbee module like the Ebyte E180-ZG120B would just about be about the equivalent to having a hacked Sonoff ZBBridge, so such a setup could be used as a development environment.

The downside to using such setup instead of Sonoff ZBBridge is that the E180-ZG120B module will likely not come preloaded with firmware so have to build EmberZNet PRO Zigbee Stack firmware with coordinator device type config and flash firmware to the E180-ZG120B module first.

See a longer discussion about building Silabs EmberZNet firmware here -> https://github.com/xoseperez/espurna/issues/2224

Hedda avatar Apr 23 '20 09:04 Hedda

FYI @SillyDay don't own a E180-ZG120B but has tried to build a firmware for it as per discussion here:

https://github.com/Koenkk/zigbee-herdsman/issues/168

SillyDay GitHub repo for EFR32 firmware:

https://github.com/SillyDay/EFR32

Hedda avatar Apr 28 '20 09:04 Hedda

FYI, as per related request https://github.com/zigpy/zigpy/issues/405 I just learned that there is an existing ESP8266-based networked-attached Zigbee-adapter called "ZiGate Pack WiFi adapter" which has a new v2.0 firmware that archives this requested function of UART-to-TCP/IP (for Serial-port to WiFi-bridge function) using "ESP-LINK from Jeelab" software, in addition, using ESP-LINK also adds mDNS zeroconf to allow automatic network discovery and configuration:

  • https://github.com/jeelabs/esp-link

    • https://github.com/fairecasoimeme/ZiGate-WiFi

Description of functions that using ESP-LINK will add to v2.0 firmware for ZiGate Pack WiFi adapter:

https://translate.google.com/translate?sl=fr&tl=en&u=https%3A%2F%2Fzigate.fr%2Fdocumentation%2Fdescription-du-firmware-v2-xx%2F

  • ZiGate TCP 9999 to UART WiFi Bridge
  • WiFi configuration in client and access point mode
  • DHCP client or static IP
  • Client syslog
  • SNTP client
  • mDNS
  • MQTT client
  • WiFi firmware update (OTA)
  • Console for logging and validating the operation of the ZiGate

As I understand it, all ZiGate hardware look to be modular in design and the "ZiGate Pack WiFi adapter" is really just an optional ESP8266 based "dumb" UART-to-TCP/IP (for Serial-port to WiFi-bridge function) for the standard "ZiGate TTL adapter" that allows users to connect to it remotely using TCP/IP over your home LAN (Local Area Network) instead of plugging it directly to your computer via the optional USB adapter.

  • https://zigate.fr/produit/module-wifi-v1-3-compatible-zigate/

Specifically, please see the picture of "ZiGate Pack WiFi adapter" https://zigate.fr/produit/zigate-pack-wifi-v1-3/ compared to the picture of "ZiGate TTL USB adapter" https://zigate.fr/produit/zigate-ttl/

Thus "ZiGate Pack WiFi adapter" allows ZHA users to have a networked Zigbee adapter setup like this:

ZHA <–> zigpy/zigpy-zigate <–> TCP/IP over LAN <–> ZiGate-WiFi <–> UART <–> ZiGate Radio

Suggesting this now as I just learned from @doudz there that the new v2.0 version of the ZiGate Pack WiFi adapter firmware contains "ESP-LINK from Jeelab" software which among other things adds mDNS and UART WiFi Bridge support over TCP. As I understand, version v1.x of the firmware for the ZiGate Pack WiFi adapter basically only contained a simple UART/serial-port server forwarding service ( serial server software that just acts as a dumb Zigbee to WiFi bridge for zigpy-zigate), while the new version v2.x also has more advanced features (which does not need to used) it still also contain a simple UART/serial-port server forwarding service, but now mDNS also makes it easier to discover the adapter on your local network.

Now it would be awesome if the ZHA integration component for Home Assistant from an end-user perspective supported just as an easy detection and configuration of network networked-attached Zigbee coordinator adapters, like the Sonoff ZBBridge and the ZiGate Pack WiFi adapter.

I would therefore also suggest using some kind of Zero-configuration networking (zeroconf) method, like for example mDNS, (as mDNS is already in use in Home Assistant Core), to make the ZHA integration component for Home Assistant automatically detect, connect, and configure compatible networked-attached Zigbee coordinator adapters like the "ZiGate Pack WiFi adapter" as that is otherwise already supported by the zigpy-zigate radio library for zigpy.

Hedda avatar May 05 '20 09:05 Hedda

FYI, @s-hadinger has now got a Sonoff ZBBridge and started reviewing the board in it (for Tasmota)

  • https://github.com/arendst/Tasmota/issues/8583

First signs it is the EFR32 Zigbee module it has inside it has EmberZNet / Ember based firmware.

Hedda avatar Jun 01 '20 12:06 Hedda