Hi,
I’m in the beginning of OH2 implementation at home. Basic stuff works pretty well now. Now I try to use MQTT to get data from my Domoticz instance that I want to keep for now.
Every messages are sent to a common MQTT topic (domoticz/out). The value I want to read is always associated with “svalue1” name, and sometime additional with “svalue2”, “svalue3”. Exported messages in the MQTT looks like this:
{
“Battery” : 255,
“RSSI” : 12,
“description” : “”,
“dtype” : “Current”,
“id” : “10”,
“idx” : 195,
“meterType” : “Energy”,
“name” : “Teleinfo Courant”,
“nvalue” : 0,
“stype” : “CM113, Electrisave”,
“svalue1” : “12.0”,
“svalue2” : “0.0”,
“svalue3” : “0.0”,
“unit” : 0
}
So I want to provide the right values to each item. To get the right data to the right item, I can use the idx value which is unique for each item. So I tried, without success, to use a regex before the jsonpath to ensure only the right message with the right idx value is used by the item. There are no error in the logs, the item just do not capture the values.
My item definition looks like this:
Number EnergyHousePercent "Teleinfo Pourcentage de Charge [%.1f %%]" {mqtt="<[nasmqtt:domoticz/out:state:JSONPATH($.svalue1):REGEX(.*\"idx\".*196,$)]"}
My presumption is that the regex return only one line and I did not identify any modifier to make the result multiline.
NB: I have another collection of messages I get from another common topic on MQTT with only 1 line and then this method works well.
- How should I do to confirm that presumption ? What log should I look at and would I need to change the log level ?
- How should I get the full multiline json back from the regex instead ?
- How should I proceed with another way to have the same result ?
Thanks for your kind and patient attention ^^