[SOLVED] HTTPbinding - I dont get it running


I tried it, I read tons of pages every describing it in a different way and I don
T understand it.

I want to do following:
From this webpage I try to read out the value from this line: Letzter Messwert vom 14.01.18 09:00 Uhr: 94 cm

The intention is to get the date and the Value.

It would be great if someon could help me and provide the steps I need to do.
I’m so confused with all this descriptions I found, looks like there is no way out for me.

I use OpenHab2

What are the entries for:
default.sitemap (display the value)
and maybe I have overseen something.

Please help!

So, the interesting line at the website would be

<span style="color:black">Letzter Messwert vom <b>14.01.18 15:30</b> Uhr: <b>94</b> cm</span>

You have to get your info through REGEX, the date part would be
REGEX(.*Letzter Messwert vom <b>(.*)</b> Uhr.*)
and the value would be
REGEX(.*Letzter Messwert.*Uhr: <b>(.*)</b> cm.*)
You need at least two items for this values:

String ffbLevelDate "Erfasst um [%s]" {http="<[http://www.hnd.bayern.de/pegel/donau_bis_kelheim/fuerstenfeldbruck-16605006:900000:REGEX(.*Letzter Messwert vom <b>(.*)</b> Uhr.*)]"}
Number ffbLevelValue "Pegel [%d cm]" {http="<[http://www.hnd.bayern.de/pegel/donau_bis_kelheim/fuerstenfeldbruck-16605006:900000:REGEX(.*Letzter Messwert.*Uhr: <b>(.*)</b> cm.*)]"}

Please be aware that the Date Item is of type String. This is due to the fact, that the given date is not in the correct form for openHAB DateTime Item. If you need a real date, you will have to add an unbound item and a rule to transform date date to the correct form.

These items will only update 4 times an hour, as the website does only 4 measurements an hour. When testing you can reduce 900000 to 60000.

1 Like

Thank you Udo,
your example works perfect.
I thought I have to use the http.cfg file to define the Website I wanna read out.
I think this was casuing the trouble.

Nevertheless it’s a cool feature I was looking for.
Now I will continue to read out other values from other websites.




You can use the http.cfg file to configure a http cache. The idea is, if, for example, you got a page with detailed weather information, you may have dozens of values to read. this may cause an unnecessary impact of http requests, especially if you want to update your items frequently. So instead of downloading the same page over and over again, openHAB will read the page to a http cache “store” and then read the items from this store.

In fact, you could do the requests for the river level the same way, but as the page is small, I was lazy :wink:

You could define the cache like this:

# cache for river level Donau bis Kelkheim / Fürstenfeldbruck.
# Update every 900,000 Milli Seconds


and then use the cache to get the values:

String ffbLevelDate "Erfasst um [%s]" {http="<[riverlevel:60000:REGEX(.*Letzter Messwert vom <b>(.*)</b> Uhr.*)]"}
Number ffbLevelValue "Pegel [%d cm]" {http="<[riverlevel:60000:REGEX(.*Letzter Messwert.*Uhr: <b>(.*)</b> cm.*)]"}

You can use as many caches as you want, but of course it will need memory for each web page to cache.