[SOLVED] MQTT item parsing

Hi,
I try to parse MQTT message coming from domoticz (topic domoticz/out)

The content of the messages is JSON

Examples :

2015-10-01 21:54:25,493 INFO [log] {
“Battery” : 100,
“RSSI” : 12,
“dtype” : “Temp”,
“id” : “3073”,
“idx” : 45,
“name” : “Temperature”,
“nvalue” : 0,
“stype” : “TFA 30.3133”,
“svalue1” : “22.8”,
“unit” : 1
}

2015-10-01 21:54:25,473 INFO [log] {
“Battery” : 100,
“RSSI” : 12,
“dtype” : “Lux”,
“id” : “0000C03”,
“idx” : 44,
“name” : “Luminosite”,
“nvalue” : 0,
“stype” : “Lux”,
“svalue1” : “30”,
“unit” : 255
}

In my Item, I want to get the svalue1 of sensor name “Luminosite”

I defined it like that:

String LuminositeSensor “Luminosité [%s]” (g1) {mqtt="<[mqttserver:domoticz/out:state:JSONPATH($.svalue1):REGEX(.*“Luminosite”.*)]"}

But I didn’t success in filtering the correponding message, it is skipped…

2015-10-02 00:00:01.574 [DEBUG] [.o.b.m.i.MqttMessageSubscriber] - Skipped message '{
“Battery” : 100,
“RSSI” : 12,
“dtype” : “Lux”,
“id” : “0000C03”,
“idx” : 44,
“name” : “Luminosite”,
“nvalue” : 0,
“stype” : “Lux”,
“svalue1” : “20”,
“unit” : 255
}
’ because Message Filter ‘REGEX(.*“Luminosite”.*)’ does not apply.

despite the regex pattern seems to match …
https://regex101.com/r/nG0eL9/27

any idea of how to define the mqtt binding rule to filter the correct sensor ?
Thanks
Romain

I tested with a java regex parser :
http://www.regexplanet.com/advanced/java/index.html

My new REGEX : [\\s\\S](“Luminosite”)[\\s\\S]

It matches on the test page but not within the MQTT binding…

Where am I wrong ?

Found the response.

In fact, you don’t have to key the REGEX() word for the 5th parameter. You just have to key the REGEX rules directly.

String	LuminositeSensor "Luminosité [%s]"	(g1)	{mqtt="<[mqttserver:domoticz/out:state:JSONPATH($.svalue1):.*\"Luminosite\".*]"}

The sample in the wiki make me the mistake.

1 Like

Could you post the link? I’m trying to integrate an ambient temperature sensor but have had no luck so far. Maybe with the document you used I could fix it? I’ve made a topic describing my problem here: [SOLVED] JSONpath doesn’t have enough parameters?