Before I begin, I’m not being lazy and asking for a solution, I would just like to understand the concept so I can start in the right place. Time and time again I spend loads of time on something only to find I’ve taken the wrong path to begin with.
I have two problems I wish to address:
A. I wish to be able to control a second Z-wave network in my garden shed as I cannot stretch the house z-wave that far. I have extended my network to my shed via cat6 and installed another Pi.
B. I want to be able to control my Caravans openhab which is miles away.
Ideally control all through one sitemap.
I understand the basics of MQTT as I’ve used it to send messages to my SmartThings in the past. For this I installed the mosquito broker on my pi along with a SmartThings device handler.
I’m struggling to get me head around the whole concept so I’m unsure how to start.
Do I just install the broker on my shed pi and the client on the home pi?
I’m unsure how to translate the MQTT message and forward to a z-wave channel. Do I just use a rule?
One pi with openHAB cloud, all my items, broker and client?
The other pi with just the broker. Port forward to the ip and port?
From what I’ve read it may be the eventbus MQTT that I need but to be honest I’m in a bit of a muddle. Brokers, clients, eventbus, persistence, bindings…. sore head…
If anyone could help me get my head around it would really appreciate it.
B. I recommend using a cloud-based MQTT broker like CloudMQTT. You will need to set up Items that mirror your Caravans openHAB in your main openHAB and use the MQTT Event Bus. You could go through the work of exposing your own broker to the internet but given the level of the questions I would not recommend that.
Another approach is to set up a VPN (I use OpenVPN) between your remote and home networks in which case both networks will be able to see each other. Depending on the nature of the devices in the remote environment you may be able to do it all with just one OH. If not, then your remote OH will be able to see your already existing broker.
You need only one broker that all your clients can see. So just reuse the broker you already have.
and 2. I don’t understand the question.
The MQTT Broker is the central communication point. Clients publish and subscribe to topics on a central broker. When a client publishes a message, the broker makes sure that all the clients who are subscribed receive the message. There are ways to get brokers to talk to each other but from the client’s perspective, that is transparent.
The MQTT EventBus configuration will create a set of topics for all of your Items in OH and it will publish and subscribe to those topics. Consequently, all the events that occur on one OH get published and read on the other OH and vice versa. This is appropriate for your use case.
Thanks very much, your response helps massively, it makes a lot more sense now.
I’m using a Razberry with my Pi, would it be correct to assume that this will still work as it uses a serial port?
If it won’t work I’ll just create a rule for each broker item to push the state to each z-wave item.
Ah that sounds like a good idea, I never knew that such a thing existed.
Would this mean that I would always need an internet connection to control my devices locally?
The caravan is where I use SmarthThings with the Mosquitto broker. I assume I can send from this to CloudMQTT then to my main openHAB at home? I don’t make things easy for myself do I!
Not sure I fully understand this approach. Do I install OpenVPN on both Pi’s then port forward through my router to connect them or something? Never used a VPN apart from to change my ip address sometimes.
Ignore my waffle you have already answered it anyway
Thanks very much for clearing up the differences between, broker, client and event bus. I can see I’m on the right track at least.
If it shows up as a /dev/tty device then it will work with socat/ser2net.
This CloudMQTT is what links the two OH instances together. Locally you will be talking to your OH directly and OH will be talking to your devices directly. But if there is no internet connection then your other OH will not be informed of these interactions.
You can configure your SmartThings to use CloudMQTT or you can set up Mosquitto as a bridge and have it forward messages on certain topics to CloudMQTT.
A VPN is a secure way to make two LANs able to see each other over the Internet through an encrypted tunnel. You would install an OpenVPN server on one subnet and configure it appropriately which would include setting up a port forward to the OpenVPN server (usually 1194 I think). Then on your remote devices use the OpenVPN clients to connect to your OpenVPN server. You probably will want some sort of Dynamic DNS set up as well. Most midrange or better wifi routers will have OpenVPN built into them. I know for sure the Nighthawk series of routers do.
As an example, I have an OpenVPN server and I set up an OpenVPN client on my phone. So when I bring up the openHAB app it connects to the local address, not the remote myopenhab.org address because as far as my phone is concerned, it is on the same network as my OH server.
So if you set up a VPN connection between your remote LAN and your home LAN, all the computers on both LANs can see each other.
Another approach is to set up an ssh tunnel between your server and your home OH server. This is similar to the OpenVPN approach but ends up being a point-to-point solution. Rather than connecting your two LANs it only connects those two computers.