Page 7 of 14

Re: Python Plugin: MqttMapper

Posted: Saturday 16 March 2024 20:34
by FlyingDomotic
Concerning baro, there's a temperature/humidity/barometer device, with type=84 and sybtype=1.

If you have access to ESP code, and can make a unique json message like

Code: Select all

{"druck":1014, "eco2":500,  "error": 0, "iaqAC":0, "luftfeuchte":59.31, "temperatur":19.81, "voc":0}
then you can easily get data with

Code: Select all

"BME680 Temp": {
	"topic": "BME680_01",
	"key": "BME680_01-temperature",
	"type": "84", "subtype":"1",
	"mapping":{"item":"temperatur;humidity;0;druck;0"}
},
"BME680 Iaq": {
	"topic": "BME680_01",
	"key": "BME680_01-iaq",
	"type": "249", "subtype":"1",
	"mapping":{"item":"iaq"}
}
If it's not possible to make a json complete message, then a small change in plugin will be done to allow putting multiple different topics in one device.

Re: Python Plugin: MqttMapper

Posted: Saturday 16 March 2024 23:41
by waltervl
For humidity you need to supply 2 values: HUM and HUM status. See https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s

Re: Python Plugin: MqttMapper

Posted: Saturday 16 March 2024 23:46
by FlyingDomotic
You're right ! That's why humidity is followed by a 0 (which in fact should be entered as ~0).

In the same spirit, baro should be followed by tendency.

Re: Python Plugin: MqttMapper

Posted: Sunday 17 March 2024 2:52
by FlyingDomotic
In case it's not possible to get all data in one JSON message, I made a change to allow inserting full message content specifying ~* in a multiple item sValue.

In your case, after updating to new plugin version, you can try:

Code: Select all

{
	"BME680 Temperature": {
		"topic": "BME680_01/temperatur",
		"key": "BME680_Temp",
		"type": "84", "subtype":"1",
		"mapping":{"item":"~*;~;~;~;~"},
		"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
	},
	"BME680 Humidity": {
		"topic": "BME680_01/humidity",
		"key": "BME680_Temp",
		"type": "84", "subtype":"1",
		"mapping":{"item":"~;~*;~0;~;~"},
		"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
	},
	"BME680 Pressure": {
		"topic": "BME680_01/druck",
		"key": "BME680_Temp",
		"type": "84", "subtype":"1",
		"mapping":{"item":"~;~;~;~*;~0"},
		"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
	},
	"BME680 Iaq": {
		"topic": "BME680_01/iaq",
		"type": "249", "subtype":"1",
		"mapping":{"item":""}
	}
}

Re: Python Plugin: MqttMapper

Posted: Monday 18 March 2024 15:06
by thaui
Thanks for your reply. I have used your json file from above and got the follwing result. Not really what I exprected because Temperature and Barometer values passed away and Hunidity stay 0. I intend to get four devices in domoticz for temperatur/pressure/humidity/iaq ... if possible. The remaining values like CO2, Iaq accuracy and VOC will follow later on when I understand how to configure the json file

Re: Python Plugin: MqttMapper

Posted: Monday 18 March 2024 20:52
by FlyingDomotic
The way it is setup, there's one device for temperature/humidity/pressure. If you really wish to have 3 different devices, that's another configuration (in fact, your original configuration, taking care of not naming 2 devices identically "BME680 Feuchte").

If you want to keep one device for temperature/humidity/pressure, I made an error in humidity topic name in configuration file. Replace:

Code: Select all

"topic": "BME680_01/humidity",
by:

Code: Select all

"topic": "BME680_01/luftfeuchte",

Re: Python Plugin: MqttMapper

Posted: Tuesday 19 March 2024 11:52
by thaui
I followed your advice and changed the topic. Sorry to say that nothing has changed.
devices.JPG
devices.JPG (20.19 KiB) Viewed 1037 times
However I have access to the Arduino sketch where the topics are send to the Mqtt broker but I do not understand how to send all data with one json command as recommended.

client.publish(temp_topic, String(temp).c_str(), true);
client.publish(hum_topic, String(hum).c_str(), true);
client.publish(druck_topic, String(druck).c_str(), true);
client.publish(iaq_topic, String(IAQ).c_str(), true);
client.publish(iaq_ac_topic, String(IAQac).c_str(), true);
client.publish(eco2_topic, String(eCO2).c_str(), true);
client.publish(voc_topic, String(voc).c_str(), true);
Mqtt Explorer.JPG
Mqtt Explorer.JPG (8.91 KiB) Viewed 1037 times

Re: Python Plugin: MqttMapper

Posted: Tuesday 19 March 2024 22:42
by FlyingDomotic
Strange ....

I made a test with the following configuration file:

Code: Select all

{
	"BME680 Temperature": {
		"topic": "BME680_01/temperatur",
		"key": "BME680_Temp",
		"type": "84", "subtype":"1",
		"mapping":{"item":"~*;~;~;~;~"},
		"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
	},
	"BME680 Humidity": {
		"topic": "BME680_01/luftfeuchte",
		"key": "BME680_Temp",
		"type": "84", "subtype":"1",
		"mapping":{"item":"~;~*;~0;~;~"},
		"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
	},
	"BME680 Pressure": {
		"topic": "BME680_01/druck",
		"key": "BME680_Temp",
		"type": "84", "subtype":"1",
		"mapping":{"item":"~;~;~;~*;~0"},
		"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
	},
	"BME680 Iaq": {
		"topic": "BME680_01/iaq",
		"type": "249", "subtype":"1",
		"mapping":{"item":""}
	}
}
I sent the following MQTT messages and saw devices like:
Sans titre.png
Sans titre.png (35.74 KiB) Viewed 1017 times
Are you sure you sure:
1) you have exactly the same settings as me?
2) MQTT is properlly updated?

Concerning changes to code, this is not mandatory anymore, since last changes. However, should you really want to do this, I can give you the lines to add.

Re: Python Plugin: MqttMapper

Posted: Wednesday 20 March 2024 10:19
by thaui
Sorry to say, no changes at all. I am running domoticz on a Rpi3 with bullseye. Domoticz Version is 2024.4 and Mosquitto is 2.0.11. In any case I have deleted the Mqttmapper plugin and reinstalled again to be sure that this is not an issue.

Re: Python Plugin: MqttMapper

Posted: Wednesday 20 March 2024 10:23
by FlyingDomotic
Would it be possible to check (with MQTT EXplorer for example), that you properly receive updates for these topics (in particular, for temp/humidity/pressure) ?

Re: Python Plugin: MqttMapper

Posted: Wednesday 20 March 2024 10:53
by thaui
Yes Mqtt explorer is responding well. I have changed the the json file again and get this result. Barometer does't appear in the Domoticz Gui
devices.JPG
devices.JPG (34.6 KiB) Viewed 1006 times
values.JPG
values.JPG (17.74 KiB) Viewed 1006 times
{
"BME680 Temperature": {
"topic": "BME680_01/temperatur",
"key": "BME680_Temp",
"type": "84", "subtype":"1",
"mapping":{"item":"~*;~;~;~;~"},
"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
},
"BME680 Humidity": {
"topic": "BME680_01/luftfeuchte",
"key": "BME680_Temp",
"type": "84", "subtype":"1",
"mapping":{"item":"~;~*;~0;~;~"},
"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
},
"BME680 Pressure": {
"topic": "BME680_01/druck",
"key": "BME680_Temp",
"type": "84", "subtype":"1",
"mapping":{"item":"~;~;~;~*;~0"},
"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
},
"BME680 Temp": {
"topic": "BME680_01/temperatur",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": ""}
},
"BME680 Baro": {
"topic": "BME680_01/druck",
"type": "243", "subtype": "26", "switchtype": "0",
"mapping": {"item": ""}
},
"BME680 Iaq": {
"topic": "BME680_01/iaq",
"type": "249", "subtype":"1",
"mapping":{"item":""}
}
}

Re: Python Plugin: MqttMapper

Posted: Wednesday 20 March 2024 14:41
by FlyingDomotic
Do you have any errors in Domoticz log?

Re: Python Plugin: MqttMapper

Posted: Wednesday 20 March 2024 14:55
by FlyingDomotic
Did you also update to last version (file /home/pi/domoticz/plugins/MqttMapper/plugin.py version should be "1.0.25"?

If not, go to /home/pi/domoticz/plugins/MqttMapper/ and enter "git pull"

Re: Python Plugin: MqttMapper

Posted: Wednesday 20 March 2024 23:07
by FlyingDomotic
If you prefer having 4 different devices (temperature, humidity, pressure and voc), then load last version (1.0.26) of plugin and use the following configuration file:

Code: Select all

{
	"BME680 Temp": {
		"topic": "BME680_01/temperatur",
		"type": "80", "subtype": "5",
		"mapping": {"item": ""}
	},
	"BME680 Humidity": {
		"topic": "BME680_01/luftfeuchte",
		"type": "81", "subtype": "1",
		"mapping": {"item": ""},
		"initial" : {"nvalue":0, "svalue": "0"}
	},
	"BME680 Baro": {
		"topic": "BME680_01/druck",
		"type": "243", "subtype": "26",
		"mapping": {"item": "~*;~0"},
		"initial" : {"svalue": "0;0"}
	},
	"BME680 Iaq": {
		"topic": "BME680_01/iaq",
		"type": "249", "subtype":"1",
		"mapping":{"item":""}
	}
}
FYI, humidity was not updated due to the fact that standalone humidity sensor need an integer value in nValue while other sensors accept float values in sValue. And your device returns a float value, not compatible with humidity sensor. I made a change in 1.0.26 to round float value in this case.

Re: Python Plugin: MqttMapper

Posted: Thursday 21 March 2024 9:59
by thaui
I can report improvements on the latest version. Thanks a lot for your initiativ. I prefer to have different devices from this topic because I need the sensor accuracy and error value as well. I had no time to test it but I will come back on this. Pls. continue your work because the missing interface between the mqtt broker and Domoticz is a big disatvantage.
devices.JPG
devices.JPG (34.28 KiB) Viewed 968 times

Re: Python Plugin: MqttMapper

Posted: Thursday 21 March 2024 18:17
by thaui
I have tested your json file. The Baro device is not visible in the Domoticz GUI using the type 243 with subtype 26. When is switch to 243 / 9 it's visible but with bar as measuring unit. Why do we have Humidity in the value field? What can we do with the CO2 and VOC values?
devices.JPG
devices.JPG (36.71 KiB) Viewed 940 times

Re: Python Plugin: MqttMapper

Posted: Thursday 21 March 2024 20:50
by FlyingDomotic
Baro is shown in "Weather" tab, not in "Utility", with "type 243 with subtype 26".

Re: Python Plugin: MqttMapper

Posted: Friday 22 March 2024 18:49
by thaui
I have not found out the logic with "mapping" and "Initial". Read several time the github description but found no way to reconfigure the numbers to show Temperature & Humidity with Type 82. What I am missing?

"BME680 Temperature": {
"topic": "BME680_01/temperatur",
"key": "BME680_Temp",
"type": "82", "subtype":"1",
"mapping":{"item":"~*;~;~;~;~"},
"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}
},
"BME680 Humidity": {
"topic": "BME680_01/luftfeuchte",
"key": "BME680_Temp",
"type": "82", "subtype":"1",
"mapping":{"item":"~;~*;~0;~;~"},
"initial":{"nvalue":0, "svalue":"0;0;0;0;0"}

Re: Python Plugin: MqttMapper

Posted: Sunday 24 March 2024 23:49
by FlyingDomotic
"Mapping" indicates how to load MQTT data into Domoticz sValue, while "initial" give (initial) nValue and sValue when device is created, before any MQTT value is read.

Configuration you gave should work. You may perhaps delete "BME680_Temp" device, and restart MqttMapper plugin (or Domoticz).

Ensure you have last version of plugin (by "git pull" when in MqttMapper plugin folder (something like /home/pi/domoticz/plugins/MqttMapper/)

Re: Python Plugin: MqttMapper

Posted: Tuesday 02 April 2024 15:34
by hjzwiers
I have the two temperatures from MQTT.

I have a question how to get a boolean from the file?

I tried using general but failed, so the variable "topic": "ebusd/global/running" is a boolean

"T_Outside": {
"topic": "ebusd/broadcast/outsidetemp",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": "", "multiplier": 0.1}
},

"T_Living": {
"topic": "ebusd/ctlv2/z1RoomTemp",
"type": "80", "subtype": "5", "switchtype": "0",
"mapping": {"item": "", "multiplier": 0.1}
},

"MQTTrunning": {
"topic": "ebusd/global/running",
"type": "243", "subtype": "19", "switchtype": "0",
"mapping": {"item": ""}
}

}