Skip to content

VAISALA Xweather (formerly Aeris) (English)

roe-dl edited this page Nov 8, 2024 · 13 revisions

What is Xweather?

Xweather (formerly Aeris) is a weather service provided by the finnish company VAISALA. If you upload the readings of your weather station to PWSweather, you can get limited access to Xweather for free by the PWS contributor subscription.

Using Xweather API with WeeWX

weewx-DWD supports the API of Xweather.

Retrieving current observations of the nearest station

Configuration

[WeatherServices]
    path = "/etc/weewx/skin/SKINNAME/DIRECTORY"
    [[current]]
        ...
        [[[Xweather]]]
            prefix = xyz
            provider = Xweather
            model = observations/closest
            station = replace_me
            latitude = replace_me
            longitude = replace_me
            api_id = replace_me
            api_secret = replace_me

This would retrieve current weather data for the official weather station nearest to the location specified by latitude and longitude keys. api_id (client id) and api_secret (client secret) are mandatory. If you replace observation/closest with conditions you get interpolated weather values for the location you specified.

  • prefix: prefix for the observation type names
  • provider: here Xweather
  • model: endpoint and action to use, optional, default observations/closest. Set it to observations or conditions if you use the station key with a real ID, not one of the special values.
  • station: station ID, if any, optional, default the section name, special values:
    • here, thisstation: refers to the location of the weather station as defined in section [Station] of weewx.conf
    • mobile: mobile station, the actual location is defined by the $current.latitude and $current.longitude readings
    • none: no station
  • latitude: latitude, optional
  • longitude: longitude, optional
  • file: If this key is present, the received reply is saved. The file key sets the file name, the path key the directory.
  • api_id: client ID, mandatory
  • api_secrect: client secret, mandatory
  • [[[[parameters]]]]: if present, additional parameters for the URL. Each entry in this section defines one additional parameter.

Normally you will use either station or a latitude/longitude pair.

If you want to restrict the result to METAR stations, set filter = metar under [[[[parameters]]]]. For other filter conditions see the Xweather documentation.

Usage in skins

The prefix is set to xyz in this example. This means, if you want to display the temperature you would write $current.xyzOutTemp in the skin template.

Observation types (replace prefix with the prefix you set in configuration):

  • prefixDateTime: issuing timestamp
  • prefixPressure: ground level pressure
  • prefixBarometer: sea-level pressure
  • prefixAltimeter: altimeter pressure
  • prefixOutTemp: air temperature
  • prefixOutHumidity: relative humidity
  • prefixDewpoint: dewpoint
  • prefixAppTemp: feels-like temperature
  • prefixWindchill: windchill temperature
  • prefixHeadindex: heat index
  • prefixVisibility: visibility (up to 10 km)
  • prefixWindSpeed: wind speed
  • prefixWindDir: wind direction
  • prefixWindGust: wind gust speed
  • prefixCloudcover: cloud cover (percent)
  • prefixIcon: file name of the weather condition icon
  • prefixIcontitle: current weather condition as text in English
  • prefixLongitude: longitude of the station
  • prefixLatitude: latitude of the station
  • prefixAltitude: altitude of the station
  • prefixPlace: name of the station (string, use with .raw)
  • prefixSunrise: sunrise time at the specified station
  • prefixSunset: sunset time at the specified station
  • prefixAerisCodedWeatherPrimary: coded weather (string, use with .raw)
  • prefixAerisCodedWeather: coded weather (string, use with .raw)
  • prefixDirection: direction of the station from the location set in the configuration
  • prefixDistance: distance of the station from the location set in the configuration

Configuration examples

observations of the nearest official weather station to the location of your station as defined in the [Station] section of weewx.conf:

        [[[Near-My-Station]]]
            prefix = next
            provider = Xweather
            station = here
            api_id = replace_me
            api_secret = replace_me

observations of the nearest official weather station to 50.4283N 12.9536E (mount Fichtelberg):

        [[[Near-Fichtelberg]]]
            prefix = fichtelberg
            provider = Xweather
            latitude = 50.4283
            longitude = 12.9536
            api_id = replace_me
            api_secret = replace_me

observations of the nearest official weather station to the current location of a mobile station:

        [[[Near-Where-I-am]]]
            prefix = next
            provider = Xweather
            station = mobile
            api_id = replace_me
            api_secret = replace_me

observations of the airport weather station of the Dresden airport:

        [[[Dresden-Airport]]]
            prefix = drs
            provider = Xweather
            model = observations
            station = EDDC
            api_id = replace_me
            api_secret = replace_me

Retrieving a list of active tropical cyclones

Configuration

[WeatherServices]
    path = "/etc/weewx/skin/SKINNAME/DIRECTORY"
    ...
    [[download]]
        ...
        [[[Tropicalcyclones]]]
            provider = Xweather
            url = "https://data.api.xweather.com/tropicalcyclones?client_id=replace_me&client_secret=replace_me"
            file = tropicalcyclones.json

Usage in skins

This saves the data to the file /etc/weewx/skin/SKINNAME/DIRECTORY/tropicalcyclones.json in JSON format. It requires further processing, for example by JavaScript or in a CheetahGenerator template.

Here is an example that generates a table of the active cyclones in a CheetahGenerator template:

#from weewx.units import ValueHelper,ValueTuple
#import json
#set $file= open('/etc/weewx/skin/SKINNAME/DIRECTORY/tropicalcyclones.json','rt')
#set $cyclones=json.load($file)
$file.close()
#if $cyclones['success']
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Start time</th>
<th>Max. category</th>
<th>Max. wind speed</th>
<th>Min. pressure</th>
</tr>
#for $cyclone in $cyclones['response']
<tr>
<td>$cyclone['id']</td>
<td>$cyclone['profile']['name']</td>
<td>$ValueHelper(ValueTuple($cyclone['profile']['lifespan']['startTimestamp'],'unix_epoch','group_time'),formatter=$station.formatter)</td>
<td>$cyclone['profile']['maxStormCat']</td>
<td>$ValueHelper(ValueTuple($cyclone['profile']['windSpeed']['maxKPH'],'km_per_hour','group_speed'),formatter=$station.formatter)</td>
<td>$ValueHelper(ValueTuple($cyclone['profile']['pressure']['minMB'],'mbar','group_pressure'),formatter=$station.formatter)</td>
</tr>
#end for
</table>
#else
$cyclones['error']
#end if

There is much more information in the file than this examples shows. It shall only illustrate how to do it in general.

Retrieving a list of the last lightning strikes around the station

Configuration

[WeatherServices]
    path = "/etc/weewx/skin/SKINNAME/DIRECTORY"
    ...
    [[download]]
        ...
        [[[Lightning]]]
            provider = Xweather
            url = "https://data.api.xweather.com/lightning?p=32.6,-2.2&radius=40km&limit=10&client_id=replace_me&client_secret=replace_me"
            file = lightning.json

Replace 32.6,-2.2 with the location of your station. You can also alter the radius size and unit (for exampale mi for miles).

If you want to get the nearest lightning stroke as observation types in the archive record as well as a file for further processing, you can alternatively put the configuration into the [[current]] section:

[WeatherServices]
    path = "/etc/weewx/skin/SKINNAME/DIRECTORY"
    [[current]]
        ...
        [[[Lightning]]]
            prefix = lightning
            provider = Xweather
            model = lightning/closest
            latitude = 32.6
            longitude = -2.2
            api_id = replace_me
            api_secret = replace_me
            file = lightning.json
            [[[[parameters]]]]
                limit = 10
                radius = 40km

Usage in skins

This saves the data to the file /etc/weewx/skin/SKINNAME/DIRECTORY/lightning.json in JSON format. It requires further processing, for example by JavaScript or in a CheetahGenerator template.

Here is an example that generates a table of the last lightning strokes in a CheetahGenerator template:

#from weewx.units import ValueHelper,ValueTuple
#import json
#set $file= open('/etc/weewx/skin/SKINNAME/DIRECTORY/lightning.json','rt')
#set $lightnings=json.load($file)
$file.close()
#if $lightnings['success']
<table>
<tr>
<th>ID</th>
<th colspan="2">Location</th>
<th>Time</th>
<th>Age</th>
<th>Type</th>
<th>Max. current</th>
<th colspan="2">Direction</th>
<th>Distance</th>
</tr>
#for $lightning in $lightnings['response']
<tr>
<td>$lightning['id']</td>
<td>$lightning['loc']['lat']</td><td>$lightning['loc']['long']</td>
<td>$ValueHelper(ValueTuple($lightning['ob']['timestamp'],'unix_epoch','group_time'),formatter=$station.formatter)</td>
<td style="text-align:right">$ValueHelper(ValueTuple($lightning['ob']['age'],'second','group_deltatime'),formatter=$station.formatter)</td>
<td>$lightning['ob']['pulse']['type']</td>
<td style="text-align:right">$ValueHelper(ValueTuple($lightning['ob']['pulse']['peakamp'],'amp','group_amp'),formatter=$station.formatter)</td>
<td style="text-align:right">$ValueHelper(ValueTuple($lightning['relativeTo']['bearing'],'degree_compass','group_direction'),formatter=$station.formatter)</td>
<td>$lightning['relativeTo']['bearingENG']</td>
<td style="text-align:right">$ValueHelper(ValueTuple($lightning['relativeTo']['distanceKM'],'km','group_distance'),formatter=$station.formatter)</td>
</tr>
#end for
</table>
#else
$lightnings['error']
#end if

In case the configuration is in the [[current]] section, you can access the following observation types (if prefix is set to something other than lightning, replace lightning in the following list with the prefix you set):

  • lightningRecordSize: amount of items in the reply
  • lightningId: ID of the nearest lightning stroke
  • lightningLatitude, lightningLongitude: location of the nearest lightning stroke
  • lightningTimestamp: timestamp, when the lightning stroke occurred
  • lightningAge: how long ago the lightning stroke took place
  • lightningType: type of the lightning stroke (ic inter-cloud, cg cloud-to-ground)
  • lightningPeakAmplitude: peak amplitude of the lightning stroke
  • lightningSensors: how many sensors received the signal of the lightning stroke
  • lightningBearing: direction of the location of the lightning stroke from the configured position (for example the station location)
  • lightningDistance: distance of the location of the lightning stroke from the configured position (for example the station location)
  • lightningDateTime: timestamp when the record was received

Other data available through the Xweather API

You can use the general download interface to retrieve any data provided by the Xweather API. The configuration is similar to that for the tropical cyclones file above.

Radar picture

(example from Xweather documentation; not tested because my account is not sufficient for that)

Configuration

[WeatherServices]
    path = "/etc/weewx/skin/SKINNAME/DIRECTORY"
    ...
    [[download]]
        ...
        [[[Xweather-Radar]]]
            provider = Xweather
            url = https://maps.api.xweather.com/{client_id}_{client_secret}/flat,radar,admin/500x300/minneapolis,mn,5/current.png"
            file = "us_radar.png"

Usage in skins

<img src="$relative_url/DIRECTORY/us_radar.png" ... />

Links

Clone this wiki locally