Home Assistant Sonoff zigbee

Introduction

I used Xiaomi Gateway 3 for my Smart Home with Home Assistant integration last three years.

You can find guidance on how to integrate it with Zegbee2MQTT in this article:

https://www.diyenjoying.com/2022/09/25/home-assistant-zigbee-integration-with-xiaomi-gateway/

Unfortunately, after three years of stable functioning, I was faced with the issue due to losing connection with all my devices after 30 min of Zigbee2MQTT running. 

So, I decided to try Sonoff ZigBee USB 3.0 Plus.

Sonoff ZigBee USB 3.0 Plus configuration

Of cause you can use the dongle as is, but I prefer to update devices with last firmware. 

So, I started with from update.

You can find guidance on now update firmware on Sonoff web-site. 

In this guidance, you can see a pretty complicated instruction for Windows. But update process more simple if you have Linux instance (Raspberry PI for example). So, I updated it with an automatical python script.

The instruction on how to update the firmware on ZigBee2MQTT

First of all you should download the script:

wget https://github.com/JelmerT/cc2538-bsl/archive/refs/heads/master.zip

The next step is unarchiving it:

unzip master.zip 
Archive:  master.zip
538ea0deb99530e28fdf1b454e9c9d79d85a3970
   creating: cc2538-bsl-master/
  inflating: cc2538-bsl-master/.gitignore  
  inflating: cc2538-bsl-master/.travis.yml  
  inflating: cc2538-bsl-master/LICENSE.md  
  inflating: cc2538-bsl-master/README.md  
  inflating: cc2538-bsl-master/cc2538-bsl.py  
  inflating: cc2538-bsl-master/setup.py  
   creating: cc2538-bsl-master/tests/
  inflating: cc2538-bsl-master/tests/test_cc2538-bsl.py  

The script requires a bunch of dependencies, so you have to install them: 

cd ./cc2538-bsl-master
pip install pyserial
pip install intelhex
pip install python-magic

The last version of firmware you can find here.

Please download and unarchive the latest firmware into directory with the script.

And flash your dongle with the command:

python3 cc2538-bsl.py -ewv -p /dev/ttyUSB1 --bootloader-sonoff-usb CC1352P2_CC2652P_launchpad_coordinator_20220219.hex 

You can find path to USB port with connected dongle with following command: 

dmesg | grep cp210x
cp210x converter now attached to ttyUSB1

Zigbee2mqtt configuration

Please be aware that /dev/ttyUSB1 path can be changed after reboot and other USB devices reconnection. So, you need USB port-agnostic link for your dongle. It looks like: /dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0 The easiest way is to find the link in the Supervisor panel. You can find how to revert back Supervisor panel in this article: HOME ASSISTANT REVERT BACK SUPERVISOR PANEL Please open hardware overview:

And find ID for your  USB port with the dongle:

So, you can configure Zigbee2MQTT now.

The step-by-step guidance on how to set up Zigbee2MQTT with Home Assistant you can find in this article:

INTEGRATION BETWEEN ZIGBEE2MQTT AND HOME ASSISTANT

But use ID above for the port configuration.

Problems with Sonoff zigbee dongle and solving them

So, you can configure Zigbee2MQTT now.

The step-by-step guidance on how to set up Zigbee2MQTT with Home Assistant you can find in this article:

INTEGRATION BETWEEN ZIGBEE2MQTT AND HOME ASSISTANT

But use ID above for the port configuration.

I tried to launch Z2M with old config for Xiaomi to avoid re-paring my devices again. I changed port only to Sonnoff Zigbee USB only.

Please notice that I used 25 channel to reduce interference signals with WiFi.

Hence, Z2M launched successfully, but no one device was connected to Sonoff.

I switched back to Xiomi Gateway and removed all devices from the network and switched to Sonoff – no result!

So, I decided to change the channel to default 11.

Please remember that you have to delete following file if you want to change the channel:

/usr/share/hassio/homeassistant/zigbee2mqtt/coordinator_backup.json

Channel should be configured in Z2M config file:

/usr/share/hassio/homeassistant/zigbee2mqtt/configuration.yaml
advanced:
  channel: 25

Unfortunately, I was faced with the following error when I had changed the channel:

Zigbee2MQTT  Error: network commissioning timed out - most likely network with the same panId or extendedPanId already exists nearby

I was struggling with an error for 5 hours till I solved it!!!!

Steps to solve the issue with Zigbee2MQTT Error: network commissioning timed out

According to the Zigbee2MQTT instruction I tried to generate a new PanID with following config:
advanced:
  pan_id: GENERATE
  ext_pan_id: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]
  network_key: GENERATE    

Of cause I changed numbers randomly.

As a result, Z2M generated a new PanID but I still had the same error.

I found the reset button according to the picture on the official site

So, I unscrewed the dongle, reset it and re-flashed firmware to get it with factory default settings.

Also, I re-installed Zigbee2MQTT by deleting its directory and configuring it from scratch.

No result! Error still was present.

I struggled with the issue until I decided to launch Z2M without an antenna on the dongle!

It was magic!!! 

So, you should initiate Zigbee2MQTT without an antenna to solve the error:

(I was also faced with the same error without the antenna. So, I wrapped the dongle with aluminium foil and initiated it without the error).

Zigbee2MQTT  Error: network commissioning timed out - most likely network with the same panId or extendedPanId already exists nearby

Final ZigBee2MQTT config looks like:

/usr/share/hassio/homeassistant/zigbee2mqtt/configuration.yaml
homeassistant: true
mqtt:
  server: mqtt://core-mosquitto:1883
  user: addons
  password: Top_Secret
serial:
  port: >-
    /dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0
  adapter: auto
  rtscts: false
  disable_led: true
frontend:
  port: 8099
devices:
  '0x00_Addr':
    friendly_name: Sensor_1
advanced:
  transmit_power: 15
availability: true
ota:
  ikea_ota_use_test_url: false

conclusion and comparing with Xiaomi gateway

Sonoff zigbee 3.0 usb dongle plus is more simple with firmware updating and connecting to Z2M but I never faced with such problems running Xiaomi Gateway. I spent time integrating it with Home Assistant and forget about it for three years.

I’m surprised by low ZigBee signal strength of Sonoff despite the external antenna.

The same devices had link quality over 200 with Xiaomi and 130 – 160 with Sonoff. So, I’m looking for a more powerful antenna. Moreover, link quality is very sensitive for a place of Sonoff antenna: devices stop response if move Raspberry PI with the dongle around 10sm. 

I improved the signal quality by replacing the antenna with more power full.

I have never seen such behavior with Xiaomi. 

My devices easily connected to Xiaomi Gateway with any channel. 

In the case of Sonoff I several times tried to use the 25th channel, but devices can connect with 11 channels only.

I use Xiaomi plugs and Philips HUE motion and light sensors.

Please feel free to ask any questions in the comments.

 

One thought on “Home Assistant Sonoff zigbee

  1. Hi, I do believe this is an excellent blog. I stumbledupon it 😉 I'm going to return once again since
    I saved as a favorite it. Money and freedom is the greatest way to change, may you be
    rich and continue to help other people.

Leave a Reply

Your email address will not be published. Required fields are marked *