from my mqtt topic i get the following back:
i get back
which is RGBW, now i need RGB, i could do that with a regex
which holds in $1 the result i want
Is there a way i can nest those transformations ?
Yes, with any version of the bindings after 2.5 M1 I think. It’s pretty self explanatory in PaperUI how to chain the transformations, separating them with the union symbol.
I am little bit new in REGEX on openhab. Maybe you can help me.
I receive from mqtt broker firmware version string using JSONPATH:
I receive string “v8.1.0(tasmota)”
now I want to apply REGEX to that result to remove “v” and “(tasmota)”.
regix which I want to apply: ^[^\d](\d[.]\d*[.]\d*).*$ with substitution $1
what is correct syntax I need to use for transformationPattern to use JSONPATH & REGEX together?
In openHAB the regex must match the entire string. The first matching group (i.e. stuff in parens) is what get’s returned. That pattern doesn’t do that. For one,
\d matches digits, not letters so it won’t match the starting “v”.
I find it easiest to be simple. We don’t really care about efficiency here as the strings are usually very short and the regex is not called that often. So keep it simple.
Or even simpler:
Just in case there is some white space before or after you can use
See MQTT 2.5 M1+ How to implement the equivalent to MQTT1 REGEX filters, only the regex will go second instead of first as shown in that example.
Not sure yours answer helps me. I still do not understand what i need to put in my things file.
2020-01-31, pn 16:06, Rich Koshak via openHAB Community firstname.lastname@example.org rašė:
Bur how i need to use it with jsonpath with my example. Sorry. I am strugling.
2020-02-01, št 07:52, Ron via openHAB Community email@example.com rašė:
I don’t use MQTT with REGEX but according to the docs I think it should be something like this:
"JSONPATH:$.StatusFWR.Version ∩ REGEX:.*v(.*)\(tasmota\).*"
Note the ‘∩’ character that chains the transformations: first the complete version string is extracted from the JSON response and then the actual version number is regex’ed from that string.
I don’t use nor recommend the use of .things files so I can’t help with that. But in Ron’s example, I’m pretty sure there should not be a space on either side of the