Comment intégrer divers services météorologiques à pywws

Ce guide donne de brèves instructions sur comment utiliser pywws avec d’autres services météorologiques et logiciels. Il n’est pas exhaustive, et certains services (comme Twitter) sont couverts en détail ailleurs.

YoWindow

YoWindow est un widget météo qui peut afficher des données provenant d’une source internet ou de votre station météo. Pour afficher les données de votre station, pywws a besoin d’écrire dans un fichier local, en général toutes les 48 secondes lorsque de nouvelles données sont reçues. C’est facile à faire:

  1. Arrêter toute instance de pywws

  2. Copier le gabarit exemple yowindow.xml dans votre répertoire de gabarits text.

  3. Si ce n’est déjà fait, éditez le fichier weather.ini et configurez la clé local_files dans la section [paths] pour un répertoire approprié pour votre fichier yowindow.

  4. Ajoutez le modèle yowindow dans les tâches [live] de weather.ini. Mettre son paramètre à 'L' si le résultat est copié dans votre répertoire local au lieu d’être téléchargés sur un site ftp:

    [live]
    text = [('yowindow.xml', 'L')]
    
  5. Redémarrez l’enregistrement live de pywws.

Vous pouvez vérifier que le fichier est mis à jour toutes les 48 secondes en utilisant more ou cat pour afficher à l’écran.

Finallement, configurez yowindow pour l’utilisation de ce fichier. Voir http://yowindow.com/pws_setup.php pour les instructions pour ce faire.

Twitter

Voir Comment configurer pywws pour poster des messages sur Twitter pour les instructions détaillées.

Other « services »

The remaining weather service uploads are handled by the pywws.toservice module. See the module’s documentation for general configuration options. The following subsections give further information about some of the available services.

Citizen Weather Observer Program

Nouveau dans la version 14.02.dev1156.

  • Web site: http://www.wxqa.com/

  • Create account: http://www.wxqa.com/SIGN-UP.html

  • API: http://www.wxqa.com/faq.html

  • Example weather.ini section:

    [cwop]
    designator = EW9999
    latitude = 5130.06N
    longitude = 00008.52E
    template = default
    
    [logged]
    services = ['cwop', 'underground']
    
    [live]
    services = ['cwop', 'underground_rf']
    

    or, for radio hams:

    [cwop]
    designator = G4XXX
    passcode = xxxxxx
    latitude = 5130.06N
    longitude = 00008.52E
    template = default
    
    [logged]
    services = ['cwop_ham', 'underground']
    
    [live]
    services = ['cwop_ham', 'underground_rf']
    

Note that the latitude and longitude must be in « LORAN » format and leading zeros are required. See question 3 in the CWOP FAQ for more information.

Licensed radio hams use their callsign as the designator and need a passcode. They should use the service name cwop_ham instead of cwop when running pywws.toservice directly and in the weather.ini services entries. (The same [cwop] config section is used for both.)

CWOP uploads are rate-limited by pywws, so you can safely add it to both the [live] and [logged] sections in weather.ini.

The CWOP/APRS uploader is based on code by Marco Trevisan <mail@3v1n0.net>.

MQTT

Nouveau dans la version 14.12.0.dev1260.

MQTT is a « message broker » system, typically running on localhost or another computer in your home network. Use of MQTT with pywws requires an additional library. See Dependencies - MQTT for details.

  • MQTT: http://mqtt.org/

  • Mosquitto (a lightweight broker): http://mosquitto.org/

  • Example weather.ini section:

    [mqtt]
    topic = /weather/pywws
    hostname = localhost
    port = 1883
    client_id = pywws
    retain = True
    auth = False
    user = unknown
    password = unknown
    template = default
    multi_topic = False
    
    [logged]
    services = ['mqtt', 'underground']
    

pywws will publish a JSON string of the data specified in the mqtt_template_1080.txt file. This data will be published to the broker running on hostname, with the port number specified. (An IP address can be used instead of a host name.) client_id is a note of who published the data to the topic. topic can be any string value, this needs to be the topic that a subscriber is aware of.

retain is a boolean and should be set to True or False (or left at the default unknown). If set to True this will flag the message sent to the broker to be retained. Otherwise the broker discards the message if no client is subscribing to this topic. This allows clients to get an immediate response when they subscribe to a topic, without having to wait until the next message is published.

auth, user and password can be used for MQTT authentication.

multi_topic is a boolean and should be set to True or False. If set to True pywws will also publish all the data each as separate subtopics of the configured topic; i.e., with the topic set to /weather/pywws pywws will also publish the outside temperature to /weather/pywws/temp_out and the inside temperature to /weather/pywws/temp_in.

If these aren’t obvious to you it’s worth doing a bit of reading around MQTT. It’s a great lightweight messaging system from IBM, recently made more popular when Facebook published information on their use of it.

This has been tested with the Mosquitto Open Source MQTT broker, running on a Raspberry Pi (Raspian OS). TLS (mqtt data encryption) is not yet implemented.

Thanks to Matt Thompson for writing the MQTT code and to Robin Kearney for adding the retain and auth options.

UK Met Office

Open Weather Map

When choosing a user name you should avoid spaces (and probably non-ascii characters as well). Having a space in your user name causes strange « internal server error » responses from the server.

The default behaviour is to use your user name to identify the weather station. However, it’s possible for a user to have more than one weather station, so there is an optional name parameter in the API that can be used to identify the station. This appears as id in weather.ini. Make sure you choose a name that is not already in use.

PWS Weather

temperatur.nu

  • Web site: http://www.temperatur.nu/

  • Example weather.ini section:

    [temperaturnu]
    hash = ???
    template = default
    
    [logged]
    services = ['temperaturnu', 'underground']
    

You receive the hash value from the temperatur.nu admins during sign up. It looks like « d3b07384d113edec49eaa6238ad5ff00 ».

Weather Underground

Weather Underground « RapidFire » updates

Weather Underground a une seconde URL de téléversement pour les mises à jour en temps réel à un interval d’aussi peu que 2.5 secondes. Si vous exécutez pywws en mode “live logging” (voir Comment configurer le mode “live” avec pywws) vous pouvez l’utiliser pour envoyez des mises à jour aux 48 secondes, en ajoutant “underground_rf” à la section des tâches [live] du fichier weather.ini:

[underground]
station = ABCDEFGH1
password = xxxxxxx
template = default

[live]
services = ['underground_rf']

[logged]
services = ['underground', 'metoffice']

Make sure you still have an “underground” service in [logged] or [hourly]. This will ensure that “catchup” records are sent to fill in any gaps if your station goes offline for some reason.

wetter.com

Custom Request Headers

The pywws.toservice module does support the injection of one or more custom request headers for special cases where you want to integrate with a service that, for example, requires you to pass an authentication key header along with each request, such as x-api-key.

These headers can be added to your a_service.ini file in the format of key value pairs:

[config]
url         = https://my-aws-api-gw.execute-api.eu-west-1.amazonaws.com/test/station
catchup             = 100
interval    = 0
use get             = True
result              = []
auth_type   = None
http_headers        = [('x-api-key', 'my-api-key'), ('x-some-header', 'value')]

Commentaires et questions? SVP, abonnez-vous à la liste pywws http://groups.google.com/group/pywws et faites-vous entendre.