Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[REQUEST] Use zigpy & bellows with the new Sonoff ZBBridge (cheap Zigbee to WiFi Bridge/Gateway by Itead) #385

Closed
Hedda opened this issue Apr 20, 2020 · 16 comments

Comments

@Hedda
Copy link
Contributor

Hedda commented Apr 20, 2020

Please consider looking at using Sonoff ZBBridge as a networked Zigbee adapter for zigpy & bellows

Would be very cool if we could use this new Sonoff ZBBridge as a remote WiFi adapter for zigpy and bellows. Maybe just by forwarding the serial port (UART Bus) via TCP/IP if and when its ESP8266 is flashed with a third-party "OS" (firmware)?

Perhaps as a proof-of-concept just using something simple like ser2net (remote serial server) and socat combination to allow ZHA to remote connect to it via serial/UART over the network, like what Zigbee2mqtt does:

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

Backstory bellow:

Itead has just launched a new product called "Sonoff ZBBridge" which at less than $17 US-dollar is a very inexpensive Zigbee to Wi-Fi Bridge/Gateway which contain a very powerful Zigbee radio module.

According to the teardown on notenoughtech.com it sounds as if it contains a Silicon Labs EFR32MG21 Zigbee 3.0 radio module support and ESP8266 for WiFi and bridge/gateway/controller software. EFR32MG21 is one of the latest chip in EFR32 Gecko Series 2 MCU, and ESP8266EX is basically an Arduino microcontroller with integrated Wi-Fi and full TCP/IP stack that runs the more advanced "OS" bridge/gateway firmware, supporting either NodeMCU on Arduino IDE or MicroPython (Python for microcontrollers)

Early indications based on specifications imply that its Zigbee radio might be EmberZNet / Ember / EZSP compatible so could be that if manage to hack/replace the ESP8266 firmware then could perhaps use serial communication with bellows to control its Zigbee radio.

Please see related requests/discussion in #297 and zigpy/bellows#183

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

A similar to Sonoff ZBBridge but non-Zigbee RF to WiFi device called "Sonoff RF Bridge" already existing and that device has been hacked to run third-party open-source ESP8266 firmware from ex. ESPHome, Tasmota, ESPurna, and OpenMQTTGateway. So instructions for different methods to flash firmware on that "Sonoff RF Bridge" device already exist.

As you might already know, Tasmota also does something similar with its Zigbee2Tasmota (Z2T) subproject but by connecting an ESP8266 to a Texas Instrument CC2530 and acting as a MQTT gateway

@Hedda Hedda changed the title [REQUEST] Use zigpy & bellows with Sonoff ZBBridge (Zigbee to WiFi Bridge/Gateway by Itead) [REQUEST] Use zigpy & bellows with the new Sonoff ZBBridge (cheap Zigbee to WiFi Bridge/Gateway by Itead) Apr 20, 2020
@Hedda
Copy link
Contributor Author

Hedda commented Apr 20, 2020

I guess as a proof-of-concept you could use a popular ESP8266 development board with matching capabilities to the ESP8266EX in Sonoff ZBBridge, like the NodeMCU ESP8266 (ex, ESP8266 12-E NodeMCU Kit) or a Wemos D1 Mini (which feature the same type of ESP8266EX).

Then to it connect any already zigpy supported serial Zigbee module (like example CC2530) to its matching zigpy radio library by using ser2net or any other open-source remote serial server / serial port forwarding software that is compatible with ESP8266 / Arduino.

Maybe even a good excuse to for some zigpy developers here to play with MicroPython on ESP8266? ;)

@Hedda
Copy link
Contributor Author

Hedda commented Apr 20, 2020

Do you think that you could use esp-link for this? It is supposed to have advanced serial bridge code?

@Hedda
Copy link
Contributor Author

Hedda commented Apr 20, 2020

ESPEasy (ESP Easy) firmware can otherwise be used as a generic Ser2Net gateway (serial port wrapper)

https://www.letscontrolit.com/wiki/index.php/Ser2Net

https://github.com/letscontrolit/ESPEasy

@Hedda
Copy link
Contributor Author

Hedda commented Apr 20, 2020

@oxan might have a "stream server" solution for ESPHome firmware in esphome/feature-requests#660

@Hedda
Copy link
Contributor Author

Hedda commented Apr 21, 2020

ESP8266 dev board like NodeMCU V2 with a module like Ebyte E180-ZG120B is about the equivalent.

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

Example:

Ebyte is making an inexpensive development board called "E180-ZG120B-TB" made for testing it.

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

Note! Ebyte is now making two EFR32MG12 based modules called E180-ZG120A and E180-ZG120B

Sonoff ZBBridge could be the perfect hardware if it was not for the case that it needs to be hacked.

@Hedda
Copy link
Contributor Author

Hedda commented May 4, 2020

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

Koenkk/zigbee-herdsman#168

SillyDay GitHub repo for EFR32 firmware:

https://github.com/SillyDay/EFR32

@Hedda
Copy link
Contributor Author

Hedda commented May 5, 2020

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:

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 (zeroconf)
  • 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.

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
Copy link
Contributor Author

Hedda commented May 13, 2020

Home Assistant 0.110 & later should allow zeroconf instance sharing between different integrations:

See -> home-assistant/core#35484 ("shared zeroconf instance")

This new approach allows the zeroconf instance to be shared between Home Assistant integrations.

@Hedda
Copy link
Contributor Author

Hedda commented Jun 1, 2020

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

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

@Hedda
Copy link
Contributor Author

Hedda commented Jun 2, 2020

There is now also a deep dive follow-up discussion here in parallel about hacking or flashing its EFR32:

@Hedda
Copy link
Contributor Author

Hedda commented Jun 22, 2020

FYI; Tasmota developers has made great progress hacking Sonoff ZBBridge's EFR32 Zigbee module:

@mtx512 also builds a custom ZNet EZSP NCP firmware for the EFR32 module inside Sonoff ZBBridge:

Interestingly @s-hadinger also added a TCP serial bridge to Tasmota firmware for remote access:

Description:

Add a new feature: Serial to TCP bridge (similar to esp-link). This allows to remotely communicate to a MCU through ESP8266. Needs #define USE_TCP_BRIDGE

It adds 2 GPIO types: TCP Tx (208) and TCP Rx (209) and can work with hardware or software serial.

Commands:

  • TCPBaudRate <x>: sets the baudrate for serial (only 8N1 mode), min 1200, max 115200 by 1200 increments.
  • TCPStart <port>: listens to port <port>. This features supports 2 parallel TCP connexions, which can be useful if you need a terminal + a specific protocol (like XMODEM). The 3rd connection will disconnect an previous connection. The number of parallel connections is a compile-time option.
  • TCPStart 0 or TCPStart: shuts down the TCP server and disconnects any existing connection.

For security reasons, the TCP bridge is not started at boot, and requires an explicit TCPStart command (can be automated with Rules).

@Hedda
Copy link
Contributor Author

Hedda commented Jul 3, 2020

FYI, @s-hadinger has after the last pull request posted saying that he now feels Tasmota ready for testing of EZSP v8 interface:

arendst/Tasmota#8583

arendst/Tasmota#8839

Not for everyone yet since still need to flash its EFR32 chip with some type of J-Link Debug Probe (might always be required?).

@tube0013
Copy link
Contributor

@Hedda If you follow the instructions in arendst/Tasmota#8583 to flash the bridge with tasmota (compile with the tcp-serial enabled), and flash the firmwares there. knowing that v8 ezp support is sort of a work in progress for bellows, you can connect to remote serial ports natively in HA by manually specifying the Port, picking the ezp type radio and using the socket://host:ip as the port. https://youtu.be/RLIiAJXLU0A

@Hedda
Copy link
Contributor Author

Hedda commented Jul 31, 2020

Yes @digiblur posted step-by-step instruction here https://www.digiblur.com/2020/07/how-to-use-sonoff-zigbee-bridge-with.html

As you can read in the update there, flashing the EFR32 chip can now be done from the tasmota-zbbridge firmware once flashed.

As you can also read you can also flash it with an older EmberZNet firmware which support EZSP v4 protocol that is stable in bellows.

Also see PRs zigpy/bellows#285 & #447 & home-assistant/home-assistant.io#14124

@Hedda
Copy link
Contributor Author

Hedda commented Aug 10, 2020

Closing as this is now supported in bellows as long as flashed with Tasmota

https://www.digiblur.com/2020/07/how-to-use-sonoff-zigbee-bridge-with.html

https://www.youtube.com/watch?v=dC1AEyFhmnc

@Hedda Hedda closed this as completed Aug 10, 2020
@Hedda
Copy link
Contributor Author

Hedda commented Mar 11, 2021

FYI, HW tip now is to instead use Tube's Zigbee Gateways open-source hardware by tube0013 (which is tested via ESPHome FW).

It is based on WT32-ETH01 ESP32 board from Wireless-Tag which also has wired Ethernet for a much more stable serial connection.

He designed two variants; one has a Silicon Labs EFR32 Series 2 module and one that has a Texas Instruments CC2652P module.

https://github.com/tube0013/tube_gateways

Hardware, firmware and configuration discussion -> #584

https://www.tubeszb.com/shop/coordinators/2

image

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants