yllibed / Zigbee2MqttAssistant

GUI for Zigbee2Mqtt running in docker and HASS.IO
449 stars 42 forks source link

[Solved] Please check my config as I can't get Z2MA to connect... #147

Closed mlava closed 4 years ago

mlava commented 4 years ago

Hi there @carldebilly I'm having trouble with getting the container to connet to my MQTT broker. I am running the Assistant on a Synology NAS in a docker container, which also hosts the MQTT broker but using the Mosquitto package for Synology rather than a docker container. My network is using the MQTT broker fine, so I know that isn't the issue.

I have my container setup as follows:

screenshot 4 jpg (2)

screenshot 5 jpg (1)

For the environment variables I have tried with the Z2MA_SETTINGS__ prefix and without. For username and password I've tried "" and just leaving them blank.

I can connect to the server on port 8881 but it never changes from offline in the status page and a network scan finds no devices. I have five T/H sensors all working over Z2M perfectly well with openhab etc, but can't seem to connect via Z2MA.

Can you identify what I've done wrong? Thanks very much in advance!

carldebilly commented 4 years ago

I think you should replace the IP of the MQTT server by its name. I suspect Z2MA can't reach it because of a network issue.

Try to use the name of the container instead of the IP address.

mlava commented 4 years ago

Thanks for responding. I should have been more clear.

Mosquitto isn't running in a container. It's running as a package on my NAS. I don't think it has a name as such.

I tried the smb name of the nas but that didn't work. Is it likely there is an issue running it on Synology?

carldebilly commented 4 years ago

192.168.1.148 is the address of your Synology on your network? Is Z2M running on the synology too and connected using the same parameters?

mlava commented 4 years ago

Yes, that's the syno IP. Z2M is running on a series of RPi 0Ws, connecting to mosquitto on syno IP and port 1883. AFAIK I can't run docker on 0w so can't host it elsewhere other than the syno. Z2M is working across three pi 0Ws and MQTT on syno.

carldebilly commented 4 years ago

You can't run docker on RP0W? OOh.. I though it was supported everywhere.

Since it's possible to install HASS.IO on RP Zero-W (even if not recommended), I think it's definitely possible :-) https://www.home-assistant.io/hassio/installation/

Since Z2MA is now using the Alpine version of the container, it shouldn't be a problem to run on those devices.

mlava commented 4 years ago

Scratch that, you can run docker on a RP0W. Will get back to you...

carldebilly commented 4 years ago

@mlava ... and?

mlava commented 4 years ago

Hi again, I get a restart loop with error code 139 on the Pi0w.

carldebilly commented 4 years ago

Please give more context. Is it an error from docker? from Z2MA? I'll need more info about this.

mlava commented 4 years ago

Sorry.

This is the command I use to start: docker run -p 8881:80 -e Z2MA_SETTINGS__MQTTSERVER="Synology_NAS" -e Z2MA_SETTINGS__MQTTUSERNAME="" -e Z2MA_SETTINGS__MQTTPASSWORD="" --restart unless-stopped be8b9f216c5e

I tried using the image id instead of the z2ma image name as I wasn't sure if it was a package issue for the Pi0w and I downloaded the specific arm image. (I am able to run the helloworld package but only if I specify the arm-hf version.)

docker run hypriot/armhf-hello-world Hello from Docker. This message shows that your installation appears to be working correctly.

I get the same restarting error code 139 with the z2ma container name as well. Same error for the IP address instead of the mqtt server name for Z2MA_SETTINGS__MQTTSERVER.

After thinking for a bit it returns to a command prompt. I can't browse to the z2ma url:port as it times out.

Using the command docker container ls I get: f889164efbcc be8b9f216c5e "dotnet Zigbee2MqttA…" About a minute ago Restarting (139) 23 seconds ago gifted_chebyshev

Occasionally I get signs of life, e.g.: a2726f8613de be8b9f216c5e "dotnet Zigbee2MqttA…" 12 seconds ago Up Less than a second 0.0.0.0:8881->80/tcp nifty_brown but it immediately restarts with code 139

I think the container is crashing inside docker but don't know docker that well. The docker logs command for the container doesn't produce anything at all... e.g. pi@raspberrypi:~ $ docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 0d073b653ed2 be8b9f216c5e "dotnet Zigbee2MqttA…" 11 seconds ago Up Less than a second 0.0.0.0:8881->80/tcp stupefied_austin pi@raspberrypi:~ $ docker logs stupefied_austin pi@raspberrypi:~ $

Docker version 18.06.3-ce, build d7080c1 latest z2ma build as of a week ago

Cheers!

carldebilly commented 4 years ago

This this instead:

docker run -p 8881:80 -e "Z2MA_SETTINGS__MQTTSERVER=Synology_NAS" -e "Z2MA_SETTINGS__MQTTUSERNAME=" -e "Z2MA_SETTINGS__MQTTPASSWORD=" --restart unless-stopped be8b9f216c5e

The quotes were at the wrong place.

mlava commented 4 years ago

Thanks, but that didn't fix @carldebilly

I tried this: docker run -p 8880:80 -e "Z2MA_SETTINGS__MQTTSERVER=192.168.1.148" -e "Z2MA_SETTINGS__MQTTUSERNAME=" -e "Z2MA_SETTINGS__MQTTPASSWORD=" --restart unless-stopped carldebilly/zigbee2mqttassistant

then container ls shows:

4f6ff38fa6ec carldebilly/zigbee2mqttassistant "dotnet Zigbee2MqttA…" 16 seconds ago Restarting (139) 5 seconds ago hungry_fermi

carldebilly commented 4 years ago

I just pasted your command line in my command line and it works... it's complaining it's not able to connect to 192.168.1.148, but it worked.

Please give me more details about what you're trying.

mlava commented 4 years ago

This post covers it. If you just switch the quotes to the right spaces I am getting the same behaviour.

Ive tried with the IP & the name 'Synology_NAS'. Neither work.

RPi0W. Docker version 18.06.3-ce, build d7080c1 latest z2ma build as of three weeks ago

Do I need to worry about which build it is using, or does the docker command to pull carldebilly/zigbee2mqttassistant just download the right version for the architecture?

carldebilly commented 4 years ago

Which OS are you using on your RP0? Z2MA is published with a manifest for multiple architecture, but you can force it by using an architecture-specific tag.

https://hub.docker.com/r/carldebilly/zigbee2mqttassistant/tags

Are you can see on this page, you can use the following command to pull a linux-arm32 tag:

docker pull carldebilly/zigbee2mqttassistant:linux-arm32

For your case, that means:

docker run -p 8880:80 -e "Z2MA_SETTINGS__MQTTSERVER=192.168.1.148" -e "Z2MA_SETTINGS__MQTTUSERNAME=" -e "Z2MA_SETTINGS__MQTTPASSWORD=" --restart unless-stopped carldebilly/zigbee2mqttassistant:linux-arm32
mlava commented 4 years ago

@carldebilly Thanks, but that didn't work for me...

I found this on the docker instructions at https://www.zigbee2mqtt.io/information/docker.html

Note for Raspberry Pi 1 and zero users: there is a bug in Docker which selects the wrong image architecture. Before executing docker run pull the correct image with docker pull koenkk/zigbee2mqtt --platform linux/arm/v6.

Your repo https://hub.docker.com/r/carldebilly/zigbee2mqttassistant/tags only lists the linux/arm version. Could that be arm7 and I need arm6?

pierch commented 4 years ago

@mlava FYI: Z2MA runs just fine on Synology inside docker. Here is the command I used (I've masked some sensitive info): sudo docker run -d -p ****:80 -e "Z2MA_SETTINGS__MQTTSERVER=*.*.*.*" -e "Z2MA_SETTINGS__MQTTUSERNAME=****username***" -e "Z2MA_SETTINGS__MQTTPASSWORD=***pass***" -e "TZ=Europe/*****" --restart unless-stopped carldebilly/zigbee2mqttassistant

I should mention I run all the neccessary services inside docker containers on Syno. Z2M, Z2MA, HA, Mosquitto, etc. and I am quite happy with such setup. Could it be the lack of username/password? Can Z2MA connect to the MQTT broker without them?

carldebilly commented 4 years ago

I just confirmed in another issue that Z2MA can't work on armv6, v7 is required. So that means it won't work on RP-Zero or RP-Zero-W :-( Sorry.

mlava commented 4 years ago

Thanks anyway. re RPi0W.

@pierch Thank you. I tried your command with the appropriate values subbed in and I can access the webserver page. It just never seems to find the Z2M network. The bridge state remains offline and a Network Scan and refresh doesn't lead to any items being discovered.

mlava commented 4 years ago

Re-opened as still not seeing bridge connected or any devices listed after a network scan.

@pierch, I can see Z2MA connect in my logs but no messages on mqtt. Are there any other tricks I need to use to get this working? Cheers!

pierch commented 4 years ago

@mlava: Besides waiting for some of the end devices to report status, I haven't done anything else.

I see you run the broker as Syno package. You could try to run it as a docker container as a test? On the other hand, I don't see why it should not work with your setup.

mlava commented 4 years ago

Hi @carldebilly @pierch I finally have it running on my Synology. The trick was that the MQTTServer environment variable needed to be set to the docker bridge gateway ip. Everything started working as soon as I did that. Cheers!

aHVzY2g commented 4 years ago

@mlava is your Bridge State now "online", because I tried your steps and it didn't solve the issue for me, my Bride States stays offline no matter how I connect? If you could post you config via the export option I guess that could be helpful.

But besides that I was able to connect to mqtt via the IP and the docker container name.

aHVzY2g commented 4 years ago

I had to activate homeassitant in Zigbee2mqtt now evreything works as expected

kristianrl commented 4 years ago

I read the entire thread as I was encountering a similar issue. If this could be of use for anyone in the future, I have attached screenshots of my working setup: I am running zigbee2mqtt as well as zigbee2mqttassistant on the same docker host (my Synology DS219+ with DSM's Docker interface). Both containers are set up with "Use the same network as Docker host".

Zigbee2mqttassistant in Docker on Synology DSM

I have changed Z2MA_SETTINGS__MQTTSERVER as well as changing the port number for ASPNETCORE_URLS

Zigbee2mqttassistant in Docker on Synology DSM