Jump to content
jason0x43

Weather workflow

Recommended Posts

daily.png

 

I wrote a weather forecaster workflow that displays forecasts from Dark Sky or the Weather Underground. This is actually the second iteration; my first was loosely based on David Ferguson's weather workflow, but written in Python. This version is a complete rewrite in Go.

 

The source, along with installation and setup instructions, is available at it at https://github.com/jason0x43/alfred-weather.The most current release can be found at https://github.com/jason0x43/alfred-weather/releases.

 

Version history:

 

2016-12-18: 1.0.0

2017-05-03: 1.3.0

2018-11-08: 1.5.0

Edited by jason0x43
Update for new version of the workflow

Share this post


Link to post

I wrote a simple weather forecaster workflow that displays forecasts from the Weather Underground. It's based on David Ferguson's workflow, but written in Python and with a something different usage model.

 

You'll need to register for an API key with Weather Underground to use the workflow (don't worry, it's free). I'd include one by default, but free keys are pretty limited in terms of how many requests they can make over a given period of time.

 

The source, along with installation and setup instructions, is available at it at https://github.com/jason0x43/jc-weather. You can download a prepackaged version of the workflow here, which includes everything the workflow needs to run, along with a few icon sets.

 

Qg71xWm.png

 

I would like to sign up for the api, but does it have anything substantially different than Ferguson's?

Share this post


Link to post

I wrote a simple weather forecaster workflow that displays forecasts from the Weather Underground. It's based on David Ferguson's workflow, but written in Python and with a something different usage model.

 

You'll need to register for an API key with Weather Underground to use the workflow (don't worry, it's free). I'd include one by default, but free keys are pretty limited in terms of how many requests they can make over a given period of time.

 

The source, along with installation and setup instructions, is available at it at https://github.com/jason0x43/jc-weather. You can download a prepackaged version of the workflow here, which includes everything the workflow needs to run, along with a few icon sets.

 

Qg71xWm.png

 

Did you get your own API key for this or did you reuse mine?

Share this post


Link to post

I would like to sign up for the api, but does it have anything substantially different than Ferguson's?

 

The main differences between the two are on the backend (mine's written in Python, David's is in PHP) and in the command system. I have single 'weather' command rather than separate 'conditions' and 'forecast' commands, and all my options are grouped under a 'wset' command. In the end, though, both are pulling down weather data from Weather Underground, and the displayed information looks pretty similar.

Share this post


Link to post

Did you get your own API key for this or did you reuse mine?

 

I got my own key, and the workflow requires users to get their own as well. If you have some kind of super-account with Weather Underground I'd be happy to just bundle yours, though. :)

Share this post


Link to post

I got my own key, and the workflow requires users to get their own as well. If you have some kind of super-account with Weather Underground I'd be happy to just bundle yours, though. :)

 

I don't and I'm running out of raindrops for my account as well so I'm going to migrate to forecast.io as a weather source soon

Share this post


Link to post

I don't and I'm running out of raindrops for my account as well so I'm going to migrate to forecast.io as a weather source soon

 

I was just doing that myself (at least, adding it as an option). Their API is quite a bit cheaper than Wundergrounds, although it will still probably be pretty easy to hit that 1000-request-per-day limit if you get popular.

Share this post


Link to post

After using wset to set either a forecast.io or weather underground API key the workflow returns the following error:

 

{u'type': u'keynotfound': u'description': u'this key does not exist'}

Share this post


Link to post

After using wset to set either a forecast.io or weather underground API key the workflow returns the following error:

 

{u'type': u'keynotfound': u'description': u'this key does not exist'}

 

That's actually an error from the Weather Underground that they send back when your API key is incorrect. One thing to keep in mind is that you have to choose the service first, then set the key, because `wset key` sets the key for the current service (wunderground by default). I should probably make specific commands to set the key for forecast.io or wunderground, or maybe look at the key format or something.

Share this post


Link to post

I just posted a new version--this one ties the key specification to the service selection, so there shouldn't be any more problems with key vs. service.

Share this post


Link to post

New version up. The workflow will now display weather alerts. You can action an alert to be taken to a details page (this only works in the US for Weather Underground).

 

There's also a new command to set the format for displaying timestamps.

Share this post


Link to post

So I need an api at wunderground to set the location? 

 

I installed using forecast api, but can't set location. look through console shows this error

 

Alfred 2[238]: [ERROR] Script XML Parsing, item missing UID attribute

Share this post


Link to post

So I need an api at wunderground to set the location? 

 

I installed using forecast api, but can't set location. look through console shows this error

 

Alfred 2[238]: [ERROR] Script XML Parsing, item missing UID attribute

You do need an API key from either Weather Underground or forecast.io, but only to get the actual weather data. From your error message I'm guessing you haven't upgraded to Alfred 2.0.3 yet (it was just released in the last couple of days). I made a change to the workflow to take advantage of some new stuff in 2.0.3. It may have been a bit premature.

Share this post


Link to post

Yup that did it. Once I upgraded to that, it worked fine. I wasn't aware of the issue as I leave my mac on all the time and I think the update checker only notifies on start up.

Share this post


Link to post

New version. There is now a "Get key" on the "Enter your API key" dialog that pops up when selecting your weather service. I thought this was a bit easier than having a separate "getkey" command; it's more where you need it than floating around on its own. You can also set a custom time format now with the "format" command.

Share this post


Link to post

Another update. The workflow is now timezone-aware. This is used to 1) fix a bug where you could get weird output if you were looking at the weather across the international date line, and 2) show the local time for your target location.

Share this post


Link to post

Well, I updated to the new version, now it doesn't work anymore. I get the result "key.wund"

 

Hmmm...I've tried this with several older versions of my settings file but I can't reproduce this error. Could you open up your settings file (at /Users/<you>/Library/Application Support/Alfred 2/Workflow Data/jc-weather/settings.json) and either post it or see if it looks like this? It's OK if you have additional settings, like key.fio, but you should have at least the ones below.

 

  {

    "key.wund": "<your key>",

    "service": "wund",

    "icons": "grzanka",

    "days": 3,

    "time_format": "%A, %B %d, %Y %I:%M%p",

    "version": 3,

    "location": {

      "latitude": 34.0522342,
      "timezone": "America/Los_Angeles",
      "longitude": -118.2436849,
      "name": "Los Angeles, California",

      "short_name": "Los Angeles"

    },

    "units": "si"

  }

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×