Can someone help me creating temperature sensor from FMI weather station
This is the address for nearest official finnish weather station from my home:
https://opendata.fmi.fi/wfs?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::simple&fmisid=101675&starttime=2024-11-17T13:41:00Z¶meters=temperature&
It updates every 10 minutes, so i have to load this in every 10 minutes changing time and date parameter.
It return this:
<wfs:FeatureCollection xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:gml="http://www.opengis.net/gml/3.2" xmlns:BsWfs="http://xml.fmi.fi/schema/wfs/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" timeStamp="2024-11-17T13:52:53Z" numberReturned="1" numberMatched="1" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0/wfs.xsd http://xml.fmi.fi/schema/wfs/2.0 https://xml.fmi.fi/schema/wfs/2.0/fmi_wfs_simplefeature.xsd">
<script id="youtube-hd-fjdmkanbdloodhegphphhklnjfngoffa">var ythdlog = () => {};;var ythderror = () => {};</script>
<wfs:member>
<BsWfs:BsWfsElement gml:id="BsWfsElement.1.1.1">
<BsWfs:Location>
<gml:Point gml:id="BsWfsElementP.1.1.1" srsDimension="2" srsName="http://www.opengis.net/def/crs/EPSG/0/4258">
<gml:pos>63.83882 23.09715 </gml:pos>
</gml:Point>
</BsWfs:Location>
<BsWfs:Time>2024-11-17T13:50:00Z</BsWfs:Time>
<BsWfs:ParameterName>temperature</BsWfs:ParameterName>
<BsWfs:ParameterValue>0.2</BsWfs:ParameterValue>
</BsWfs:BsWfsElement>
</wfs:member>
</wfs:FeatureCollection>
What should i do to create a temperaturesensor from that?
I think your URL was truncated, because clicking on it does not return XML. According to the RESTful sensor documentation, if the endpoint returns an appropriate content type header (I can’t tell because the URL doesn’t seem correct), then the XML will be converted to JSON.
If it does have an appropriate header, then the resulting JSON would be:
{
"wfs:FeatureCollection": {
"@xmlns:wfs": "http://www.opengis.net/wfs/2.0",
"@xmlns:gml": "http://www.opengis.net/gml/3.2",
"@xmlns:BsWfs": "http://xml.fmi.fi/schema/wfs/2.0",
"@xmlns:xsi": "http://www.w3.org/2001/XMLSchema-instance",
"@timeStamp": "2024-11-17T13:52:53Z",
"@numberReturned": "1",
"@numberMatched": "1",
"@xsi:schemaLocation": "http://www.opengis.net/wfs/2.0 http://schemas.opengi s.net/wfs/2.0/wfs.xsd http://xml.fmi.fi/schema/wfs/2.0 https://xml.fmi.fi/schema /wfs/2.0/fmi_wfs_simplefeature.xsd",
"script": {
"@id": "youtube-hd-fjdmkanbdloodhegphphhklnjfngoffa",
"#text": "var ythdlog = () => {};;var ythderror = () => {};"
},
"wfs:member": {
"BsWfs:BsWfsElement": {
"@gml:id": "BsWfsElement.1.1.1",
"BsWfs:Location": {
"gml:Point": {
"@gml:id": "BsWfsElementP.1.1.1",
"@srsDimension": "2",
"@srsName": "http://www.opengis.net/def/crs/EPSG/0/4258",
"gml:pos": "63.83882 23.09715"
}
},
"BsWfs:Time": "2024-11-17T13:50:00Z",
"BsWfs:ParameterName": "temperature",
"BsWfs:ParameterValue": "0.2"
}
}
}
}
So I think you should be able to do:
rest:
- resource: "https://...the-url..."
- sensor:
- name: "FMI Temperature"
value_template: '{{ value_json["wfs:FeatureCollection"]["wfs:member"]["BsWfs:BsWfsElement"]["BsWfs:ParameterValue"] }}'
But I can’t test it to be sure.