Multiple MQTT?

Xiaomi, Ikea TRÅDFRI, Philips Hue and more.

Moderator: leecollings

Post Reply
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Multiple MQTT?

Post by Calzor Suzay »

Can you run multiple MQTT On one RaspberryPi4?

I already have the "MQTT Client Gateway with LAN interface" running on Domoticz.
I'm about to introduce Shelly devices and would like to add a Zigbee dongle so will then need the ShellyMQTT and Zigbee2MQTT.

Can they all run on the same box, IP, port etc?
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Multiple MQTT?

Post by lwolf »

They can use the same mqtt server, as the MQTT path used by the plugins is different. Just make sure to use enough CPU power and network bandwidth on mqtt server machine. A lot of device will make a lot of mqtt messages. :)
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Multiple MQTT?

Post by FireWizard »

HI @Calzor Suzay

You wrote:
Can you run multiple MQTT On one RaspberryPi4
What do you really mean with "multiple MQTT"?

MQTT is a client/server protocol.

In order to use it, you need a MQTT server, often called a broker. This server can be installed on the same hardware as e.g. Domoticz.
There exist many different brokers, such as HiveMQ, Eclipse Mosquitto, etc.
A comprehensive list, you can find at https://github.com/hobbyquaker/awesome-mqtt#broker.

Probably one of the brokers (servers) that is most used, is Mosquitto,

It is sufficient to install one instance of Mosquitto on your host or even in your local network. It is possible to install a second instance, even on the same host, but in this case you need to give it another port number. The default port number is 1883 and if you install another MQTT server on the same device, you have to configure another port number, e.g. 1884.

All other devices, such as the Domoticz "MQTT Client Gateway with LAN interface" are clients (see the name). Also other "hardware" devices, such as Zigbee2MQTT, Shelly MQTT, but also the Desktop/Laptop clients, as MQTT Explorer and MQTTfx are clients. This is also the case with the CLI clients mosquitto_pub and mosquitto_sub, part of the mosquitto-clients package.
You can connect as many clients to your server, as you like (compare it as browser to a particular website).

Als the clients should publish their payloads under a different topic, so that other clients can subscribe to it.

@lwolf says:
They can use the same mqtt server, as the MQTT path used by the plugins is different
The different path, he mentioned, are the different topics. It is true for the plugin, you mentioned, but you should check that if you use MQTT, that the topics are different. But pay attention, that if two Domoticz instances, publish to the same MQTT server, they use the same topic (domoticz/out and domoticz/in). So do not configure 2 Domoticz devices to the same MQTT broker.

To answer your question.
Can they all run on the same box, IP, port etc?
Yes, all "hardware" can run on the same box and, yes that box has got one (wired) single IP address and Probably one (wireless) IP address.
It is not necessary to change the port number, so leave it default 1883.

Your CPU power is more than enough. (I run one of my Mosquitto servers on a Pi 1) and MQTT is specially developed to run on low bandwidth networks.
See: https://mqtt.org/

From Wikipedia:
It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited.
Regards
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Re: Multiple MQTT?

Post by Calzor Suzay »

Ok so I'm thinking terminology or at least reading install FAQs that assume you have nothing and want to start from scratch.

I started off a while back with some Sonoff devices that I flashed with tasmota, at that point I ran through the wiki here https://www.domoticz.com/wiki/MQTT and installed Node.JS, Node-RED and an MQTT broker.
I believe this resulted in the "MQTT Client Gateway with LAN interface" under hardware.
Then I added 1 shelly device which I installed the ShellyMQTT python plug in for from here https://github.com/enesbcs/Shelly_MQTT
Which reading again looks like it points back to the MQTT server I setup in the first bit for Tasmota.

Now I want to add a Zigbee dongle and looking at this https://www.zigbee2mqtt.io/getting_star ... 2mqtt.html and it says "Before starting make sure you have an MQTT broker installed on your system" which I assume is the thing I installed right at the start for the Tasmota/MQTT requirement.

Is that a correct assumption?
In which case if it is I'm good to go and just need to get the dongle and then zigbee2mqtt but then I thought how does it appear in Domoticz and confused myself again.

Basically how do I get Zigbee devices into Domoticz, am I following the right path with zigbee2mqtt?
I plan on buying the ZZH device.
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Re: Multiple MQTT?

Post by Calzor Suzay »

Think I just bumbled my way across the domoticz-zigbee2mqtt-plugin

So in summary I need:-
Dongle https://www.tindie.com/products/electro ... -rf-stick/
zigbee2mqtt installed https://www.zigbee2mqtt.io/getting_star ... 2mqtt.html
domoticz-zigbee2mqtt-plugin https://github.com/stas-demydiuk/domoti ... qtt-plugin

??
User avatar
FireWizard
Posts: 1745
Joined: Tuesday 25 December 2018 12:11
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Voorthuizen (NL)
Contact:

Re: Multiple MQTT?

Post by FireWizard »

Hi, @Calzor Suzay,

You wrote:
I ran through the wiki here https://www.domoticz.com/wiki/MQTT and installed Node.JS, Node-RED and an MQTT broker.
In this case you have your complete infra structure ready and you have the tools to handle almost every challenge. In addition you can use several scripts and plugins.

Fot your applications, in fact, the MQTT server is the heart of the system.

All kind of devices, like the Sonoff (flashed with Tasmota), Shelly or Zigbee devices, using Zigbee2MQTT, but also others publish their values to the MQTT server. All the plugins subscribe to the corresponding topics on the server and write directly the values to Domoticz.
Sometimes, we use an application or solution for which no plugin exists. In this case we can use Node Red, who subscribes to the published topic. We can convert the values into a by Domoticz readable format and publish it to the same server under the topic domoticz/in. Domoticz is able to read that data and controls the virtual sensor.
"Before starting make sure you have an MQTT broker installed on your system" which I assume is the thing I installed right at the start for the Tasmota/MQTT requirement. Is that a correct assumption?
Right, you have installed the broker.(server).
In which case if it is I'm good to go and just need to get the dongle and then zigbee2mqtt but then I thought how does it appear in Domoticz and confused myself again.
This is handled by the Domoticz plugin: https://github.com/stas-demydiuk/domoti ... qtt-plugin.

I think with you hardware/software selection you are on the right track and you will succeed.

Regards
Calzor Suzay
Posts: 145
Joined: Tuesday 08 July 2014 15:10
Target OS: -
Domoticz version: 4.9700
Location: UK
Contact:

Re: Multiple MQTT?

Post by Calzor Suzay »

Thanks for confirming :)
I have some Shelly kit on order so will play with this first before adding Zigbee as well.
lwolf
Posts: 216
Joined: Saturday 10 November 2018 18:29
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Hungary
Contact:

Re: Multiple MQTT?

Post by lwolf »

Calzor Suzay wrote: Sunday 10 January 2021 22:42 Basically how do I get Zigbee devices into Domoticz, am I following the right path with zigbee2mqtt?
I recommend using Domoticz Plugins Manager which has a nice GUI after you can succesfully install it, and in the future you can install or update Python plugins with one click:
https://github.com/stas-demydiuk/domoti ... ns-manager
(list includes domoticz-zigbee2mqtt and shelly_mqtt plugin amongs a lot of other plugin)
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest