Skip to content

General Download Interface (English)

roe-dl edited this page Oct 28, 2024 · 2 revisions

What is the general download interface?

With the general download interface you can download files from every provider who offers an API. There is no restriction to specific institutions. Nevertheless, special options are available for some providers to make configuration easier.

Using the general download interface with WeeWX

You can download files to process them further during skin creation. It depends on the provider whether you have to register with them or do other things in order to use their API before.

Configuration

The setup is located in section [WeatherServices], sub-section [download]. There you can set up as many download as you wish.

[WeatherServices]
    # path to the directory to save the files there
    path='/etc/weewx/skins/SKINNAME/SUBDIRECTORY'
    ...
    [[download]]
        # general download interface to download maps and forecasts and
        # other files
        [[[Download1]]]
            # what to download
            url = "https://www.example.com/pfad/datei"
            # file name to save to
            file = "filename.ext"
            # what encoding the original file is in
            # optional
            #from_encoding = iso8859-1
            # what encoding is to used to save the file
            # optional
            #to_encoding = html_entities
            # authentication (optional)
            #auth_method = basic # or digest
            #username = replace_me
            #password = replace_me
        [[[Download2]]]
            ...

The following keys can be used:

  • url: complete URL to retrieve data from (mandatory)
  • file: name of the file on disk
  • from_encoding: in case of text data, the encoding the data is provided in (optional, default iso8859-1)
  • to_encoding: in case of text data, the encoding the data are to be converted to (optional, default html_entities)
  • auth_method: authentication method, if any, optional, values basic or digest
  • username: user name, if any, optional
  • password: password, if any, optional

What happens

The files are downloaded, converted (if required) and saved to the directory specified in path. This happens right before the end of the archive interval. So the files are available when the report generation starts.

Including in skins

How to include the downloaded files into skins depends on their type.

Text files:

#include raw "SUBDIRECTORY/filename.ext"

Image files:

<img src="$relative_url/SUBDIRECTORY/filename.ext" ... />

Special interfaces

There are special configuration options for several protocols and providers. You can use them for easier configuration.

Clone this wiki locally