Help with rest sensor (FMI weather stations)

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&parameters=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.

Hello!

As it happens I’m trying to achieve same kind of thing with rest.
My wfs request link is like this and returns beautiful xml for Hämeenlinna weather station:
https://opendata.fmi.fi/wfs/fin?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::timevaluepair&place=H%C3%A4meenlinna&parameters=t2m&timezone=Europe/Helsinki&timestep=30

I installed xml->json converter and did some cleaning and got a file like this:

{
   "wfs:FeatureCollection":{
      "wfs:member":{
         "omso:PointTimeSeriesObservation":{
            "om:featureOfInterest":{
               "sams:SF_SpatialSamplingFeature":{
                  "sam:sampledFeature":{
                     "target:LocationCollection":{
                        "target:member":{
                           "target:Location":{
                              "gml:identifier":{
                              },
                              "gml:name":[
                                 {
                                    "#text":"Hämeenlinna ""Katinen",
                                    "@codeSpace":"http://xml.fmi.fi/namespace/locationcode/name"
                                 },
                                 {
                                    "#text":"-16000125",
                                    "@codeSpace":"http://xml.fmi.fi/namespace/locationcode/geoid"
                                 },
                                 {
                                    "#text":"2754",
                                    "@codeSpace":"http://xml.fmi.fi/namespace/locationcode/wmo"
                                 }
                              ],
                              "target:region":{
                                 "#text":"Hämeenlinna",
                                 "@codeSpace":"http://xml.fmi.fi/namespace/location/region"
                              },
                              "target:representativePoint":{
                                 "@xlink:href":"#point-fmisid-101150-1-1-t2m"
                              }
                           }
                        }
                     }
                  },
                  "sams:shape":{
                     "gml:Point":{
                        "@gml:id":"point-fmisid-101150-1-1-t2m",
                        "@srsDimension":"2",
                        "@srsName":"http://www.opengis.net/def/crs/EPSG/0/4258",
                        "gml:name":"Hämeenlinna ""Katinen",
                        "gml:pos":"60.99920 ""24.49163"
                     }
                  }
               }
            },
            "om:observedProperty":{
               "@xlink:href":"http://opendata.fmi.fi/meta?observableProperty=observation&param=t2m&language=fin"
            },
            "om:parameter":{
               "om:NamedValue":{
                  "om:name":{
                     "@xlink:href":"https://inspire.ec.europa.eu/codeList/ProcessParameterValue/value/groundObservation/observationIntent"
                  },
                  "om:value":"atmosphere"
               }
            },
            "om:phenomenonTime":{
               "gml:TimePeriod":{
                  "@gml:id":"time1-1-1",
                  "gml:beginPosition":"2025-02-15T13:54:00Z",
                  "gml:endPosition":"2025-02-16T01:54:00Z"
               }
            },
            "om:procedure":{
               "@xlink:href":"http://xml.fmi.fi/inspire/process/opendata"
            },
            "om:result":{
               "wml2:MeasurementTimeseries":{
                  "@gml:id":"obs-obs-1-1-t2m",
                  "wml2:point":[
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T14:00:00Z",
                           "wml2:value":"-7.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T14:10:00Z",
                           "wml2:value":"-7.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T14:20:00Z",
                           "wml2:value":"-7.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T14:30:00Z",
                           "wml2:value":"-7.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T14:40:00Z",
                           "wml2:value":"-7.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T14:50:00Z",
                           "wml2:value":"-7.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T15:00:00Z",
                           "wml2:value":"-8.0"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T15:10:00Z",
                           "wml2:value":"-8.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T15:20:00Z",
                           "wml2:value":"-8.3"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T15:30:00Z",
                           "wml2:value":"-8.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T15:40:00Z",
                           "wml2:value":"-8.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T15:50:00Z",
                           "wml2:value":"-8.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T16:00:00Z",
                           "wml2:value":"-8.9"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T16:10:00Z",
                           "wml2:value":"-9.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T16:20:00Z",
                           "wml2:value":"-9.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T16:30:00Z",
                           "wml2:value":"-9.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T16:40:00Z",
                           "wml2:value":"-8.9"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T16:50:00Z",
                           "wml2:value":"-8.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T17:00:00Z",
                           "wml2:value":"-8.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T17:10:00Z",
                           "wml2:value":"-8.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T17:20:00Z",
                           "wml2:value":"-8.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T17:30:00Z",
                           "wml2:value":"-8.9"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T17:40:00Z",
                           "wml2:value":"-9.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T17:50:00Z",
                           "wml2:value":"-9.3"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T18:00:00Z",
                           "wml2:value":"-9.3"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T18:10:00Z",
                           "wml2:value":"-9.4"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T18:20:00Z",
                           "wml2:value":"-9.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T18:30:00Z",
                           "wml2:value":"-9.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T18:40:00Z",
                           "wml2:value":"-9.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T18:50:00Z",
                           "wml2:value":"-10.0"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T19:00:00Z",
                           "wml2:value":"-10.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T19:10:00Z",
                           "wml2:value":"-10.2"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T19:20:00Z",
                           "wml2:value":"-10.4"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T19:30:00Z",
                           "wml2:value":"-10.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T19:40:00Z",
                           "wml2:value":"-10.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T19:50:00Z",
                           "wml2:value":"-10.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T20:00:00Z",
                           "wml2:value":"-10.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T20:10:00Z",
                           "wml2:value":"-10.8"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T20:20:00Z",
                           "wml2:value":"-11.0"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T20:30:00Z",
                           "wml2:value":"-11.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T20:40:00Z",
                           "wml2:value":"-11.2"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T20:50:00Z",
                           "wml2:value":"-11.2"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T21:00:00Z",
                           "wml2:value":"-11.3"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T21:10:00Z",
                           "wml2:value":"-11.2"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T21:20:00Z",
                           "wml2:value":"-11.3"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T21:30:00Z",
                           "wml2:value":"-11.4"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T21:40:00Z",
                           "wml2:value":"-11.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T21:50:00Z",
                           "wml2:value":"-11.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T22:00:00Z",
                           "wml2:value":"-11.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T22:10:00Z",
                           "wml2:value":"-11.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T22:20:00Z",
                           "wml2:value":"-11.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T22:30:00Z",
                           "wml2:value":"-11.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T22:40:00Z",
                           "wml2:value":"-11.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T22:50:00Z",
                           "wml2:value":"-11.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T23:00:00Z",
                           "wml2:value":"-11.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T23:10:00Z",
                           "wml2:value":"-11.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T23:20:00Z",
                           "wml2:value":"-11.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T23:30:00Z",
                           "wml2:value":"-11.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T23:40:00Z",
                           "wml2:value":"-11.9"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-15T23:50:00Z",
                           "wml2:value":"-11.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T00:00:00Z",
                           "wml2:value":"-11.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T00:10:00Z",
                           "wml2:value":"-11.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T00:20:00Z",
                           "wml2:value":"-11.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T00:30:00Z",
                           "wml2:value":"-11.1"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T00:40:00Z",
                           "wml2:value":"-11.2"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T00:50:00Z",
                           "wml2:value":"-11.3"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T01:00:00Z",
                           "wml2:value":"-11.3"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T01:10:00Z",
                           "wml2:value":"-11.4"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T01:20:00Z",
                           "wml2:value":"-11.5"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T01:30:00Z",
                           "wml2:value":"-11.6"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T01:40:00Z",
                           "wml2:value":"-11.7"
                        }
                     },
                     {
                        "wml2:MeasurementTVP":{
                           "wml2:time":"2025-02-16T01:50:00Z",
                           "wml2:value":"-11.9"
                        }
                     }
                  ]
               }
            },
            "om:resultTime":{
               "gml:TimeInstant":{
                  "@gml:id":"time2-1-1",
                  "gml:timePosition":"2025-02-16T01:54:00Z"
               }
            }
         }
      }
   }
}

I would like to make a sensor out of the last (most recent) observation. This is what I tried so far:

sensor:
  - platform: rest
    resource: "https://opendata.fmi.fi/wfs/fin?service=WFS&version=2.0.0&request=getFeature&storedquery_id=fmi::observations::weather::timevaluepair&place=H%C3%A4meenlinna&parameters=t2m&timezone=Europe/Helsinki&timestep=30"
    name: FMI Temperature
    unique_id: fmi_temperature
    scan_interval: 600 # 10 minutes  
    value_template: '{{ value_json["wfs:FeatureCollection"]["wfs:member"]["omso:PointTimeSeriesObservation"]["om:featureOfInterest"]["om:result"]["wml2:MeasurementTimeseries"]["wml2:point"]["wml2:MeasurementTVP"]["wml2:value"] }}' 

New observation is made every 10 min so that’s why scan_interval is set to 600 sec. I managed to load as much as nothing with this…

If anyone else has played with this, any help would be appreciated :slight_smile:

Regards,
Juho