Jump to content

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.

Link to comment

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

Link to comment

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.
Link to comment

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

Link to comment

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!

Link to comment

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!

Link to comment

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?

Link to comment

@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.

Link to comment

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.

Link to comment

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.

Link to comment

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
Link to comment

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.

Link to comment

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!

Link to comment

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
×
×
  • Create New...