JSONPATH and REGEX on a cached http return

I’m trying to use JSONPATH and REGEX transformation on the return of a web-request, however I’m hitting a wall:

The item:

String Tasmota2_Release "Tasmota2 Release: [%s]" { http="<[tasmota:10000:JSONPATH($[0].name)]"}

gets the state “v5.12.0”
Now, I want to have it without the “v”. I figured a REGEX of “\d{1,2}.\d{1,2}.\d{1,2}” would do the trick (checked with https://regex101.com/).

The item changed to:

String Tasmota2_Release "Tasmota2 Release: [%s]" { http="<[tasmota:10000:JSONPATH($[0].name):\d{1,2}.\d{1,2}.\d{1,2})]"}

produces initially the syntax warnings:

20:52:28.230 [WARN ] [del.core.internal.ModelRepositoryImpl] - Configuration model 'Haus.items' has errors, therefore ignoring it: [57,58]: mismatched character 'd' expecting set null
[57,97]: mismatched input '{' expecting RULE_STRING
[57,98]: missing '}' at '1'
[57,99]: extraneous input ',' expecting RULE_ID
[185,117]: mismatched character '<EOF>' expecting '"'

and when the item is requested by an UI following erors:

21:06:54.367 [WARN ] [.basic.internal.render.SwitchRenderer] - Cannot determine item type of 'Light_Dual2'

for nearly all items, but not the one in question.

Is the usage of JSONPATH and REGEX for an item possible at all?

The errors come from not escaping backslash in a string, see doc. And from a stray ) at the end.

I didn’t test it but the doc says, you can use cascaded transformation with the http binding.

String Tasmota2_Release "Tasmota2 Release: [%s]" { http="<[tasmota:10000:JSONPATH($[0].name):\\d{1,2}.\\d{1,2}.\\d{1,2}]"}

If not i would suggest to use the regex at the label.

String Tasmota2_Release "Tasmota2 Release: [REGEX(\\d{1,2}.\\d{1,2}.\\d{1,2}):%s]" { http="<[tasmota:10000:JSONPATH($[0].name)]"}
1 Like

Sometimes one doesn’t see the wood because of all those trees!

Thanks.

Did some tries to incooperate it. It didn’t work using the label, nor did it work cascading (i.e. JSONPATH and REGEX in the item definition).
I finally just used a JavaScript to do the job.

(function(i) {
    var version =JSON.parse(i)[0].name;
    return version.substring(1);
})(input)

So jsonpath and regex does not work?
Did you check if both transformatino Services are installed?

Both were and are installed, I didn’t get it them to work.