MQTT -> Domoticz : multiple devices

Moderator: leecollings

Post Reply
MarsaultP
Posts: 34
Joined: Wednesday 27 November 2019 13:31
Target OS: Linux
Domoticz version: 2024.7
Location: France
Contact:

MQTT -> Domoticz : multiple devices

Post by MarsaultP »

Hi,

ESP8266 hardware / librarie Pubsubclient / MQTT client gateway with lan interface

From a ESP8266 and Pubsubclient librarie, I send temperature device to Domoticz like this :
topic domoticz/in
{ "idx" : 194, "nvalue" : 0, "svalue" : "13.0" }
That work well !
But, I need also to send other temperature, flowrate from other devices ....
What is the syntaxe for example to send values to domoticz/in ?
{ "idx" : 194, "nvalue" : 0, "svalue" : "13.0" } and { "idx" : 195, "nvalue" : 0, "svalue" : "17.0" }

thanks in advance

Philippe
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: MQTT -> Domoticz : multiple devices

Post by waltervl »

See the wiki https://www.domoticz.com/wiki/MQTT#MQTT_to_Domoticz

There is also a link to someone who explained the mqtt payloads for different devices: https://piandmore.wordpress.com/2019/02 ... -domoticz/
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
MarsaultP
Posts: 34
Joined: Wednesday 27 November 2019 13:31
Target OS: Linux
Domoticz version: 2024.7
Location: France
Contact:

Re: MQTT -> Domoticz : multiple devices

Post by MarsaultP »

Thanks for your answer, but my question is not how to use a single device or what is the format of the result for a specific device.
The question is more precisely: how to communicate MQTT to Domoticz for multiple devices at the same time.
So in the wiki it is explained that Domoticz listens to the topic domoticz/in to read data in json format. But there is only 1 topic domoticz/in recognized.
For example, with the homeassistant prefix and the corresponding topic, we distinguish as many devices since the topic contains the type of device, its name etc.... What I see with my Shellys.
How can I do the same with the domoticz prefix for my different Wemos ?
This is what we can see with MQTT Explorer
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: MQTT -> Domoticz : multiple devices

Post by waltervl »

Domoticz needs an mqtt payload for each device.
So you have to send multiple messages. It is not possible to send one big message for all devices.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
MarsaultP
Posts: 34
Joined: Wednesday 27 November 2019 13:31
Target OS: Linux
Domoticz version: 2024.7
Location: France
Contact:

Re: MQTT -> Domoticz : multiple devices

Post by MarsaultP »

Maybe, I confuse the fact that all differents messages from differents devices are stored in the history domoticz/in (?)
I had test with 2 devices and that seems to work (values are updated in Domoticz ....
User avatar
waltervl
Posts: 5397
Joined: Monday 28 January 2019 18:48
Target OS: Linux
Domoticz version: 2024.7
Location: NL
Contact:

Re: MQTT -> Domoticz : multiple devices

Post by waltervl »

I am not a mqtt Domoticz expert. You better test the options. Perhaps it works, perhaps it does not. I don't understand why it should be an issue to send separate messages.

By the way, there are Domoticz devices that are combined devices (eg temp+humidity+barometer), then you better send 1 combined payload (with a combined Svalue).
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
FlyingDomotic
Posts: 326
Joined: Saturday 27 February 2016 0:30
Target OS: Raspberry Pi / ODroid
Domoticz version: 2020.2
Contact:

Re: MQTT -> Domoticz : multiple devices

Post by FlyingDomotic »

If your question is "What's the syntax to send data to different device types to Domoticz", answer is "it depends on Domoticz device type".

Some devices types uses nValue (for numerical value), some nValue and sValue (for string value), and other only sValue.

Values to send also depends on device type.

A good starting point could be https://www.domoticz.com/wiki/Domoticz_ ... .2Fsensors, searching for your device type.

As general guideline, nValue is integer only, while sValue is float (in string format) and string. Multiple values in sValue are separated by ";". For example, sending temperature and humidity (with humidity status) is like 20.1;75;0 (20.1 °C, 75% humidity, status=0: comfortable).

You may connect multiple sensors to the same ESP. Just use the right IDX to send data to the right device.

If you want to see what's received into "domoticz/in" topic, you may use tools like MqttExplorer or MQTT.fx on PC, or even mosquito tools on headless RPi, for example:

Code: Select all

mosquitto_sub -t domoticz/in -u <mosquito_username> -P <mosquito_password>
Replace <mosquito_username> and <mosquito_password> by your mosquito's identifier and password
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests