Want to link my SmartThings, IP address problem with MQTT

Hi,

I built a fresh Hassbian instance with the ambition of getting HA and SmartThings to talk two-way, so I can VPN into my HA and observe my home.

I built an MQTT bridge (as described here) in a Docker container on the same Pi as my HA instance.

The Docker container gave the MQTT bridge an IP address of 172...* and I can’t talk to that IP. I realised my first error was building the MQTT bridge on the same box as my HA, it should be on a seperate box with a seperate NIC, but how do I go about getting the MQTT docker container to be on my 192.168.0.0/24 network please?

I can not add static routes with my router.

I think, from memory, that you need net=host when you start the container to use the host network. If not that command it is something you add to the docker startup, so look in that documentation.

1 Like

thanks! I’ll try adding that line and if not, search Docker’s config for initiation strings.

You either need to use the -p flag and forward the ports through host and docker, or use --net=host and allow all the ports.

do i need to run --net=host at the Mosca stage or the MQTT bridge stage?

that flag should be added to your DOCKER command. I don’t understand what you mean by Mosca stage or Bridge stage…

so in this guide I followed: https://home-assistant.io/blog/2016/02/09/Smarter-Smart-Things-with-MQTT-and-Home-Assistant/

There are 2 instances of Docker created, MQTT and MQTT Bridge. I have no technical idea what the difference between them are, or why I need two, I blindly followed the guide.

according to the linked github page port 8080 on the bridge, and you could do net-host on the other

If you look at the ‘Docker’ section under ‘Installation’ you will see that it already passes port 8080 through.

Having heard that it’s a simple switch - -net=host, I don’t see any harm in me setting it on both dockers, MQTT Mosca and MQTT bridge. I will start them from scratch and try again

Still no joy, I get an error when adding a SmartApp, do you think it’s legit to use MQTT and MQTT-bridge on the same physical machine?

I think it would be fine, but you cannot use --net=host for both of them as both of them offer service on ports 1883 and 8883

1 Like

can I use ==net-host and -p 8080:8080 on the same container? e.g. the bridge

That would be pointless and redundant.

net=host means that the container will use whatever port is necessary. if it needs port 8080, it will use it.

-p and net=host should be used separately.

use the -p on the one for 8080, and net=host or -p 1883:1883 -p 8883:8883 on the other one

cheers. I’ve really got my knickers in a twist with this one. Now when i’m creating new docker containers with these options, it’s not going to download all the stuff any more from the web, it’s creating them instantly which is disconcerting.

because it already has local copies of the containers. you don’t need to download them every time.

1 Like

OK I chose to do --net=host on the MQTT bridge, so I configured the SmartThings Device with the physical MAC of my machine which is hosting docker, and it’s IP address. No dice.

Then I read this below in the instructions…I’ve now no idea what docker to give what. If it was you which would you give the --net=host to? MQTT-bridge or MQTT?

The MQTT Bridge only needs to know where your MQTT broker lives. If you are using these docker commands as-is, edit /opt/mqtt-bridge/config.yml to look like this:


mqtt:
host:

I switched it around and it worked. Net=host worked for MQTT and not the MQTT-bridge, thank you for helping @flamingm0e

1 Like