Page 1 of 1

MQTT -> Domoticz : multiple devices

Posted: Friday 29 March 2024 22:43
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

Re: MQTT -> Domoticz : multiple devices

Posted: Friday 29 March 2024 22:55
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/

Re: MQTT -> Domoticz : multiple devices

Posted: Saturday 30 March 2024 15:24
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

Re: MQTT -> Domoticz : multiple devices

Posted: Saturday 30 March 2024 17:11
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.

Re: MQTT -> Domoticz : multiple devices

Posted: Saturday 30 March 2024 17:27
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 ....

Re: MQTT -> Domoticz : multiple devices

Posted: Saturday 30 March 2024 19:47
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).

Re: MQTT -> Domoticz : multiple devices

Posted: Wednesday 03 April 2024 15:12
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