HTTP Binding things ... help me please

Hi everyone I am running into the OH 3.0 configuration
In my OH 1.8 system I have the following parameters:

File config
http:sma-inverter-cache.url=http://192.168.1.168/home.htm
http:sma-inverter-cache.updateInterval=60000

File Items
Number PotenzaFV “Pot. Ist. Prodotta [%.0f W]” (PotenzaFV_Chart) { http="<[sma-inverter-cache:30000:REGEX(.<td id=“Power” class=“tdcol1”>.?(\d*)..)]" }

File Sitemap
Text item=PotenzaFV label=“Pot. Fotovoltaico [%.0f W]” icon=“inverter”

I don’t understand how to set things up in OH 3.0
Bye thank you

Add a thing, put the URL from the file-cache as baseURL. Add a number channel, add the regex as stateTransformation. Link an item to the Channel. Done.

I am not a programmer, Can you help me with examples.? Thanks

You can click everything in the UI, no need to program anything.

Is the regex all this string?

REGEX (. < Td id = “Power” class = “tdcol1”>. ? (\ D *) )]

The part between REGEX( and the final ) is the regular expression, so it’s .<td id=“Power” class=“tdcol1”>.?(\d*)... You need to copy that and put REGEX: followed by the regular expression in the “State Transformation” input field: REGEX:.<td id=“Power” class=“tdcol1”>.?(\d*)...

While that may work, I doubt the regular expression is what you really want. Could it be that some characters are missing from your original configuration?

Thank you very much … As soon as I can I try …

hi, thank you for your time, i tried but it doesn’t work … where am i wrong?
here is the screenshot of the Things / Channel configuration
openHAB_http_Channel.pdf (93.7 KB)

remove the state extension.no need to use that

Thanks, but I have not solved …

You have to show the logs.

I have a question about caching in OH3. I use the http binding to query the API of the UK Environment Agency river level data. The readings are taken at the sites every 15 minutes but they are only published at that frequency when the flood risk is high. Fortunately, the API response includes a time stamp for the reading.

In OH1, I hit the API once and cached the result and then had two items, one for the reading and one for the timestamp. I want to optimise my use of the API so what it the best way to set this up?

At the, moment, I have the base URL as the thing and a channel for each reading I want to request, including the url extension. If I have two requests for the same extended url but with different jsonpath strings to get different parts of the response, will the binding query the API twice?

Thing http:url:riverstations "River Measuring Stations" [ baseURL="http://environment.data.gov.uk/flood-monitoring/id/measures/", refresh=900] {
   Channels:
      Type number : BuzzardLevel        [ stateExtension="E21187-level-stage-i-15_min-m", stateTransformation="JSONPATH:$.items.latestReading.value", mode="READONLY"  ]
      Type DateTime : BuzzardTime        [ stateExtension="E21187-level-stage-i-15_min-m", stateTransformation="JSONPATH:$.items.latestReading.dateTime", mode="READONLY"  ]
      Type number : ClipstoneLevel        [ stateExtension="E21987-level-stage-i-15_min-m", stateTransformation="JSONPATH:$.items.latestReading.value", mode="READONLY" ]
      Type number : ClipstoneTime        [ stateExtension="E21987-level-stage-i-15_min-m", stateTransformation="JSONPATH:$.items.latestReading.dateTime", mode="READONLY" ]
}

What about if I create a thing with the extended url and then create two channels with no url extension but with the two different jsonpath strings?

Thing http:url:riverBuzzard "River Measuring Stations" [ baseURL="http://environment.data.gov.uk/flood-monitoring/id/measures/E21187-level-stage-i-15_min-m", refresh=900] {
   Channels:
      Type number : Level        [ stateTransformation="JSONPATH:$.items.latestReading.value", mode="READONLY"  ]
      Type DateTime : Time        [ stateTransformation="JSONPATH:$.items.latestReading.dateTime", mode="READONLY"  ]
}

Thing http:url:riverClipstone "River Measuring Stations" [ baseURL="http://environment.data.gov.uk/flood-monitoring/id/measures/E21987-level-stage-i-15_min-m", refresh=900] {
      Type number : Level        [  stateTransformation="JSONPATH:$.items.latestReading.value", mode="READONLY" ]
      Type number : Time        [  stateTransformation="JSONPATH:$.items.latestReading.dateTime", mode="READONLY" ]
}

Either of these will work but I would prefer to be responsible and minimise the number of API calls.

Consider the thing as a site. So add a thing per site and use different channels (if needed with stateExtension€. Within a thing results are cached.

Thanks. I can make that work by using the second method. In fact I did a bit more research into jsonpath filtering so I can use the /measures?latest api call as recommended by the provider.

It sounds from what you are saying that even in the first case, the results would be cached and extracted by the channels in the thing. Does the binding retrieve the entire result for the base url and then work out what subset of the result would be delivered by appending the extension? If so, that is really clever and a great way to reduce the load on APIs.