Hi,
I am now already failing for hours to get this html-code scraped to just show the value of the water level.
This is the original website
https://www.steb-koeln.de/
And this is the related html-code:
<div class="upper">
<strong id="water-level">2,59 m</strong>
<span>Kölner Pegel</span>
<time datetime="">6.9.2021 20:15</time>
</div>
This is what I got so far:
- platform: scrape
resource: https://www.steb-koeln.de
name: "water-level"
select: ".water-level"
unit_of_measurement: "m"
scan_interval: 300
I just don’t know, How I can just retrieve the value for “water-level”, which is 2,59m in this example.
Hope that anybody can help.
Sorry. This is all new to me and very complicated.
Thanks. in advance.
Best regards.
Till
That’s how it may look like, but the raw HTML code does not contain the actual value and looks like this instead:
<div class="upper">
<strong id="water-level"><img src="/Intern/resources/img/Ajax-Loader.gif" alt="loader" /></strong>
<span>Kölner Pegel</span>
<time datetime=""> </time>
</div>
However, the good news is that the actual data you are looking for is available in JSON format under this URL: https://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/KÖLN/W/currentmeasurement.json
You can use a rest
sensor to fetch and extract the value. Try this:
sensor:
- platform: rest
resource: https://www.pegelonline.wsv.de/webservices/rest-api/v2/stations/K%C3%96LN/W/currentmeasurement.json
value_template: "{{ value_json.value / 100 | float }}"
name: "water-level"
unit_of_measurement: "m"
That was it. Thanks. Danke. Worked out. Hat geklappt
1 Like
What if we make an integration for this