Plasma Weather widget: code template available to add your favorite weather data provider

Quick recap

Plasma 5.6 has finally seen the return of the Plasma Add-ons Weather widget, which had been missing the port from Plasma4.
Next, the Weather widget does not talk to any weather data providers directly, instead it talks to a weather dataengine (currently part of the Plasma Workspace module), to query for any weather stations matching the entered location search string when configuring the widget and to subscribe to the data feed for a given weather station from a given weather data provider.
That weather dataengine itself again also does not talk directly to any weather data providers. Instead it relies on an extendable set of sub-dataengines, one per weather data provider. So-called “ion”s.

Currently there are only 3 ions part of Plasma: wetter.com (private company running wetter.com), envcan (Environment Canada, by Government of Canada), noaa (USA’s National Oceanic and Atmospheric Administration). That is not enough, right.

Get quickly started with a working template

Time to add an ion for your favourite weather data provider. An ion can be independently developed by everyone, no need to do this in the plasma-workspace module (though it would be great if your ion ends up there once it is working, so it can be shared more easily).

To allow you a quick start with your own ion development, for the next version of the Plasma, 5.7, a code template (in the kapptemplate format, as supported by KAppTemplate or KDevelop) has been added. So when installing the development packages for Plasma Workspace (e.g. “plasma5-workspace-devel”), there should be also a “Plasma Weather Ion Dataengine” code template available, in the “KDE/Plasma Dataengine” folder.

Until Plasma 5.7 is released, download a snapshot of the ion code template. This snapshot also works with Plasma 5.6. You will need to have the development packages for Plasma Workspace installed, so the “plasma/weather/ion.h” header is available.
To use the template with KDevelop, select in the menu “Project”/”New From Template…” and click the button “Load Template From File” to add the template to the list. Then select the template and follow the dialog.
To use it with KAppTemplate, you need to manually install the file in “/usr/share/kdevappwizard/templates/” and (for KAppTemplate before Applications 16.04) also add a dummy PNG file to “/usr/share/kdevappwizard/template_previews/“, with the same base name as the template, “ion-dataengine.png“.
If the template does not work for you (please tell in the comments if), download this sample ion zip file, made from the template and the name “trueweather”, and start from that.

Follow the “README” in the sources and learn how to build, install and test your ion dataengine, e.g. how to query it via the Weather dataengine with the Plasma Engine Explorer:
trueweather ion dataengine in Plasma Engine Explorer

Learn more details about the Plasma Weather dataengine system in the last blog post.

Do not hesitate to ask for help on the #plasma irc channel and the plasma-devel mailinglist.