Help with MQTT please

In your initial post, it tried to connect to a broker on 192.168.0.61.

Where does one change that, assuming that’s what you’re implying?

I’m not implying anything, I’m just mentioning an observation :smiley:

I don’t know where that IP-address came from, and if it makes sense to use. It was the MQTT broker IP-address that was initially used, I assumed it was configured as:

server: http://192.168.0.61:1883

(if so, it should have been mqtt://192.168.0.61)

I’ve tried removing the username/password & server information, so it uses defaults as suggested previously by another user - no go.

I’ve edited YAML/config to use localhost:1883, localhost, 192.168.0.61:1883,192.168.0.61, and no matter what details I put in there - it refuses to connect. It stumbles at the same point each time :frowning:

Zigbee2MQTT:info 2022-06-03 10:21:17: Zigbee: allowing new devices to join.
Zigbee2MQTT:info 2022-06-03 10:21:17: Connecting to MQTT server at mqtt://192.168.0.61:1883
Zigbee2MQTT:error 2022-06-03 10:21:23: MQTT failed to connect: read ECONNRESET
Zigbee2MQTT:error 2022-06-03 10:21:23: Exiting…
Zigbee2MQTT:info 2022-06-03 10:21:23: Stopping zigbee-herdsman…

No matter what I put in the config - it dies.

I’ve just gone back to my broker’s log (Mosquitto) and found this in the logs, repeating over & over…

[10:33:44] INFO: Starting mosquitto MQTT broker…
1654248824: Error: Unable to open include_dir ‘/share/mosquitto’.
1654248824: Error found at /etc/mosquitto/mosquitto.conf:36.

Is it likely that this error is causing the connection issues to from Z2M??? The log shows these three lines repeating over & over with different time-stamps.

Have to admit, I do not know enough about MQTT. Have you tried to remove MQTT add-on, reboot and then install again. Just to figure out if MQTT can start with no errors+

1 Like

Yeah, I usually pride myself on figuring out computer related problems with relative ease - but HOAS has been nothing but a pain in the rear-end with one or another issue constantly cropping up. I think half the issue is simply how quickly instruction videos & related pages become obsolete. Every video I’ve seen has a lengthy page of configuration, but since I’ve tried installing Z2M it’s always been a short (roughly 10 lines) YAML, not like the videos which look more like 30 lines.

It certainly doesn’t look good.

Any suggestions on how to fix that?

Google found this

So try active: false

Doesn’t make sense to me, but that’s what I found in my quick search.

In general, you have to get Mosquitto working first, nothing MQTT related will work until you fix it so it starts up ok.

I run mosquitto in a docker container, independent of HA. I know this is more work than running the mosquitto add on, but I like having my MQTT broker running independently, was worth it to me to spend the time to figure it out. I used IOTstack to install, which does most of the work.

Randy

1 Like

KarlM, how is you MQTT configuration looking.

Try using this, no changes.

logins: []
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
  active: false
  folder: mosquitto
1 Like

Awesome! That seems to have fixed the Mozzy Broker from logging repeated errors as previous - THANK YOU soooooo much, Randy! That’s one step nearer, I think…

Thanks, khvej… As above, the ‘false’ seems to have resolved the broker side of things :slight_smile:
Now… I need to resume work on the Z2M as that’s still hiccupping badly :frowning:

Zigbee2MQTT:info 2022-06-03 20:32:42: Connecting to MQTT server at mqtt://192.168.0.61:1883
Zigbee2MQTT:error 2022-06-03 20:32:42: MQTT failed to connect: Connection refused: Not authorized
Zigbee2MQTT:error 2022-06-03 20:32:42: Exiting…
Zigbee2MQTT:info 2022-06-03 20:32:42: Stopping zigbee-herdsman…

I stand corrected… I’ve just refreshed the Broker’s logs - and it’s chock full of this:

1654284972: Client disconnected, not authorised.
1654284973: New connection from 172.30.32.1:39290 on port 1883.

So I have restarted it and refreshed the logs as they’re being added to.

It seems to start without issue - then BAM - and all hope is gone!

[s6-init] making user provided files available at /var/run/s6/etc…exited 0.
[s6-init] ensuring user provided files have correct perms…exited 0.
[fix-attrs.d] applying ownership & permissions fixes…
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts…
[cont-init.d] mosquitto.sh: executing…
[20:40:53] INFO: Certificates found: SSL is available
[cont-init.d] mosquitto.sh: exited 0.
[cont-init.d] nginx.sh: executing…
[cont-init.d] nginx.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
[20:40:53] INFO: Starting NGINX for authentication handling…
[20:40:54] INFO: Starting mosquitto MQTT broker…
1654285254: Warning: Mosquitto should not be run as root/administrator.
[20:40:55] INFO: Successfully send discovery information to Home Assistant.
[20:40:55] INFO: Successfully send service information to the Supervisor.
1654285254: mosquitto version 2.0.11 starting
1654285254: Config loaded from /etc/mosquitto/mosquitto.conf.
1654285254: Loading plugin: /usr/share/mosquitto/go-auth.so
1654285254: ├── Username/password checking enabled.
1654285254: ├── TLS-PSK checking enabled.
1654285254: └── Extended authentication not enabled.
1654285254: Opening ipv4 listen socket on port 1883.
1654285254: Opening ipv6 listen socket on port 1883.
1654285254: Opening websockets listen socket on port 1884.
1654285254: Opening ipv4 listen socket on port 8883.
1654285254: Opening ipv6 listen socket on port 8883.
1654285254: Opening websockets listen socket on port 8884.
1654285254: mosquitto version 2.0.11 running
1654285255: New connection from 127.0.0.1:37444 on port 1883.
1654285255: Client closed its connection.
1654285255: New connection from 172.30.32.1:51860 on port 1883.
1654285255: Client disconnected, not authorised.
1654285255: New connection from 172.30.32.1:48383 on port 1883.
1654285255: New client connected from 172.30.32.1:48383 as 3i2vLaFeouoc4jfyL2L4uq (p2, c1, k60, u’moz’).
1654285256: New connection from 172.30.32.1:51866 on port 1883.
1654285256: Client disconnected, not authorised.
1654285262: New connection from 172.30.32.1:44964 on port 1883.
1654285262: Client disconnected, not authorised.
1654285263: New connection from 172.30.32.1:44980 on port 1883.
1654285263: Client disconnected, not authorised.
1654285264: New connection from 172.30.32.1:44988 on port 1883.
1654285264: Client disconnected, not authorised.

Below is my configuration YAML for Mosquitto Broker…

logins:
require_certificate: false
certfile: fullchain.pem
keyfile: privkey.pem
customize:
active: false
folder: mosquitto

:roll_eyes:

OK so I uninstalled MQTT broker, uninstalled Z2M and reinstalled MQTT broker.

It had retained information from it’s previous install.

I manually deleted the User ‘moz’ and created a new local-only user called ‘mozzy’ with a password.

I went back to the ‘Integrations’ page of HA and found the MQTT broker integration. I clicked ‘Configure’ and then "re-configure MQTT’ at the top where I applied the newly created local-only user of ‘mozzy’ and it’s password.


ETA:
I’d forgotten to restart the broker…

Ignore everything I’d wrote before…

sigh :face_with_raised_eyebrow:


OMG OMG OMG OMG :open_mouth:

I think… I thiiiiiiiink… it’s working… :crossed_fingers:

I’ve just reinstalled Z2M and started the service. I’ve kept an eye on the logs and intermittently refreshed them.

Annnnnnd so far, it’s given the below results without further logs being added, as yet.

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/socat.sh
[21:38:31] INFO: Socat not enabled, marking service as down
cont-init: info: /etc/cont-init.d/socat.sh exited 0
cont-init: info: running /etc/cont-init.d/zigbee2mqtt.sh
cont-init: info: /etc/cont-init.d/zigbee2mqtt.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun socat (no readiness notification)
services-up: info: copying legacy longrun zigbee2mqtt (no readiness notification)
[21:38:32] INFO: Handing over control to Zigbee2mqtt Core …

[email protected] start
node index.js
Zigbee2MQTT:info 2022-06-03 21:38:36: Logging to console and directory: ‘/config/zigbee2mqtt/log/2022-06-03.21-38-36’ filename: log.txt
Zigbee2MQTT:info 2022-06-03 21:38:36: Starting Zigbee2MQTT version 1.25.2 (commit #unknown)
Zigbee2MQTT:info 2022-06-03 21:38:36: Starting zigbee-herdsman (0.14.34)
Zigbee2MQTT:info 2022-06-03 21:38:37: zigbee-herdsman started (resumed)
Zigbee2MQTT:info 2022-06-03 21:38:37: Coordinator firmware version: ‘{“meta”:{“maintrel”:1,“majorrel”:2,“minorrel”:7,“product”:1,“revision”:20220219,“transportrev”:2},“type”:“zStack3x0”}’
Zigbee2MQTT:info 2022-06-03 21:38:37: Currently 0 devices are joined:
Zigbee2MQTT:warn 2022-06-03 21:38:37: permit_join set to true in configuration.yaml.
Zigbee2MQTT:warn 2022-06-03 21:38:37: Allowing new devices to join.
Zigbee2MQTT:warn 2022-06-03 21:38:37: Set permit_join to false once you joined all devices.
Zigbee2MQTT:info 2022-06-03 21:38:37: Zigbee: allowing new devices to join.
Zigbee2MQTT:info 2022-06-03 21:38:37: Connecting to MQTT server at mqtt://core-mosquitto:1883
Zigbee2MQTT:info 2022-06-03 21:38:38: Connected to MQTT server
Zigbee2MQTT:info 2022-06-03 21:38:38: MQTT publish: topic ‘zigbee2mqtt/bridge/state’, payload ‘{“state”:“online”}’
Zigbee2MQTT:info 2022-06-03 21:38:38: Started frontend on port 0.0.0.0:8099
Zigbee2MQTT:info 2022-06-03 21:38:38: MQTT publish: topic ‘zigbee2mqtt/bridge/state’, payload ‘{“state”:“online”}’

:pray:

Does this seem about right to anyone who knows from previous how it should work?

I have not edited the configuration tab of Z2M as yet, so it seems the default config does work - even though everywhere tells me to edit it…

It’s working, after a full uninstallation & reinstallation.

What a hideous headache this has been…

1 Like

Happy to hear.

How about Z2M, can to connect devices?

Well I’ve so far only managed to put my Zigbee (Samsung SmartThings) motion sensor in there, but its’ showing in the Z2M map after I manually reset it (which happened after I’d had 10 cigs and 18 coffees to calm my nerves once things began working).

I only have two zigbee devices, and my next job is to somehow get the Philips Hue Bulb working… Google seems to suggest that ain’t gonna be easy, either :frowning:

Nice to hear. Then it works.

If you have a hue dimmer switch, then it is easy to reset the hue bulbs. , press 1 and 0 at the same time for 10sec, holding it very close to the bulb. Then it resets.
Otherwise, I do not know how to reset them, there are many videos on it😁

It’s done.

I used Alexa to reset the Philips Hue bulb and set HA Z2M to enable join at the same time, it found it instantly :slight_smile:

FWIW, I ran into this issue today (July 2023) with a brand new installation of Home Assistant, and found the docs a bit lacking, and the tutorials on YouTube a bit out of date. What worked for me was using the real IP address of my Home Assistant server when configuring the Zigbee2MQTT add-on, rather than using “localhost” or “127.0.0.1”.

That is, I have a full Home Assistant Operating System installation, and have installed both the Mosquitto broker add-on and the Zigbee2MQTT add-on into that installation. When configuring the Zigbee2MQTT add-on, this did not work:

mqtt:
  server: mqtt://127.0.0.1
  user: mqttclient
  password: lucky#7password

When configured as above, using localhost, I consistently received a “MQTT error: connect ECONNREFUSED” error in the Zigbee2MQTT add-on logs.

Switching to using the “real” IP address of my Home Assistant server did work:

mqtt:
  server: mqtt://10.10.10.31
  user: mqttclient
  password: lucky#7password

I suspect this is due to the nature of networking across the add-on containers. But even the Zigbee2MQTT configuration docs use localhost. Since that’s where I copy/pasted from, it lead me astray. Perhaps it’s fooled others, too.

1 Like