Anyone got a working sensor with this API: http://api.sehavniva.no/tideapi_en.html ?
this url: http://api.sehavniva.no/tideapi.php?lat=58.974339&lon=5.730121&fromtime=2019-06-27T00%3A00&totime=2019-06-28T00%3A00&datatype=tab&refcode=cd&place=&file=&lang=nn&interval=10&dst=0&tzone=&tide_request=locationdata
produces “high and low” data:
<tide>
<locationdata>
<location name="STAVANGER" code="SVG" latitude="58.974339" longitude="5.730121" delay="0" factor="1.00" obsname="STAVANGER" obscode="SVG" place="STAVANGER"/>
<reflevelcode>CD</reflevelcode>
<data type="prediction" unit="cm">
<waterlevel value="69.4" time="2019-06-27T04:51:00+01:00" flag="high"/>
<waterlevel value="45.4" time="2019-06-27T10:59:00+01:00" flag="low"/>
<waterlevel value="65.5" time="2019-06-27T17:41:00+01:00" flag="high"/>
<waterlevel value="49.2" time="2019-06-27T23:19:00+01:00" flag="low"/>
</data>
</locationdata>
</tide>
i want to scrape the waterlevel values into one or several sensors.
Before I start studying different “grep” commands, I would like to check if somebody aldready did this?
Did you make any progress on this?
You can scrape this xml with multiscrape:
multiscrape:
- resource: 'https://api.sehavniva.no/tideapi.php?lat=58.974339&lon=5.730121&fromtime=2019-06-27T00%3A00&totime=2019-06-28T00%3A00&datatype=tab&refcode=cd&place=&file=&lang=nn&interval=10&dst=0&tzone=&tide_request=locationdata'
sensor:
- name: latest tide
unique_id: latest_tide
select: 'tide:nth-child(1) > locationdata:nth-child(1) > data:nth-child(3) > waterlevel:nth-child(1)'
attribute: 'flag'
attributes:
- name: value
select: 'tide:nth-child(1) > locationdata:nth-child(1) > data:nth-child(3) > waterlevel:nth-child(1)'
attribute: 'value'
- name: time
select: 'tide:nth-child(1) > locationdata:nth-child(1) > data:nth-child(3) > waterlevel:nth-child(1)'
attribute: 'time'
I was looking to test xml support in multiscrape and this helped, thanks 
1 Like