Jump to content
Jb_Bryant

Dark Sky Workflow

Recommended Posts

Getting a chance to jump back into this thread after a busy week. First thing I'm noticing is that changes are floating around which aren't compatible with how the extension works in v2 of Alfred. I'm going to update my changes into the Github repo so we can be working off of the same updated code.

 

Dark Sky introduced their Forcast API but the Dark Sky API that this is running off still functions. I'll look into if Forcast.io can offer a bit better support but I want to leave the scope of this extension for just immediate weather checks, not full forecasts. I'll let David tackle that.

 

I'll poke around the code for a bit and post back with what I find with the case that not all three elements are being returned. Here's what I'm seeing right now in NY.

 

Screen%20Shot%202013-03-31%20at%2011.03.

Share this post


Link to post

I've created a branch that I'm working off for now. You can see it here: https://github.com/nickwynja/darksky-alfred/tree/v2

 

While I'm stabilizing things, I've made it clear in the workflow title and keyword that it's a dev build. The biggest change you'll see while I'm working on it is that all the settings and code is in `darksky.php` and all Alfred is doing is calling the script. This just makes it easier to work on. For now, if you want to play around with this, just change your $lon and $lat in the PHP file by going "Open workflow folder" and changing it in a text editor.

 

In the final version, you'll probably end up setting these in the Alfred prompt like in David's Weather workflow.

 

I did some more testing, and it appears the Next 24 Hour issue only occurs if daySummary returns clear.  If Dark Sky reports something other than clear for daySummary, it seems to work correctly.

 

I believe I squashed this bug. Your description of the issue was helpful, thanks.

 

Here's a current build with that issue fixed. I'm going to keep working on improving this and possibly migrate to the new API with a few other changes before I tag this the 2.0.

 

http://cl.ly/0l2P1s473s1B

Share this post


Link to post

Hey Nick!
 
Thanks for all your dedication -- I really appreciate it!  I made the necessary adjustments in the PHP, and here's what I get in central Texas:

 

1sxrar.jpg

 

Share this post


Link to post

I'm in the UK and I've been experimenting with UK Long / Lat.

 

I've tried both the PHP version as well as the original. No difference from my last post really.

 

I get nothing back, blank slots like this: http://cl.ly/Ny3H

 

Here's London's Long / Lat:

 

 

 

$lat = "51.5171";
$lon = "0.1062";
 
I've tried it with my API key and the default, no luck whatsoever. :(
 
I'd love it if anyone could tell me what I should do. I'm not a coder but happy to help if there's some way I can do that.
 
Thanks much.

Share this post


Link to post

OK, been working on this for a little while and then after fixing some issues, integrating @stouty's error handling, and moving over to David's workflow suite, I started to migrate to the new Forecast API. Long story short, the old API used to return very vague data, so I did a lot of cases to write their data out in full sentences. The new version of the API returns better data in most cases, which simplifies the code a ton.

 

@stouty, I integrated most of your error handling with some minor tweaks. Thanks for this. I've mentioned you in the workflow readme. If you're interested in any other changes please send a pull request.

 

@TychoX, you should see results coming back for Next 24 now since I'm just passing through what I get returned from the API.

 

@nick, The previous API only supported American locations. This version should work since the v2 API has international support.

 

Spend some time playing around with this build. The settings are back in the Alfred window (except the API key which is in `settings.plist`. I want to QA it more before I announce this as the 2.0 but it should work pretty well. Let me know of any issues.

 

http://cl.ly/0g0c1v2h2p2t

Share this post


Link to post

OK, been working on this for a little while and then after fixing some issues, integrating @stouty's error handling, and moving over to David's workflow suite, I started to migrate to the new Forecast API. Long story short, the old API used to return very vague data, so I did a lot of cases to write their data out in full sentences. The new version of the API returns better data in most cases, which simplifies the code a ton.

 

@stouty, I integrated most of your error handling with some minor tweaks. Thanks for this. I've mentioned you in the workflow readme. If you're interested in any other changes please send a pull request.

 

@TychoX, you should see results coming back for Next 24 now since I'm just passing through what I get returned from the API.

 

@nick, The previous API only supported American locations. This version should work since the v2 API has international support.

 

Spend some time playing around with this build. The settings are back in the Alfred window (except the API key which is in `settings.plist`. I want to QA it more before I announce this as the 2.0 but it should work pretty well. Let me know of any issues.

 

http://cl.ly/0g0c1v2h2p2t

 

Yes! It all works for me now! 

 

Thanks nick! I changed the long lat and inserted my API key from Dark Sky and it all works perfectly!

 

So exciting!

 

Thank you so much!

Share this post


Link to post

So...

 

At the risk fo being a complete arse.. incase you were wondering about features.. besides pretty pictures and sorts.. 

 

Maybe auto-locate long/lat? I just installed this today: http://www.alfredforum.com/topic/1660-geolocation/ - maybe it's an easy integration.

 

I sync my Alfred settings between home and work so I'll need to pick a place in the middle and use that if I don't want to constantly be updating the long / lat.

 

As a slight aside.. Weather in England can be snowing feet of snow and in a town less then 20 minutes away have a tropical spring day. 

 

I'm jumping the gun.  Let's just enjoy the beauty and awesomeness in the ability to know the exact weather in my location without sticking my hand out the window.

 

Ahh yes, it feels good, though a bit chilly.

 

 :-)

 

Thanks again!

Share this post


Link to post

@nick, Thanks for pointing me to that extension. I had been wanting to do automatic location lookup but couldn't think of an elegant way to do it. This helped me figure it out.

 

Try this, I think you'll be pleasantly surprised. It does location lookup based on IP: http://cl.ly/3j0q1o303U3M

Share this post


Link to post

Nick,

 

2.0b1 absolutely nails it!  All I did was put my API key in settings.plist, and viola, everything works!  You truly rock.  Any way we can send a few bucks your way to say thank you?

 

Thanks again!

Share this post


Link to post

I have a small issue with next hour report. It's not showing any data, but it has data on forecast.io . Any suggestions?

 

Screen%20Shot%202013-04-01%20at%201.59.1

Share this post


Link to post

I have a small issue with next hour report. It's not showing any data, but it has data on forecast.io . Any suggestions?

 

This should fix that: http://cl.ly/293V3l0w3W0l

 

The API docs said that it would potentially return nothing for the Next Hour summary, so I put that "No data" message. Rather than do that now, I just populate it with the next best guess.

Share this post


Link to post

The new version must be pulling the wrong location data. It's pouring outside and the iPhone app shows it is but the workflow says it's clear.

Share this post


Link to post

The new version must be pulling the wrong location data. It's pouring outside and the iPhone app shows it is but the workflow says it's clear.

 

I'm using http://ipecho.net/plain to get the IP address you are connecting from and passing that to http://freegeoip.net/json/YOUR.IP.ADDRESS to get the location coordinates.

 

Can you go directly to those sites to validate that the location returned is anywhere near you?

Share this post


Link to post

@nick, Thanks for pointing me to that extension. I had been wanting to do automatic location lookup but couldn't think of an elegant way to do it. This helped me figure it out.

 

Try this, I think you'll be pleasantly surprised. It does location lookup based on IP: http://cl.ly/3j0q1o303U3M

 

No Sir, do not dare to thank me, it's truly the least I can do.

 

I, thank you, for this excellent extension and all your hard work. I've updated and it seems to be working brilliantly. I see a few other posts may have a few troubles but I just checked my current location vs the results and everything looks great on my end.

 

I'll try it again tomorrow at the office and if it shares the right forecast I'd say it's sewn up. 

 

I'll let you know if anything else funky occurs but as of now, it's just perfect.

 

Thank you so much again.

Share this post


Link to post

I'm using http://ipecho.net/plain to get the IP address you are connecting from and passing that to http://freegeoip.net/json/YOUR.IP.ADDRESS to get the location coordinates.

 

Can you go directly to those sites to validate that the location returned is anywhere near you?

 

It's somewhat close. Shows the center of downtown Jacksonville, FL but I'm about 30 miles south of there... I'm guessing a Comcast building may be located there.

Share this post


Link to post

For anyone interested, I've modified the workflow quite a bit:

Screen%20Shot%202013-04-02%20at%2010.09.

Changes:

  • Added weather icons (Climacons)
  • Ability to set a dark or light theme ('w theme' command)
  • Modified results to get a little more info in there
  • Selecting any result will launch Forecast.io in the default browser

Still have to do some testing to make sure the results work will in various times throughout the day.

Share this post


Link to post

So I've been playing with this a lot today and decided to release it. @nickwynja, let me know if you're not okay with the info in the read-me. I feel I've sufficiently modified the workflow, but haven't used github and don't know how to make branches, etc.

 

Regardless, here's my Forecast.io workflow to try out. To set it up, you'll need your own developer API. You can paste it right into the workflow by entering 'w k <api-string-here>'. For convenience, links to register or login to Forecast for Developers are included. The theme can be changed by entering 'w t' and selecting light or dark. Forecast data has been reconfigured to get a little more info in there and (hopefully) handle different times of day nicely.

 

I've also changed the way it handles US/UK/SI units directly from the forecast api, so it shouldn't have to convert anything.

 

Image%202013.04.02%2011:22:40%20PM.png

Screen%20Shot%202013-04-02%20at%2011.23.

Image%202013.04.02%2011:24:56%20PM.png

[update: branched nickwynja's code on github.]

Edited by conigs

Share this post


Link to post

This is great, thanks. Is there any way to have it return ºC, or is that supposed to happen on the API side? I have forecast.io set to ºC, but the workflow keeps returning ºF.

Share this post


Link to post

This is great, thanks. Is there any way to have it return ºC, or is that supposed to happen on the API side? I have forecast.io set to ºC, but the workflow keeps returning ºF.

 

It's based on the country code of the location returned from the IP lookup. It would be possible to set a preference for it. In the mean time, you could edit line 45 of forecast.php to be 

 

$units = 'si';

 

 and that should take care of it.

Share this post


Link to post

It's based on the country code of the location returned from the IP lookup. It would be possible to set a preference for it. In the mean time, you could edit line 45 of forecast.php to be 

 

$units = 'si';

 

 and that should take care of it.

 

Perfect, thanks!

Share this post


Link to post

Perfect, thanks!

 

I've also updated the workflow to set units explicitly now. It defaults to location-based, but you can select the units you want by using 'w u' and selecting from the list.

Share this post


Link to post

Hi, if I set the units, the workflow no longer works. It says that it returned a non-JSON file. I do prefer US units, but I am getting use to metric. BTW: My location is Thailand. My only other problem is that it is much slower than others.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...