Zigbee2mqtt - New Sonoff Universal Zigbee 3.0 USB Dongle Plus that gives me, 502: bad gateway

Hi,
Bought a Sonoff Universal Zigbee 3.0 USB Dongle Plus Gateway with an Antenna.
, for my Raspberry Pi 4 with Home Assistant (image) installed.

Sonoff device: version 1.29.2-1

Zigbee2mqtt addon config:
data_path: /config/zigbee2mqtt
socat:
enabled: false
master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
options: -d -d
log: true
mqtt:
ase_topic: zigbee2mqtt
user: mqtt_user
password: ???
server: mqtt://core-mosquitto:1883
serial:
port: >-
/dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0
adapter: ezsp
zigbee_herdsman_debug: true

Debug:
cat /config/zigbee2mqtt/log/2023-01-30.15-27-29/log.txt
debug 2023-01-30 15:27:29: Loaded state from file /config/zigbee2mqtt/state.json
info 2023-01-30 15:27:29: Logging to console and directory: /config/zigbee2mqtt/log/2023-01-30.15-27-29 filename: log.txt
debug 2023-01-30 15:27:29: Removing old log directory /config/zigbee2mqtt/log/2023-01-29.20-08-28
info 2023-01-30 15:27:29: Starting Zigbee2MQTT version 1.29.2 (commit #unknown)
info 2023-01-30 15:27:29: Starting zigbee-herdsman (0.14.83-hotfix.0)
debug 2023-01-30 15:27:29: Using zigbee-herdsman with settings: {adapter:{concurrent:null,delay:null,disableLED:false},backupPath:/config/zigbee2mqtt/coordinator_backup.json,databaseBackupPath:/config/zigbee2mqtt/database.db.backup,databasePath:/config/zigbee2mqtt/database.db,network:{channelList:[11],extendedPanID:[221,221,221,221,221,221,221,221],networkKey:HIDDEN,panID:6754},serialPort:{adapter:ezsp,path:/dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0}}

After following numerous videos on Youtube within the subject, and other forum texts on the internet, I need serious help on this. Can’t simply get inte to work. Some have suggested to remove old backups, but with no luck for this to work.

My Home Assistant server on the Raspberry Pi have the IP: 172.16.1.102 but the MQTT service seem to have 172.30.33.0 (core-mosquitto). Should the MQTT have the former or later IP?

I would appreciate any suggestions to get this working.

Regards
Lars

Do you have the Sonoff Universal Zigbee 3.0 USB Dongle Plus-E? If not, remove the adapter info in your settings because the Plus-P is not an ezsp.

1 Like

I have the Plus-P version. I saw one user that added the adapter. When I remove it, more errors turn up in the logfile. Please see below:

cat /config/zigbee2mqtt/log/2023-01-30.17-08-34/log.txt
debug 2023-01-30 17:08:34: Loaded state from file /config/zigbee2mqtt/state.json
info 2023-01-30 17:08:34: Logging to console and directory: ‘/config/zigbee2mqtt/log/2023-01-30.17-08-34’ filename: log.txt
debug 2023-01-30 17:08:34: Removing old log directory ‘/config/zigbee2mqtt/log/2023-01-29.20-14-39’
info 2023-01-30 17:08:34: Starting Zigbee2MQTT version 1.29.2 (commit #unknown)
info 2023-01-30 17:08:34: Starting zigbee-herdsman (0.14.83-hotfix.0)
debug 2023-01-30 17:08:34: Using zigbee-herdsman with settings: ‘{“adapter”:{“concurrent”:null,“delay”:null,“disableLED”:false},“backupPath”:"/config/zigbee2mqtt/coordinator_backup.json",“databaseBackupPath”:"/config/zigbee2mqtt/database.db.backup",“databasePath”:"/config/zigbee2mqtt/database.db",“network”:{“channelList”:[11],“extendedPanID”:[221,221,221,221,221,221,221,221],“networkKey”:“HIDDEN”,“panID”:6754},“serialPort”:{“path”:"/dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0"}}’
error 2023-01-30 17:08:55: Error while starting zigbee-herdsman
error 2023-01-30 17:08:55: Failed to start zigbee
error 2023-01-30 17:08:55: Check Zigbee2MQTT fails to start | Zigbee2MQTT for possible solutions
error 2023-01-30 17:08:55: Exiting…
error 2023-01-30 17:08:55: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)
at ZStackAdapter.start (/app/node_modules/zigbee-herdsman/src/adapter/z-stack/adapter/zStackAdapter.ts:103:27)
at Controller.start (/app/node_modules/zigbee-herdsman/src/controller/controller.ts:132:29)
at Zigbee.start (/app/lib/zigbee.ts:58:27)
at Controller.start (/app/lib/

Lars

Try with removing the integration and restart HA, then re-install the integration again to start over fresh.

I have shutdown the Raspberry and power of, after removing the Zigbee2mqtt addon. After start up, I added the addon again and added the previous configure.yaml code. The debug result can be seen below:
cat /config/zigbee2mqtt/log/2023-01-30.17-41-01/log.txt
debug 2023-01-30 17:41:01: Loaded state from file /config/zigbee2mqtt/state.json
info 2023-01-30 17:41:01: Logging to console and directory: ‘/config/zigbee2mqtt/log/2023-01-30.17-41-01’ filename: log.txt
debug 2023-01-30 17:41:01: Removing old log directory ‘/config/zigbee2mqtt/log/2023-01-30.17-09-05’
info 2023-01-30 17:41:01: Starting Zigbee2MQTT version 1.29.2 (commit #unknown)
info 2023-01-30 17:41:01: Starting zigbee-herdsman (0.14.83-hotfix.0)
debug 2023-01-30 17:41:01: Using zigbee-herdsman with settings: ‘{“adapter”:{“concurrent”:null,“delay”:null,“disableLED”:false},“backupPath”:"/config/zigbee2mqtt/coordinator_backup.json",“databaseBackupPath”:"/config/zigbee2mqtt/database.db.backup",“databasePath”:"/config/zigbee2mqtt/database.db",“network”:{“channelList”:[11],“extendedPanID”:[221,221,221,221,221,221,221,221],“networkKey”:“HIDDEN”,“panID”:6754},“serialPort”:{“path”:"/dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0"}}’
error 2023-01-30 17:41:22: Error while starting zigbee-herdsman
error 2023-01-30 17:41:22: Failed to start zigbee
error 2023-01-30 17:41:22: Check Zigbee2MQTT fails to start | Zigbee2MQTT for possible solutions
error 2023-01-30 17:41:22: Exiting…
error 2023-01-30 17:41:22: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)
at ZStackAdapter.start (/app/node_modules/zigbee-herdsman/src/adapter/z-stack/adapter/zStackAdapter.ts:103:27)
at Controller.start (/app/node_modules/zigbee-herdsman/src/controller/controller.ts:132:29)
at Zigbee.start (/app/lib/zigbee.ts:58:27)
at Controller.start (/app/lib/controller.ts:101:27)
at start (/app/index.js:107:5)

An error at start occures directly. I find anything interresting when search for these error lines.

Lars

According to the logs, it’s failing in connecting to the adapter ie. the Sonoff for some reason. Either confirm that your settings is correct in this sense or try to use ttyUSB0 instead.

Edit: Are you using an USB-extension for the adapter? If not, it’s recommend at least in regards of interference down the road. Then the adapter might be sensitive to USB 3.0, this can also be eliminated with the extension.

Unless you sanitized the log and changed the adapter id, the port name looks wrong.

Earlier I use the /dev/ttyUSB0, but recommended by users to change to use the Sonoff serial path, usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0, instead since it’s always the same. It didn’t change anything either.

BTW, the command gives: ls -la /dev/serial/by-id
total 0
drwxr-xr-x 2 root root 60 Jul 13 2022 .
drwxr-xr-x 4 root root 80 Jul 13 2022 …
lrwxrwxrwx 1 root root 13 Jul 13 2022 usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0 → …/…/ttyUSB0

I have earlier used one of the two the USB 3.0 ports on the RPI. The other USB 3.0 is used by a small USB stick of 128GB. I have now changed the Sonoff to one of the USB 2.0 ports. The other USB 2.0 port is not used. Nothing that helps anyway.

Lars

Didn’t understand that. Could you please clarify a bit more?

Lars

That’s correct, this is for eliminating the risk of loosing the connection to the adapter at for instance restarts. But just to eliminate one factor during troubleshooting, I suggested to test ttyUSB0.

None the less, I wonder if the old settings are saved even though you removed the integration. I’d remove the integration yet again and then also delete the zigbee2mqtt folder under config and try once more.

Removed the /config/zigbee2mqtt folder after removed the addon in HA. Did a shutdown and power of for a couple of minutes. PowerOn and added the zigbee2mqtt addon once again. Added the config and started. Sorry to say… same old problem occur again, please see debug info below:

cat /config/zigbee2mqtt/log/2023-01-30.19-18-38/log.txt
debug 2023-01-30 19:18:38: Can’t load state from file /config/zigbee2mqtt/state.json (doesn’t exist)
info 2023-01-30 19:18:38: Logging to console and directory: ‘/config/zigbee2mqtt/log/2023-01-30.19-18-38’ filename: log.txt
info 2023-01-30 19:18:38: Starting Zigbee2MQTT version 1.29.2 (commit #unknown)
info 2023-01-30 19:18:38: Starting zigbee-herdsman (0.14.83-hotfix.0)
debug 2023-01-30 19:18:38: Using zigbee-herdsman with settings: ‘{“adapter”:{“concurrent”:null,“delay”:null,“disableLED”:false},“backupPath”:"/config/zigbee2mqtt/coordinator_backup.json",“databaseBackupPath”:"/config/zigbee2mqtt/database.db.backup",“databasePath”:"/config/zigbee2mqtt/database.db",“network”:{“channelList”:[11],“extendedPanID”:[221,221,221,221,221,221,221,221],“networkKey”:“HIDDEN”,“panID”:6754},“serialPort”:{“path”:"/dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0"}}’
error 2023-01-30 19:18:58: Error while starting zigbee-herdsman
error 2023-01-30 19:18:58: Failed to start zigbee
error 2023-01-30 19:18:58: Check Zigbee2MQTT fails to start | Zigbee2MQTT for possible solutions
error 2023-01-30 19:18:58: Exiting…
error 2023-01-30 19:18:59: Error: Failed to connect to the adapter (Error: SRSP - SYS - ping after 6000ms)
at ZStackAdapter.start (/app/node_modules/zigbee-herdsman/src/adapter/z-stack/adapter/zStackAdapter.ts:103:27)
at Controller.start (/app/node_modules/zigbee-herdsman/src/controller/controller.ts:132:29)
at Zigbee.start (/app/lib/zigbee.ts:58:27)
at Controller.start (/app/lib/controller.ts:101:27)
at start (/app/index.js:107:5)

Lars

Might suspect that there are something at play here with either the adapter it self, USB-port or the USB-extension. Are you able to use the ZHA integration with the same hardware setup?

Hmm… don’t know any about that. Need to check, but something tells me that it should, but I don’t know anything about it. I’m new to this. It’s about a week and a half since I started this “project”. If ZHA will work. It will take some time I guess.

Lars

Installing ZHA is a little easier than Z2M, normally the adapter will automatically be recognised within HA and then it’s just a click away.

If your ls output above is accurate, then the device is correct.

The port name looked off to me. Your logs show:

  • /dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0

I thought the “0001” was off, I have a long hex ID in that spot, but there are other differences in the string as well.

Now I think you just have one of the earlier sticks before Sonoff changed the ID string format.

So, going down alternate paths…

Check the “Settings->Devices and Services” page. If the ZHA integration is shown at all, it may be interfering. If ZHA is shown as “Discovered” with a “Configure” button, click the vertical “…” more menu and choose “Ignore.” If ZHA is showing and appears to be configured, click the vertical “…” more menu and choose “Disable.” Then reboot and test z2m.

If the above doesn’t apply or doesn’t work, then look at resetting the stick.

Have you flashed the latest firmware? I would expect z2m to load with older firmware, but never ran an older version myself. Even if current, re-flashing will wipe the stick, which could be a good debug step.

I would try:

  1. Stop the addon.
  2. Flash the stick
  3. Remove the “coordinator_backup.json” file from the zigbee2mqtt folder if it exists
  4. Say a prayer
  5. Start the addon

Current status:
I have now removed the Zigbee2mqtt addon and related folders/files in /config and shutdown and poweroff. Remove the Sonoff and restarted and when up I removed the Zigbee integration. Shutdown/Poweroff once again, and enter my Sonoff device. Added Zigbee integration and it’s configuration to be able to enable ZHA instead of Zigbee2mqtt. Entered a Aqara Water Leak Sensor, without no problem and it detects “water” state from the “dry” state earlier, when I put it in a small amount of water. Thats sound good. I have not upgrade the Sonoff with any new firmware yet, since I only run Linux computer here at home and no Windows. I read something about it should be possible to update firmware using a python script. Need to look into it more.