-
Notifications
You must be signed in to change notification settings - Fork 4
OpenWeather (English)
OpenWeather is an UK based company that provides weather data based on calculations for every point on earth. Despite how they call themselves, their services are not entirely for free. There is a rate limit for the current weather data if you don't pay (which will not be exceeded by this extension). To get the forecast you need a separate subscription, which involves a per-download fee and some free downloads. For maps you have to pay always.
weewx-DWD supports retrieving actual weather data from OpenWeather by their API. It includes additional observation types to the archive record. The observation types are named like the standard observation types of core WeeWX, but prepended by a configurable prefix. You can retrieve data for more than one location in parallel.
Then you can download forecasts by their "one call API" and process them.
Their maps you can download using the [[download]]
feature. You need a subscription with OpenWeather for that.
The configuration is simple. Specify latitude and longitude and the language, the text messages should be provided in. You need an API key which you get from OpenWeather for free. The configuration section in weewx.conf could look like this:
[WeatherServices]
[[current]]
[[[FichtelbergOWM]]]
provider = OpenWeather
station = Fichtelberg
latitude = 50.4283
longitude = 12.9536
lang = 'en'
prefix = 'xyz'
api_key = 'API key that you got from OpenWeather'
This would retrieve current weather data for mount Fichtelberg in Saxony. You can specify any other location around the world.
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. $current.xyzIcon.raw
provides an icon file name, and $current.xyzIcontitle.raw
a text message describing the current weather.
As OpenWeather does not provide dewpoint, it is calculated within weewx-DWD using the WeeWX formula.
Observation types (replace prefix
by the prefix you set in configuration):
-
prefixDateTime
: issuing timestamp -
prefixPressure
: ground level pressure -
prefixBarometer
: sea-level pressure -
prefixOutTemp
: air temperature -
prefixOutHumidity
: relative humidity -
prefixDewpoint
: dewpoint (not provided by OpenWeather but calculated by this extension) -
prefixAppTemp
: feels-like temperature -
prefixMinTemp
: minimum temperature (I do not really understand what that is for a single timestamp.) -
prefixMaxTemp
: maximum temperature -
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 the specified language -
prefixLongitude
: longitude of the location -
prefixLatitude
: latitude of the location -
prefixSunrise
: sunrise time at the specified location -
prefixSunset
: sunset time at the specified location -
prefixUtcoffset
: UTC offset valid at the specified location at the given timestamp
WeeWX uses a constant archive interval, but OpenWeather provides their data with a varying interval. Therefore, weewx-DWD stores the data it got from OpenWeather to a separate database. This database can be made available to WeeWX by configuring an appropriate binding.
I see no use in putting downloaded data into LOOP packets here, as their data is updated at most once per 5 minutes.
If your station is mounted on a vehicle and its location is available in WeeWX by observation types called latitude
and longitude
, you can specify station = mobile
, and data is always retrieved for the current location of the station as provided by the observation types latitude
and longitude
.
You need a special subscription to get forecasts from OpenWeather. Consult their website for details.
For WeeWX packet installation:
dwd-mosmix --weewx --openweather=API_KEY --lang=LANGUAGE OUTPUTOPTIONS LATITUDE,LONGITUDE
For WeeWX pip installation:
dwd-mosmix --config=/path/to/your/weewx.conf --lang=LANGUAGE --openweather=API_KEY OUTPUTOPTIONS LATITUDE,LONGITUDE
OUTPUTOPTIONS
can be any combination of the following options:
-
--html --daily --hourly
: create HTML include files containing the weather forecast as a table -
--database
: create a database file containing the forecast data for displaying diagrams -
--belchertown
: create a Belchertown formatforecast.json
file
Layout options if used together with --html
:
-
--orientation
: orientation of the forecast table horizontal (H
), vertical (V
) or both (H,V
) (optional, defaultH,V
) -
--icon-set
: icon set to use for weather symbols, possible valuesbelchertown
(default),dwd
,aeris
,svg
(optional) -
--hide-placemark
: if set, do not put the location name above the table (optional) -
--hours=COUNT
: if used together with--hourly
amount of hours to include in the forecast, from now on (optional, default 11) -
--us
: if set, use U.S. units instead of metric units (optional)
Weekday names and compass directions are available in English (en
), german (de
), french (fr
), czech (cz
), polish (pl
), italian (it
) and dutch (nl
).
Use dwd-mosmix --help
for a complete list of options.
To download the forecast automatically put the call to dwd-mosmix
into /etc/crontab
.
Besides using command line parameters it is possible to put options into weewx.conf
. One option is required: the setting of the icon path. Other options are optional.
[WeatherServices]
[[forecast]]
# location of the icons on the web server
icons = '../images'
# which icon set to use: belchertown, dwd, aeris
icon_set = belchertown
# which orientation(s) shall be created in HTML?
orientation = h,v
# show observation type icons in HTML
#show_obs_symbols = True # optional
# show observation type description in HTML
#show_obs_description = False # optional
# show place name above the forecast table in HTML
#show_placemark = True # optional
[[[OpenWeather-LATITUDE-LONGITUDE]]]
provider = OpenWeather
# which observations to include in forecast table (optional)
observations_daily = ww,TX,TN,heatindex,FFavg,DDavg,RR1c,Rd10,PPPPavg,Neffavg,Rad1hsum
-
pre-formatted forecast table:
This will be created if you use the option
--html
.daily forecast:
#include raw "SUBDIRECTORY/forecast-openweather-LATITUDE-LONGITUDE.inc"
hourly forecast:
#include raw "SUBDIRECTORY/forecast-openweather-LATITUDE-LONGITUDE-hourly.inc"
Example:
horizontal, U.S. units vertical, U.S. units horizontal, metric units vertical, metric units To style the table you can use additional CSS definitions like this:
.dwdforecasttable { line-height: 1.0; } .dwdforecasttable td { text-align: center; padding-left: 3px; padding-right: 3px; line-height: 1.2; } .dwdforecasttable .icons td { padding-top: 5px; padding-bottom: 0px; } .dwdforecasttable .topdist td { padding-top: 5px; } .light .dwdforecasttable td.weekend { background-color: #ffe; } .dark .dwdforecasttable td.weekend { background-color: #333; } /* scrollbar for 48-hour hourly forecast */ .dwdforecast-horizontal.dwdforecast-hourly48 { /* prevent vertical scrollbar */ padding: 5px; /* switch on horizontal scrollbar */ overflow-x: scroll; }
If there is a
custom.css
file, put them there. Otherwise look for the place where your skin wants them to be. -
diagrams and self-designed layouts:
This will be created if you use the option
--database
.Configure a binding and use it like every binding.
[DataBindings] ... [[openweather_binding]] database = openweather_sqlite table_name = forecast manager = weewx.manager.Manager schema = schemas.dwd.schema ... [Databases] ... [[openweather_sqlite]] database_name = "dwd-forecast-openwether-LATITUDE-LONGITUDE.sdb" database_type = SQLite ...
Observation types in forecast:
-
outTemp
: air temperature 2m above the ground -
dewpoint
: dewpoint 2m above the ground -
windchill
: windchill temperature (calculated out ofoutTemp
andwindSpeed
) -
heatindex
: heat index (calculated out ofoutTemp
anddewpoint
) -
outHumidity
: relative humidity -
windDir
: wind direction -
windSpeed
: wind speed -
windGust
: wind gust speed -
pop
: propability of precipitation -
cloudcover
: cloud cover -
barometer
: barometer -
rain
: amount of rain during the last hour
Example configuration for Belchertown skin within
graphs.conf
:[[forecast]] tooltip_date_format = "dddd LLL" gapsize = 3600 # 1 hour in seconds credits = "© OpenWeather" data_binding = openweather_binding time_length = all [[[outTemp]]] [[[dewpoint]]]
Example configuration within
skin.conf
:[ImageGenerator] ... [[day_images]] ... [[[forecast]]] data_binding = openweather_binding line_gap_fraction = 0.04 time_length = 950400 x_label_format = %d.%m. [[[[outTemp]]]] [[[[dewpoint]]]]
-
[WeatherServices]
path = '/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
[[download]]
[[[example map]]]
url = 'https://maps.openweathermap.org/maps/...'
file = '...'