Openhab2 things and REGEX/JSONPATH transformations

After playing around with transformations tonight, trying to get crisper output from my scripts, I think I am more lost as to how transforms work or should be used by things (and possibly items).

exec:command:kitchencheck “TP-Plug Status” [command="/scripts/ check", interval=15, timeout=5]

and the data to be parsed is:


When I check the value, it looks like the default is return the entire string. I just want the stateX value. I made sure that both the JSON and REGEX transformations were installed, and then tried appending the following transforms:

, transform=“REGEX(/“stateXXXX/”:/”(.*)/")"]
, transform=“JSONPATH($.stateX)”]

as well as various combinations of the above. I seem to get the entire string, or NULL, but nothing in between.

Is the right place to be doing these transformations in the things? Should it be done in the items instead? I am referencing the things by the thing’s channels, and haven’t seen any examples of transformations on the results of the channel.


The Thing is the proper place for this binding.

I’m not sure what to offer except I notice you are using / to escape your special characters in the REGEX as opposed to \. You are also missing a .* at the front and end of the REGEX to match everything else in that line.


That being said, your JSONPATH looks correct so I’m surprised it didn’t work.

Are you seeing any errors in your logs?

That helped with that one… both the .* and the forward vs back slashes.

Absolutely nothing in the logs for regex, even after I entered “log:set trace”… other things were tracing, but not REGEX.

JSONPATH still fails, but it logs 2 lines of text, just saying its applying it, not anything about success.


I don’t think REGEX logs anything when it works. JSONPATH too. It only logs when it fails I think. I don’t do to many transforms so I have no further ideas.