Http Binding Regex help

Hi!
I need your help…
I am trying to load on a sitemap a title track music value from a page.
my page gives me:
{"song":{"file":"http://95.182.79.189:8008/Rock_Hits.mp3","title":"Sentenced - Funeral Spring","time":0,"pos":304,"id":924}}
I’m trying to do a thing:
‘String TrackName “TrackName[%s]” (gMusic) { http="<[http://192.168.1.8:5050/current:REGEX(\.title\"\:("."),\.*)]" }’

Binding configuration of type ‘http’ of item ‘TrackName’ could not be parsed correctly.
org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig ‘http://192.168.1.8:5050/current:REGEX(.title":("."),.)’ doesn’t represent a valid in-binding-configuration. A valid configuration is matched by the RegExp '(.?)({.})?:(?!//)(\d):(.*)’

what am I doing wrong? tell me please

The page is returning JSON, why not use JSONPATH?

JSONPATH($.song.title)

Anyway, the error is telling you that your http binding configuration string is incorrect. " could not be parsed correctly." Looking at the binding docs it shows you need three fields separated by a :. You only have two. You are missing the refresh field telling the binding how often to poll that URL.

Finally, your REGEX is wrong. You need to match the entire String and your REGEX doesn’t, it only matches part of the String.

REGEX(.*title\".\"(.*)\".*)

I use . instead of : to avoid further parsing problems since : is a special character for the http binding config.

1 Like

Thanks for the answer. I would be happy to use the JSONPATH but also get an error :frowning:

'Binding configuration of type ‘http’ of item ‘TrackName’ could not be parsed correctly.

org.eclipse.smarthome.model.item.BindingConfigParseException: bindingConfig ‘http://192.168.1.8:5050/current:JSONPATH($.song.title)’ doesn’t represent a valid in-binding-configuration. A valid configuration is matched by the RegExp ‘(.?)({.})?:(?!//)(\d*):(.*)’’

transformation-jsonpath - 2.5.0.M5 installed

Did you read my full post?

Anyway, the error is telling you that your http binding configuration string is incorrect. " could not be parsed correctly." Looking at the binding docs it shows you need three fields separated by a :. You only have two. You are missing the refresh field telling the binding how often to poll that URL.

Sorry, I thought it only affects REGEX
: 1000: in the examples, I thought it was a port like mine 5050
thanks!

I cannot stress enough how important it is to read the docs in detail and with careful attention, particularly when something is not working as expected. openHAB and home automation is really complicated stuff and the tiniest detail can completely break it.

The syntax for the HTTP binding configuration string is given below.

Receive repeated updates from a URL (“in” binding):

http="<[<url>:<refreshintervalinmilliseconds>:<transformationrule>]"