Zigbee2mqtt not showing up in homeassistant

Super confused newbee.
Have homeassistant (HA) running under Ubuntu/Docker. Successfully added MQTT and integrated into HA. Struggling mightily with addition of zigbee2mqtt. Currently, docker-compose file runs and four (HA, MQTT, Portainer, and zigbee2mqtt) containers show ‘open’ in Portainer. However, I do not see zigbee2mqtt in HA. Not sure if all is properly linked. I can control a simple smart plug through zigbee, but could use some guidance to help me activate MQTT.

Is HA support enabled in z2m? Home Assistant integration | Zigbee2MQTT

Thanks robertklep,
Have reviewed docker files, and remain unsure how to ‘enable’ HA in z2m. Docker compose does not recognize terms I am using.
Log file shows error…
z2m: MQTT failed to connect, exiting…()
I further note that I am unable to access z2m directly. That is, entering my IP:8080 results in a connection error…
“Unable to Connect”

MQTT needs a username and password does not have to be a HA user

MQTT user/password are set. I’ve attempted to add this to my docker-compose file, but it keeps warning me that 'Additional property password is not allowed.

Error Report
Using ‘/app/data’ as data directory
Starting Zigbee2MQTT without watchdog.
[2025-02-23 20:56:13] info: z2m: Logging to console, file (filename: log.log)
[2025-02-23 20:56:13] info: z2m: Starting Zigbee2MQTT version 2.1.1 (commit #1accb8b66b95b99658c50e4c0209edcb946a5fe2)
[2025-02-23 20:56:13] info: z2m: Starting zigbee-herdsman (3.2.5)
[2025-02-23 20:56:13] info: zh:adapter:discovery: Matched adapter: {“path”:“/dev/ttyUSB0”,“manufacturer”:“ITead”,“serialNumber”:“96eeea1ce2e7ed1182d5cc770b2af5ab”,“pnpId”:“usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_96eeea1ce2e7ed1182d5cc770b2af5ab-if00-port0”,“vendorId”:“10c4”,“productId”:“ea60”} => zstack: path=/dev/ttyUSB0, score=4
[2025-02-23 20:56:13] info: zh:zstack:znp: Opening SerialPort with {“path”:“/dev/ttyUSB0”,“baudRate”:115200,“rtscts”:false,“autoOpen”:false}
[2025-02-23 20:56:13] info: zh:zstack:znp: Serialport opened
[2025-02-23 20:56:13] info: z2m: zigbee-herdsman started (resumed)
[2025-02-23 20:56:13] info: z2m: Coordinator firmware version: ‘{“meta”:{“maintrel”:1,“majorrel”:2,“minorrel”:7,“product”:1,“revision”:20210708,“transportrev”:2},“type”:“zStack3x0”}’
[2025-02-23 20:56:13] info: z2m: Currently 0 devices are joined.
[2025-02-23 20:56:13] info: z2m: Connecting to MQTT server at mqtt://localhost
[2025-02-23 20:56:13] error: z2m: MQTT failed to connect, exiting… ()
[2025-02-23 20:56:13] info: z2m: Stopping zigbee-herdsman…
[2025-02-23 20:56:23] info: zh:controller: Wrote coordinator backup to ‘/app/data/coordinator_backup.json’
[2025-02-23 20:56:23] info: zh:zstack:znp: closing
[2025-02-23 20:56:23] info: zh:zstack:znp: Port closed
[2025-02-23 20:56:23] info: z2m: Stopped zigbee-herdsman

docker-compose file
services:
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto
ports:
- 1883:1883
- 9001:9001
volumes:
- /opt/mosquitto:/mosquitto
- /opt/mosquitto/data:/mosquitto/data
- /opt/mosquitto/log:/mosquitto/log
zigbee2mqtt:
container_name: zigbee2mqtt
image: koenkk/zigbee2mqtt
restart: “no”
ports:
- 8080:8080
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
volumes:
- ./data:/app/data
- /run/udev:/run/udev:ro
environment:
- TZ=American/Chicago

So, check the port of your mqtt server being exposed to localhost

Also your firmware is a bit dated, but this is secondary and not related to your issue of z2m not starting up.

Thanks for weighing-in K8gg,
Not sure what you mean by ‘port … exposed to localhost’.
I don’t consider myself a ‘Noob’, more of a ‘Hobbiest’. My background is not programming or networking. Be gentle.
I have reached a precipice on my frustration level, and am considering retreating a few steps and reinstalling. Since Ubuntu, Docker, Portainer, and Homeassistant all appear to function properly. Next step might be to remove MQTT and zigbee2mqtt, and reinstall those. Thoughts?

I think your issue is with the Mosquitto setup. I’m fairly sure that the default for Mosquitto is to only allow connections from localhost, but since you’re running it inside a container, that may cause it to not be able to recognise a connection as coming from localhost.

One solution would be to set up your containers so they all use the same Docker network. Alternatively, create a custom mosquitto.conf that contains this line:

listener 1883 0.0.0.0

My installation is not over docker, but shouldnt your config point to your ip address instead of localhost?

My config regarding that is:

server: mqtt://192.168.0.28:1883
user: xxxx
password: xxxxxx

See: MQTT | Zigbee2MQTT

Thanks Gents,
I confirm that zigbee2mqtt ‘configuration.yaml’ file does point to the server by way to the IP.
server: mosquitto: //192.168.2.30:1883

I confirm that the mosquitto.conf (MQTT) file contains a line…
listener 1883
I’ll add the generic IP (0.0.0.0), and see if that helps.

No joy! I’ll pursue robertklep’s recommendation to consolidate containers to a single Docker network. Although, I’m a bit surprised that if this was/is a genuine issue it was not mentioned in any of the tutorials I reviewed. Thanks for the thoughts. I’ll keep on pluggin’ at this.

That should be:

server: 'mqtt://192.168.2.30:1883'

Negative. That does not work.

Gents,
Thank you for all the suggestions. At this point, I have reviewed existing files ad nauseam, with no hint of resolution. I’m sure the problem stems from a (likely minor) mistake on my part. I hate to stop without a solution, but it feels like time to move on. Let’s consider this issue closed.
I intend to remove/reinstall my MQTT and zigbee2mqtt containers, and rebuild associated files. Hopefully, version 2 will be successful.
Thanks again for the suggestions.

To compare notes, here is my config. I’m not using the installation type of Protainer or dockers either, very likely we are using the same USB stick.

server: mqtt://core-mosquitto:1883
user: xxxxx
password: xxxxxxxxxx

=== sidebar ===
There are many installation methods for the HA, and using docker is probably the more flexible (so that the same metal box could do other tasks) but more difficult (to start and to maintain) method.
If I were you, I would not give up - as you can see people are jumping in trying to help… and it feels like you are so close.
But if in any case you wish to start from scratch, maybe you could consider the HAOS installation route - whether it being directly on your metal box, or as a VM.

Thanks for the encouraging note k8gg. I do feel that I am close. Probably missing a 'space; or ‘hyphen’ somewhere, but as yet I can’t find the error. Last evening, I backed up and restarted the process from zigbee2mqtt initiation only to wind up in the same place. I’ll post portions of my zigbee2mqtt conf file and docker-compose file again for perusal/comment.

Excerpt from dockeer-compose.yaml file

zigbee2mqtt:
    container_name: zigbee2mqtt
    image: koenkk/zigbee2mqtt
    restart: no
    devices:
      - /dev/ttyUSB0:/dev/ttyUSB0/
#      - /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_96eeea1ce2e7ed1182d5cc770b2af5ab-if00:/dev/ttyUSB0
    ports:
#     Frontend port
      - 8080:8080
    volumes:
      - ./data:/app/data
      - /run/udev:/run/udev:ro
    environment:
      - TZ=America/Chicago

zigbee2mqtt configuration.yaml file


# Indicates the configuration version (used by configuration migrations)
version: 4

# Home Assistant integration (MQTT discovery)
homeassistant:
    enabled: false

# Enable the frontend, runs on port 8080 by default
frontend:
    enabled: true
    # port: 8080

# MQTT settings
mqtt:
    # MQTT base topic for zigbee2mqtt MQTT messages
    base_topic: zigbee2mqtt
    # MQTT server URL
    server: 'mqtt://192.168.2.30:1883'
    # MQTT server authentication, uncomment if required:
    user: hass
    password: mrw6369

# Serial settings, only required when Zigbee2MQTT fails to start with:
#   USB adapter discovery error (No valid USB adapter found).
#   Specify valid 'adapter' and 'port' in your configuration.
    serial:
#     # Location of the adapter
#     # USB adapters - use format "port: /dev/serial/by-id/XXX"
#     # Ethernet adapters - use format "port: tcp://192.168.1.12:6638"
      port: /dev/serial/by-id/usb-ITead_Sonoff_Zigbee_3.0_USB_Dongle_Plus_96eeea1ce2e7ed1182d5cc770b2af5ab-if00:/dev/ttyUSB0
#     # Adapter type, allowed values: `zstack`, `ember`, `deconz`, `zigate` or `zboss`
#     adapter: zstack

# Periodically check whether devices are online/offline
# availability:
#     enabled: false

# Advanced settings
advanced:
    # channel: 11
    # Let Zigbee2MQTT generate a network key on first start
    network_key: GENERATE
    # Let Zigbee2MQTT generate a pan_id on first start
    pan_id: GENERATE
    # Let Zigbee2MQTT generate a ext_pan_id on first start
    ext_pan_id: GENERATE

Can you connect to your MQTT broker with something like MQTT Explorer?

1 Like

Not an expert on docker, but, would you be open to the idea to verify your mqtt server independently? If mqtt://192.168.2.30:1883 is indeed available from outside, then we can focus on your z2m docker and not your mqtt broker docker.

You can test that via MQTT client apps, MyMQTT (Android) or MQTT Explorer (PC) are good options and I’m sure there are others out there. The key here is to test it from a different machine / different IP, but w/in the same local network.

Also, I’m under the impression that sometimes yaml could be picky when it comes to " and ’ and no colon, so maybe play around.

Thanks Gents,
Not to seem to ‘dense’ but…
I’ve downloaded MQTT Explorer. Although the connection screen is fairly simple, I’m not certain what my entries should be. And, I want to be sure to feedback accurate information. Here is what I tried first pass…
Name: test.mosquitto.org
Validate certificate: yes
Encryption (tls): no
Protocol: mqtt://
Host: 192.168.2.30
Port: 1883
Username: username
Password: password

I get, “Connection refused: Not authorized”