xyzroe / ZigStarGW-FW

ZigStar LAN Gateway - Firmware
GNU General Public License v3.0
87 stars 25 forks source link

Cannot connect to mosquitto mqtt running as HA addon #18

Open evlo opened 1 year ago

evlo commented 1 year ago

I'm trying to have zigstar GW connect to mosquitto MQTT server running as HA addon (HA supervised) and getting these errors

2022-09-07 22:23:49: Client <unknown> disconnected, not authorised.
2022-09-07 22:24:34: New connection from on port 1883.

I tried these settings (password is from home assistant integration where it says core-mosquitto etc.) image

and also image

while having config like this image

zigbee2mqtt connects and communicates no problem whatsoever

https://github.com/mercenaruss/zigstar_gateways/issues/20

Any ideas why it does not connect?

evlo commented 1 year ago

Update: I figured out that if I use 192.168.50.20 instead of homeassistant.local it does connect, but only if 192.168.50.20 os same subnet as zigstargw, if i have server on 192.168.51.20 it does not connect.

xyzroe commented 1 year ago

I would recommend checking the connection to MQTT broker using some other software. For example MQTT Explorer.

When you understand what credentials and server address you should use for authorization, then we will try with Zigstar.

xyzroe commented 1 year ago

Update: I figured out that if I use 192.168.50.20 instead of homeassistant.local it does connect, but only if 192.168.50.20 os same subnet as zigstargw, if i have server on 192.168.51.20 it does not connect.

Well, of course. You are probably using the /24 subnet

evlo commented 1 year ago

image with mqtt explorer it does work even when using homeassistant.local as "Server IP", but it does say IP anyways.

regarding 192.168.51.20 - normal z2m running on 192.168.51.20 was able to connect to zigstarGW ok, but only the mqtt connection to 192.168.51.20 did not work - mosquitto broker was/is running on the same ip, but maybe that is some mqtt thing and it does not work over subnets?

xyzroe commented 1 year ago

with mqtt explorer it does work even when using homeassistant.local as "Server IP", but it does say IP anyways.

This is because your PC support mDNS ("*.local) but ZigStar doesn't. You must specify exactly IP address of your mqtt broker.

regarding 192.168.51.20 - normal z2m running on 192.168.51.20 was able to connect to zigstarGW ok, but only the mqtt connection to 192.168.51.20 did not work - mosquitto broker was/is running on the same ip, but maybe that is some mqtt thing and it does not work over subnets?

This is because when z2m connecting to ZigStar connection going from z2m add-on to ZigStar. And docker doesn't block this connection. But when you trying to connect ZigStar with mqtt broker, connection goes from ZigStar to mqtt broker. So you need to specify you docker's physical network IP, not virtual one that used for communicating between add-ons.

@evlo By and large, your questions are more about the work of networks, home assistant, mqtt and so on than ZigStar.

alexbocman commented 1 year ago

Actually, I've got the same issue. It's not possible to establish connection to mosquitto mqtt running as HA addon.

I'm using SLS via Mosquitto Broker add-on and ZigStar GW via zigbee2mqtt. Tried to connect ZigStarGW to HA via mqtt with the same settings as SLS (SLS had been switched off during trial) in order to get control for ZigStarGW, but there's no mqtt connection as you can see on the picture. image image

MQTT Mosquitto has the following settings: image

Logs: image

alexbocman commented 1 year ago

The issue is solved by adding a new user to Mosquitto broker Add-On Configuration:

image image

By the way the SLS is still working with an old credentials which had been set in Mosquitto integration.