502 Bad Gateway? Zigbee2MQTT

Hi I followed the guide here as best I could to install the Zigbee2MQTT plug-in. How to Install Zigbee2MQTT in Home Assistant - TUTORIAL - YouTube . I managed to get everything installed as instructed. I am not well versed in these matters at all. The only thing I know is that an Amazon reviewer recommended I install it so that a multi-function home automation switch I bought would work properly.

This is how my configuration looks:

But notably my configuration is different from the configuration in the video, because my configuration has separate sections for the “serial” and for “mqtt”. However in the video these are all in a single configuration file?

How should my configuration look and what do I need to enter in these seperate sections to get this to work?

This is how my logfile looks. Please be gently with me. I know nothing.

I do have the ConBee II Zigbee USB dongle.

indentation is wrong, socat should be disabled

  server: 'mqtt://core-mosquitto:1883'
  user: mqtt_user
  password: gravity
  port: /dev/ttyACM0
  adapter: deconz

Stop following youtube guides. (Although this guy is usually reliable)

But especially stop following guides that are out of date, and that specifically say they are out of date and refer you to his updated guide.

But here is the official guide.

To be fair, the guy in the video says his guide is a revised guide. He doesn’t mention it being out of date. (Not that I can see anyway.) I have tried to follow the advice given above and the guide. But it doesn’t appear to have worked. My config now looks like this.

enabled: true
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: false
frontend: true
mqtt: null
port: /dev/ttyACMO
adapter: deconz

The log now gives this response when I try to start it.

[17:44:19] INFO: Preparing to start…
[17:44:20] INFO: Socat enabled
[17:44:20] INFO: Starting socat
Socat startup parameters:
Options: -d -d
Master: pty,raw,echo=0,link=/tmp/ttyZ2M,mode=777
Slave: tcp-listen:8485,keepalive,nodelay,reuseaddr,keepidle=1,keepintvl=1,keepcnt=5
[17:44:20] INFO: Starting socat process …
2023/04/30 17:44:20 socat[53] N PTY is /dev/pts/0
2023/04/30 17:44:20 socat[53] N listening on AF=2
[17:44:22] INFO: Starting Zigbee2MQTT…
Zigbee2MQTT:info 2023-04-30 17:44:28: Logging to console and directory: ‘/config/zigbee2mqtt/log/2023-04-30.17-44-28’ filename: log.txt
Zigbee2MQTT:info 2023-04-30 17:44:29: Starting Zigbee2MQTT version 1.30.3 (commit #unknown)
Zigbee2MQTT:info 2023-04-30 17:44:29: Starting zigbee-herdsman (0.14.103)
Zigbee2MQTT:error 2023-04-30 17:44:29: Error while starting zigbee-herdsman
Zigbee2MQTT:error 2023-04-30 17:44:29: Failed to start zigbee
Zigbee2MQTT:error 2023-04-30 17:44:29: Check Zigbee2MQTT fails to start | Zigbee2MQTT for possible solutions
Zigbee2MQTT:error 2023-04-30 17:44:29: Exiting…
Zigbee2MQTT:error 2023-04-30 17:44:29: Error: spawn udevadm ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:285:19)
at onErrorNT (node:internal/child_process:485:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21)

I do have the mosquito broker add-on installed.

But of note there are two separate sections in my Zigbee2MQTT config titled “MQTTT” and “Serial” (as per the image above.) What should I put here? Can someone please just show me exactly how my completed config should look? I know some guys here will be upset if I don’t learn anything. But I just want my switch to work. It always seems like such a rabbit hole to the uninitiated when it comes to getting even simple things to work in Home Assistant. I have a disability and I just want to be able to use the switch to alert my partner when I need help and to turn the lights on.

When you click on the video link you posted it literally says right below the video that it has been updated and refers you to the updated guide https://www.youtube.com/watch?v=4y_dDgo0i2g&t=0s

Anyhow you have not followed the official guide, because it says

If you are not using the Mosquitto broker addon fill in your MQTT details (leave empty when using the Mosquitto broker addon).

Also you somehow have enabled socat. You don’t need that and shouldn’t have it enabled. This was mentioned by @francisp above.

Hard to know what else may be wrong as your yaml is not posted as yaml. When posting code please put three backticks (ie ```) before and after the code on separate lines

Are you sure of the serial device? What is the output of

ls -l /dev/serial/by-id

What the heck is socat? I don’t have that in mine, but I also don’t see any part of the previous user’s config that shows that enabled. People posting monolithic config blocks (indented and with multiple sections) like francisp did above are unhelpful and confusing since the config page no longer seems to edit/display the config in that manner.

How is anyone supposed to know if a guide is outdated? Stuff seems to change and break so often, that guides aren’t even reliable?

I’m trying to follow the “official” guide (as linked, and as directly off the site), but I can’t get the dang thing working either.

My setup is strictly as-bundled defaults, in this section, itself labeled “socat”:

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: false

(again: these are defaults that the add-on installed with, if something is wrong - don’t tell me it’s wrong, tell the package maintainers)

Blank “mqtt” section (as instructed, since I use Mosquitto)

And the “serial” section:

port: >-
adapter: deconz

And then, the logs:

[00:39:44] INFO: Preparing to start...
[00:39:44] INFO: Socat not enabled
[00:39:46] INFO: Starting Zigbee2MQTT...
Zigbee2MQTT:info  2024-01-13 00:39:51: Logging to console and directory: '/config/zigbee2mqtt/log/2024-01-13.00-39-51' filename: log.txt
Zigbee2MQTT:info  2024-01-13 00:39:51: Starting Zigbee2MQTT version 1.35.1 (commit #unknown)
Zigbee2MQTT:info  2024-01-13 00:39:51: Starting zigbee-herdsman (0.30.0)
Zigbee2MQTT:info  2024-01-13 00:39:51: zigbee-herdsman started (resumed)
Zigbee2MQTT:info  2024-01-13 00:39:51: Coordinator firmware version: '{"meta":{"maintrel":0,"majorrel":38,"minorrel":120,"product":0,"revision":"0x26780700","transportrev":0},"type":"ConBee2/RaspBee2"}'
Zigbee2MQTT:info  2024-01-13 00:39:56: Currently 0 devices are joined:
Zigbee2MQTT:info  2024-01-13 00:39:56: Zigbee: disabling joining new devices.

… and it just hangs there, “running” forever, but “502 bad gateway”, never seems to finish starting up.

Beginning to think Zigbee and Home Assistant just aren’t meant to work together.

edit: It finally finished (??? DOING WHAT ???) about 5 minutes later, claimed success, Web UI loaded, and then I proceeded to spend the next hour trying to get any device to “pair” with it. Clearly in pairing mode, flashing away, and with “allow join” enabled, nothing ever appears. I give up. The ConBee II is going in the trash and it’ll take some time to get over this experience and try Zigbee in HA again.

Google failed you? Most people won’t need it so don’t sweat it.

But really, no logs = no issue.

Cos really, z2m works for thousands of us. So stop being angry and post some logs.