Jsonpath and Regex-Filter in 2.4

Hi all
In the old MQTT-Binding I configured an item
Number itemname “label [%.1f °C]” {mqtt="<[broker:RTL_433/JSON:state:JSONPATH($.temperature_C):.“sid” \: 10,.]"}
To get the temperatur from the following mqtt payload:
{“time” : “2018-12-18 06:14:46”, “brand” : “OS”, “model” : “OSv1 Temperature Sensor”, “sid” : 10, “channel” : 2, “battery” : “OK”, “temperature_C” : 18.800}
In 2.4 I configured this Item with paperUI. JSONPath transformation works but only without appending the regex-filter.
Can anybody help me with this?

1 Like

I solved this like this:

Thing mqtt:topic:rtl433 "Rtl433"  (mqtt:broker:mosquitto) {
        Type string : raw  "Raw"       [stateTopic="devices/rtl433"] 
        Type number : tuin "Tuin temp" [stateTopic="devices/rtl433", transformationPattern="JSONPATH:$..[?(@.model =~ /LaCrosse.*/i )].temperature_C"]

        Type number : other "Tuin other"       [stateTopic="devices/rtl433", transformationPattern="JSONPATH:$..[?(@.model =~ /AlectoV1.*/i )].temperature_C"]
        Type number : humidity "Tuin humidity" [stateTopic="devices/rtl433", transformationPattern="JSONPATH:$..[?(@.model =~ /AlectoV1.*/i )].humidity"]

The jsonpath ($…[?(@.model =~ /LaCrosse.*/i )].temperature_C) translates to look for an object with a model equal to LaCrosse and from that object return the temperature_C. In case the model is not equal this will return null and creates a log warning like this;

[WARN ] [eneric.internal.generic.ChannelState] - Incoming payload 'NULL' not supported by type 'NumberValue'

If that bothers you you can suppress that by changing the log level for that class in the karaf console.


Thank you very much, works like a charm

Have a similar problem: With the old mqtt binding I receive values from an Emonhub node. The Emonhub send its data as a payload with the following (example) format ‘7,3136,10,235.4,0,13,0’. In the item declaration I filtered the payload with a regex expression for each value. For the first value (a 7 in this case) the regex looks like this: mqtt="<[mosquitto:emonhub/rx/10/values:state:REGEX((.),.,.,.,.,.,.*)]".
How can I do a similar transform with the new 2.4 binding?

I didn’t test it, but I found, that Regex-Transformation was not installed under Add-ons. I suppose this was the cause for my problem.

I checked my system and Regex 2.4.0 addon is installed and started. So, that was not the problem.

If you monitor the battery state “OK”,“NOK” then the ‘NULL’ will rewrite the correct state :frowning:

Did you resolve the NULL warning?