Oh3 mqtt string in number channel json

i am struggling with a transformation:
this is what i have in my mqtt payload:

  "72.7.0" : "232.40",
  "1.7.0" : "289",
  "52.7.0" : "231.90",
  "timestamp" : "2022-09-28T23:02:10",
  "2.7.0" : "0",
  "31.7.0" : "1.02",
  "71.7.0" : "0.69",
  "2.8.0" : "204",
  "16.7.0" : "289",
  "uptime" : "0000:00:53:17",
  "32.7.0" : "233.70",
  "1.8.0" : "104418",
  "13.7.0" : "66.50",
  "51.7.0" : "0.51"

uptime and timestamp are string channels and i get these correct in my item. but the others are number channels and i just cannot get them in my items. the only data i get is NULL.

this is how is use the number channels:

JSONPath Expression:

i would really appreciate your help!


That’s not the valid syntax for a JSONPATH on this JSON. [ ] denotes an element in an array and “2.8.0” isn’t an integer indicating the element of the array.

The correct JSONPATH would be something like $.2.8.0 normally but that won’t work because . has a special meaning in JSON and, strictly speaking, the fact that you have elements with a . in it might even render this not a valid JSON in the first place. You might be able to get it to work by escaping the .: $.2\.7\.0 but I’m not hopeful. Using at least two different JSONPath testers I was unable to create any JSONPATH that would work.

You might need to use the REGEX transformation for this. .*"2.7.0" : "(.*)".* should do it

thanks for your fast response. i know that the dots are the problem, the json-tester i used worked for that but it doesn‘t work in oh3.
i don‘t know how to use regex, could you please explain it?

  1. Install the REGEX transformation add-on
  2. Use REGEX:.*"2.7.0" : "(.*)".* as the transformation entry for that Channel.

There are lots of tutorials on REGEX online as well as testers. In English that expression means

  • .* match any character any number of times until
  • "2.7.0" : " match exactly those characters
  • (.*) match any character any number of times until
  • " match exactly that character
  • .* match any number of characters.

There is bit of oddness in how REGEX works in OH as opposed to the standard. In OH, the expression must match the entire String (normally it just must match part of the String) and the first matching group (i.e. the part of the pattern between the first set of ( )) is the only part of the String that gets extracted and returned.

still null.

i forgot to mention how the channel is defined:
the json configuration string received by the component via MQTT:

Object ID:


Well, that is basically nothing like the original JSON you posted above. No wonder neither worked.

so what can I do?

Create a JSONPATH that processes that String to get the value you are after. If you are receiving both Strings on the same topic, you can use MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters to ignore the messages that don’t contain the information you want. Or you can just ignore the error messages in the logs when the Channel receives a message it can’t use the JSONPATH on.

to close this:
my adaptor didn’t work well and so I had to replace it with an MBUS. This should work with DSMR-Binding.
thanks a lot, though!