I have a functional Docker installation of Home Assistant, coupled with MQTT and zigbee2mqtt.
While I can access the Z2M frontend on a web browser on the localhost at port 8080, I cannot access it via the HA User Interface.
I can access the Portainer UI within the HA UI…but not Z2M.
Looking to some other pertinent information: in the docker-compose file, I have for Portainer (and similarly for Duplicati, which I can also access via iframe in the HA UI)
ports:
- "9000:9000/tcp"
while for the other containers I set network_mode: host.
Would that cause the issue ?
It shouldn’t, but the documentation for zigbee2mqtt no longer recommends using host networking mode. The only container I use host networking mode with is home assistant. For zigbee2mqtt, Try changing it to a bridge network with port 8080 defined instead. See link below.
Also, you generally can’t access local lan ip urls using iframes externally. You will need to configure a reverse proxy and setup the iframe url with the external url that will resolve through the proxy.
thanks for your advice.
Actually, when I started to build my Home Assistant configuration, I was using ports.
However I had issues since Z2M was not able to connect to MQTT (as I reported here). This issue was solved by setting everybody as ‘host’.
Meanwhile my comprehension of Docker has improved and I guess that another solution would have been, for Z2M, to link not only the 8080 port (as I already did at that time) but also the 1883 so that it could reach the MQTT broker…but I may be wrong, since I did not see this second port configuration for Z2M on the documentation…
No you specify 1883 for mosquitto only, and my zigbee2mqtt only opens port 8086 for the frontend so you wouldn’t also specify 1883. You only list the port one way that “binds” to the container you’re running to make the port available for incoming connections outside of itself. If you tried also adding 1883 as a port to zigbee2mqtt as well, you would get an error the port is already in use and the container would fail to start.
I run mosquitto directly on the bare metal of the host Ubuntu OS though and not docker, so that could be the difference. So, that would be the equivalent of running my mosquitto in host networking mode if it were docker. I don’t see the harm in running them in host networking mode though and don’t think that is causing your issue on its own. You’re just giving it access to more ports then it really needs.
I’ve run zigbee2mqtt both in bridge and host networking mode. The one thing I noticed about accessing the zigbee2mqtt UI is that in host mode,under settings, frontend, frontend binding host, I had to type out the full 192.168.0.whatever IP address to access the UI. In bridge mode with the -ports option, I put frontend binding host in as 0.0.0.0. . Also, make sure the frontend binding port is right- in your case 8080.