Skip to content

Commit

Permalink
Add router support (Closes: #12) (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
syssi authored Feb 22, 2022
1 parent 8371ec5 commit 42f3060
Show file tree
Hide file tree
Showing 6 changed files with 105 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea/
secret.yaml
secrets.yaml
.esphome/
**/.pioenvs/
**/.piolibdeps/
Expand Down
54 changes: 9 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
![GitHub watchers](https://img.shields.io/github/watchers/syssi/esphome-zb-gw03)
[!["Buy Me A Coffee"](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://www.buymeacoffee.com/syssi)

ESPHome custom firmware for ZB-GW03 eWeLink Ethernet Zigbee Gateway.
ESPHome custom firmware for ZB-GW03 eWeLink Ethernet Zigbee Gateway

## Compatible hardware

Expand All @@ -23,55 +23,19 @@ ZB-GW03 Zigbee to LAN bridge/gateway based on Espressif ESP32 and a Silicon Labs

## Requirements

* [ESPHome 2021.10.0 or higher](https://github.com/esphome/esphome/releases).
* [ESPHome 2021.9.3](https://github.com/esphome/esphome/releases) (see "Known issues")

## Installation
## Quick start guides

Use the `example.yaml` as proof of concept:

```bash
# Install esphome
pip3 install esphome

# Clone this external component
git clone https://github.com/syssi/esphome-zb-gw03.git
cd esphome-zb-gw03

# Validate the configuration, create a binary, upload it, and start logs
esphome run example.yaml
```

## Flash the Zigbee module via telnet

This step is required only if the Zigbee module (SM-011 V1.0, EFR32MG21) wasn't flashed via Tasmota.

```bash
apt-get install lrzsz
wget https://github.com/arendst/Tasmota/raw/development/tools/fw_SonoffZigbeeBridge_ezsp/ncp-uart-sw_6.7.8_115200.ota

# Turn "download mode" switch ON
# Toggle "zigbee reset" switch
# Turn "download mode" switch OFF
# Shutdown Home Assistant (we are trying to avoid multiple cnnections to the stream_server)

telnet 192.168.132.230 6638

# Press return
# Press 1 (upload gbl)
# Close the telnet connection
# Upload the new firmware
sx -vv -X -b --tcp-client 192.168.132.230:6638 ncp-uart-sw_6.7.8_115200.ota
```

Additional (yet untested) firmware versions:

* https://github.com/xsp1989/zigbeeFirmware/tree/master/firmware/ZigbeeBridge_SM-011
* https://github.com/xsp1989/zigbeeFirmware/tree/master/firmware/Zigbee3.0_Dongle/EZSP
* https://github.com/xsp1989/zigbeeFirmware/tree/master/firmware/Zigbee3.0_Dongle/RouterForDongle
* [Flash ESPHome and use the ZB-GW03 as Zigbee Coordinator](docs/flashing.md)
* [How to convert the router into a coordinator](docs/router.md)

## Known issues

None.
* Watchdog heartbeat timeouts if you use ESPHome `>2021.9.3` ([#8][i8])<br/>
https://github.com/oxan/esphome-stream-server/issues/14

[i8]: https://github.com/syssi/esphome-zb-gw03/issues/8

## References

Expand Down
12 changes: 9 additions & 3 deletions docs/flashing.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Flashing guide

![GitHub actions](https://github.com/syssi/esphome-zb-gw03/actions/workflows/ci.yaml/badge.svg)
![GitHub stars](https://img.shields.io/github/stars/syssi/esphome-zb-gw03)
![GitHub forks](https://img.shields.io/github/forks/syssi/esphome-zb-gw03)
![GitHub watchers](https://img.shields.io/github/watchers/syssi/esphome-zb-gw03)
[!["Buy Me A Coffee"](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://www.buymeacoffee.com/syssi)

Table of contents:
* [Warning](#warning)
* [Tools needed](#tools-needed)
Expand Down Expand Up @@ -127,8 +133,8 @@ Setup an ESPHome Project (see [README.md](../README.md)), compile the firmware f
flash the firmware to the device:

```
$ esphome run example.yaml
INFO Reading configuration example.yaml...
$ esphome run coordinator-example.yaml
INFO Reading configuration coordinator-example.yaml...
WARNING GPIO4 is a Strapping PIN and should be avoided.
Attaching external pullup/down resistors to strapping pins can cause unexpected failures.
See https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
Expand Down Expand Up @@ -255,4 +261,4 @@ Turn "download mode" switch OFF and toggle "zigbee reset" again. The Zigbee modu
* Search for "ZHA" (Zigbee Home Automation)
* Choose "Enter Manually" at the serial port selection dialog
* Choose "EZSP" as type of your Zigbee radio
* The serial device path is `socket://esphome_node_name.local:6638` (f.e. `socket://zb-gw03.local:6638` if you use the `example.yaml`). Enter `115200` baud as port speed and the "data flow control" is `software`
* The serial device path is `socket://esphome_node_name.local:6638` (f.e. `socket://zb-gw03.local:6638` if you use the `coordinator-example.yaml`). Enter `115200` baud as port speed and the "data flow control" is `software`
85 changes: 85 additions & 0 deletions docs/router.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# How to convert the router into a coordinator

![GitHub actions](https://github.com/syssi/esphome-zb-gw03/actions/workflows/ci.yaml/badge.svg)
![GitHub stars](https://img.shields.io/github/stars/syssi/esphome-zb-gw03)
![GitHub forks](https://img.shields.io/github/forks/syssi/esphome-zb-gw03)
![GitHub watchers](https://img.shields.io/github/watchers/syssi/esphome-zb-gw03)
[!["Buy Me A Coffee"](https://img.shields.io/badge/buy%20me%20a%20coffee-donate-yellow.svg)](https://www.buymeacoffee.com/syssi)

#### 1. Make sure Home Assistant (ZHA) doesn't use the device as coordinator

#### 2. Flash the `router-example.yaml` to your ZB-GW03

```
esphome run router-example.yaml
```

#### 3. Install the xmodem file transfer tool lrzsz

```
apt-get install lrzsz
```

#### 4. Download the Zigbee router firmware image

```
wget https://github.com/digiblur/Tasmota/raw/development/zigbee_router/efr32mg21_zigbee_router_signed-6.7.10.gbl.ota
```

#### 5. Boot the Zigbee module into the download mode

- Turn on the `Download Mode` switch entity via Home Assistant
- Turn on the `Zigbee Reset` switch entity via Home Assistant (goes to "off" automatically)
- Turn off the `Download Mode`

#### 6. Telnet to the bootloader of the Zigbee module and select "upload gbl"

- `telnet 192.168.132.230 6638`
- Press `return`
- Press `1` and `return` to select "upload gbl"

```
$ telnet 192.168.132.230 6638
Trying 192.168.132.230...
Connected to 192.168.132.230.
Escape character is '^]'.
Gecko Bootloader v1.9.1.04
1. upload gbl
2. run
3. ebl info
BL >
Gecko Bootloader v1.9.1.04
1. upload gbl
2. run
3. ebl info
BL > 1
begin upload
```

#### 7. Goto a second terminal and upload the new firmware. You don't need to cancel the telnet session

```
$ sx -vv -X -b --tcp-client 192.168.132.230:6638 efr32mg21_zigbee_router_signed-6.7.10.gbl.ota
connecting to [192.168.132.230] <6638>
Sending efr32mg21_zigbee_router_signed-6.7.10.gbl.ota, 1843 blocks: Give your local XMODEM receive command now.
Bytes Sent: 236032 BPS:3556
Transfer complete
```

#### 8. Restart the Zigbee module via Home Asisstant or Reboot the whole device

Press the `Zigbee Reset` switch or `Restart` switch.

#### 9. Enable the "Pairing Mode"

Goto the ESPHome device in Home Assistant and turn the "Enable Pairing Mode" switch on.

#### 10. The Router can be paired now with your Zigbee Coordinator

If you use ZHA go to your Zigbee Coordinator Device and press "Add device".

![Paired Zigbee router](../images/zha-paired-router.png "Paired Zigbee router")
Binary file added images/zha-paired-router.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion router-example.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
substitutions:
name: zb-gw03-router
name: zb-gw03-coordinator

packages:
zb-gw03:
Expand Down

0 comments on commit 42f3060

Please sign in to comment.