I fixed Apple's broken Weather Dashboard Widget

madrag

macrumors 6502
Nov 2, 2007
354
55
A little discovery based on intuition: when installing the new version of this or any other widget restart is not necessary. Instead, you can relaunch Dashboard by forcing its parent process "Dock" to force quit and re-launch with the command
Code:
killall Dock
in Terminal. That'll suffice.
You could also restart the widget by clicking it and pressing command + R, no?
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
You could also restart the widget by clicking it and pressing command + R, no?
Yeah, I'm really surprised that isn't sufficient. Reloading like this is how I test the widget during development.
 

indg

macrumors 6502
Feb 7, 2007
456
8
really appreciate this mod. i noticed a bug where pacific time zone cities start the 6-day forecast the next day. phoenix, az is MST but doesn't observe DST so it's same as PST with DST.

Screen Shot 2020-03-21 at 9.06.42 AM.jpg
Screen Shot 2020-03-21 at 9.07.30 AM.jpg
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
really appreciate this mod. i noticed a bug where pacific time zone cities start the 6-day forecast the next day. phoenix, az is MST but doesn't observe DST so it's same as PST with DST.
Thank you for the report, I think I see what I did wrong...
 
Last edited:

vkd

macrumors 6502a
Sep 10, 2012
902
301
Any idea why Rio de Janeiro doesn't pick up the present day and starts from tomorrow?




Screen Shot 2020-03-23 at 12.53.48.png
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
Any idea why Rio de Janeiro doesn't pick up the present day and starts from tomorrow?




View attachment 900667
Probably the same bug indg reported. I think I've fixed it, new version coming soon.

(The weather you're seeing isn't skipping a day, the day-of-the-week labels are just wrong)
 
Last edited:
  • Like
Reactions: vkd

indg

macrumors 6502
Feb 7, 2007
456
8
The weather you're seeing isn't skipping a day, the day-of-the-week labels are just wrong
i don't think it's mislabeling. i compared to dark sky source and the forecasts are correct for each day. just missing the current day.
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
i don't think it's mislabeling. i compared to dark sky source and the forecasts are correct for each day. just missing the current day.
Okay, thanks, we were describing different things—this is a separate error from the timezone bug. My memory of how the original widget worked was completely wrong!

I'd thought the six-day forecast was supposed to start with the following day, not the current one. The high and low temperatures are already visible in the top half the widget, so showing the current day down there would be mostly duplicate information.

However, apparently Apple disagreed, see: https://512pixels.net/projects/aqua-screenshot-library/mac-os-x-10-6-snow-leopard/#jp-carousel-15896 (Cross reference with the calendar widget to see which day of the week the screenshot was taken).

Welp, I think that's totally dumb, but I'll have to fix it to match Apple, since the point is to be faithful to the original. An update is still coming, work has just been busy lately...
 
Last edited:
  • Like
Reactions: vkd and otetzone

indg

macrumors 6502
Feb 7, 2007
456
8
i think it’s because today's forecast could be different than current conditions. so it may show a large sunny icon at top for right now, but today's forecast below could be rain icon for later today. that was my understanding, i could be wrong. anyway thanks again for working on this mod. it's sad that apple keeps dropping the ball on mac software.
 
  • Like
Reactions: otetzone

otetzone

macrumors newbie
Jul 12, 2019
13
2
Welp, I think that's totally dumb, but I'll have to fix it to match Apple, since the point is to be faithful to the original. An update is still coming, work has just been busy lately...
I dunno, I think you've done enough. I have this thing to myself but I hardly care. It's working and it's working right. I do get different days say for Ottawa and St.Pete, Russia, can't really find Stittsville but is this really that bad? I mean, it's not your fault, it's DarkSky fault so I don't see the reason pushing you to improve it. It's already good. You've done a great job. I don't know if it's worth to fiddle with the little things.
I mean, Apple dropped it and we can't expect it would be working the way it was. What we're having now is already great. I won't move from HS for as long as I can and I'll keep Mavericks on my other laptop for as long as I can. As long as it's working it's good. I can see it shows different days for different cities but does it really matter that much? We get the current conditions, what's the deal?
 
Last edited:

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
The widget in the first post has been updated so that the current day appears in the six day forecast. I also fixed the timezone bug that could cause the day-of-the-week labels to appear incorrectly in certain cities.

Quick note about the timezone bug—I'm now using DarkSky's "offset" property to calculate the local day of the week. DarkSky's documentation asks you to please not do this:
Use of this property will almost certainly result in Daylight Saving Time bugs. Please use timezone, instead.
Unfortunately, the timezone property is completely unhelpful because I have no way to interpret it. I'd have to pull in some huge library, or, worse, yet another API. So instead I'm just kind of hoping they're wrong about the DST thing...

Hopefully everything works and this is the last update for a while? I'm very conscious that updating is a little annoying since you have to move over your API keys.

I dunno, I think you've done enough. I have this thing to myself but I hardly care. It's working and it's working right. I do get different days say for Ottawa and St.Pete, Russia, can't really find Stittsville but is this really that bad? I mean, it's not your fault, it's DarkSky fault so I don't see the reason pushing you to improve it. It's already good. You've done a great job. I don't know if it's worth to fiddle with the little things.
I appreciate the kind words, but I decided a while back I wanted this widget to work fully. There was a moment early-on where I had DarkSky working but not MapQuest—everything looked perfect if you set your latitude and longitude manually in the code, but you couldn't flip the widget over to change your location. I concluded this wasn't good enough and did a lot more work to put in MapQuest. :D

I also recently spent a lot of time, money and energy last year downgrading my life to Mavericks because I was fed up with Apple's new versions of macOS. I wanted a fully working system for that effort.

The one thing I don't intend to fix right now is how the widget is empty before you set a location. I don't understand how the code for that used to work, and figuring it out would take too long for too little benefit.
 
Last edited:
  • Like
Reactions: indg and vkd

Erehy Dobon

macrumors 6502a
Feb 16, 2018
789
660
Can you put in a default location of 95014 (Cupertino, CA)?

Leave it blank if it is too much effort. Don't bother trying to use Location Services to figure out where the user is.

You have done great work with this and many of here appreciate it!

👍👍👍
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
Can you put in a default location of 95014 (Cupertino, CA)?
Sure, just tell me where in the code to set a default location and I'll do that. :p

There's a lot of code in here that I still have no idea what it does or how/why it works. Particularly most of the code in weather.js, which I really tried to modify as little as I could (although I couldn't completely avoid touching it).

I really do enjoy all the praise, makes me feel good! :D
 
Last edited:

Erehy Dobon

macrumors 6502a
Feb 16, 2018
789
660
On second thought, just leave the location blank.

If you could input Cupertino, CA as the default, someone might not figure out that it needs to be changed and will complain that the forecast is incorrect.
 

indg

macrumors 6502
Feb 7, 2007
456
8
great job fixing the day issue. everything appears to be working fine now. can’t thank you enough. 👏👍 stay safe and healthy!
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
Oh $%#!


Ironic, isn't it, that it's Apple who bought them? But of course they're closing off their API.

I'm going to switch out DarkSky with OpenWeatherMap. Should be relatively easy, but they only give us a five-day forecast, whereas the widget wants six days, which totally and completely sucks.
 
  • Like
Reactions: madrag

Mr_Brightside_@

macrumors 68040
Sep 23, 2005
3,189
1,268
Toronto
Oh $%#!


Ironic, isn't it, that it's Apple who bought them? But of course they're closing off their API.

I'm going to switch out DarkSky with OpenWeatherMap. Should be relatively easy, but they only give us a five-day forecast, whereas the widget wants six days, which totally and completely sucks.
Came here to post this - wild!
 

Erehy Dobon

macrumors 6502a
Feb 16, 2018
789
660
I'm going to switch out DarkSky with OpenWeatherMap. Should be relatively easy, but they only give us a five-day forecast, whereas the widget wants six days, which totally and completely sucks.
I ran -- not walked -- to the OpenWeatherMap website to sign up and record my API key so I will be ready for the switchover.
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
I'm really sorry to anyone who comes across this widget now and can't use it because they didn't get a DarkSky api key in time, but I'm going to leave things as they are for a while. There, um, seem to be some DarkSky keys floating around the internet, so you could maybe use some Google-Fu to try those?

If you have a key, DarkSky (Apple?) says it will keep working through 2021.

After thinking about it, I really really don't want to use OpenWeatherMap's five day forecast. That would result in an empty space at the end of the widget's six day forecast, and that would look stupid.

So instead, long-term, I'm keeping my eye on this: https://api.met.no/weatherapi/documentation. At the moment, I can't use them, because they only offer data as xml and really ugly json that's clearly just a computer conversion from xml. But, they say they're switching over to a new, proper json format within the next year. Might as well wait for that switch to happen.
 

maverick28

macrumors 6502
Mar 14, 2014
321
232
Bad news. Dark Sky is bought by Apple, no new signups. OP: you did that mods in time, so I could make it in the last minutes. Here's an email from Dark Sky I received.

bad-news-dark-sky.jpeg
 

maverick28

macrumors 6502
Mar 14, 2014
321
232
Probably the same bug indg reported. I think I've fixed it, new version coming soon.

(The weather you're seeing isn't skipping a day, the day-of-the-week labels are just wrong)
BTW, here in Vilnius (Lithuania), the widget shows weekdays from the next day too.

UPDATE. My fault, forgot the own recommendation to restart Dock. All is working now, brilliant job, Wowfunhappy.🤩
 
Last edited:

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
Turns out what I said yesterday was a lie. I stumbled upon weatherbit.io and I'm now updating the widget to use that API. It helps that I'm stuck in my apartment...

This will actually be great—it supports more weather conditions than DarkSky did, so you'll be able to see haze, sunshowers, and thunderstorms appear! Also, no SSL, so no weird proxies needed for 10.4 – 10.8.

Anyway, I came here because there's actually a couple of things I could use help with:

First, Weatherbit represents the current moon phase in a very odd way. The documentation says moonphase will always be a number between 0 and 1, but nothing else. The API gives these results for the next 16 days:

Code:
April 01: 0.704357
April 02: 0.805858
April 03: 0.892075
April 04: 0.955918
April 05: 0.991704
April 06: 0.996235
April 07: 0.969437
April 08: 0.914326
April 09: 0.836309
April 10: 0.742096
April 11: 0.638569
April 12: 0.531931
April 13: 0.427255
April 14: 0.328442
April 15: 0.328442
April 16: 0.238502
I'm referencing https://www.moongiant.com/phase/ to figure out how to translate these numbers, but I can't figure it out. "1" definitely means a full moon and I assume "0" would be no moon, but "0.5" does not appear to mean a half moon, as that will happen on April 14. Can anyone decipher it?

Secondly, this API does not have a weather condition for "windy", but it does have a wind speed. Assuming it's not raining/snowing (which will always take priority), how fast does the wind have to be to take precedence?

Lastly, should the daily high-low temperature be measured from 12 am to 12 pm or from 6 am to 6 pm? I don't know what DarkSky did; Weatherbit lets me choose. (I assume no one knows what the original did...)
 
Last edited:

Erehy Dobon

macrumors 6502a
Feb 16, 2018
789
660
I'm pretty sure other apps/services use 12am-11:59pm for daily high-low which often occurs around 4am.

When you look at the hourly forecast for a day, it goes from 12am to 11:59pm.

Also, it's the official astronomical day rather than a day dictated by a decidedly arbitrary cutoff point.
 
Last edited:

maverick28

macrumors 6502
Mar 14, 2014
321
232
Turns out what I said yesterday was a lie. I stumbled upon weatherbit.io and I'm now updating the widget to use that API. It helps that I'm stuck in my apartment...

This will actually be great—it supports more weather conditions than DarkSky did, so you'll be able to see haze, sunshowers, and thunderstorms appear!

Anyway, I came here because there's actually a couple of things I could use help with:

First, Weatherbit represents the current moon phase in a very odd way. The documentation says moonphase will always be a number between 0 and 1, but nothing else. The API gives these results for the next 16 days:

Code:
April 01: 0.704357
April 02: 0.805858
April 03: 0.892075
April 04: 0.955918
April 05: 0.991704
April 06: 0.996235
April 07: 0.969437
April 08: 0.914326
April 09: 0.836309
April 10: 0.742096
April 11: 0.638569
April 12: 0.531931
April 13: 0.427255
April 14: 0.328442
April 15: 0.328442
April 16: 0.238502
If (and this is just an assumption) these real numbers reference luminosity of the Moon then this sequence starts to make sense, especially if you round up to the first decimal position after the decimal point: it goes up to 0.9 (April 7 is max because 969437 > than 996235) and then gradually moves down. Why? Because April 6 is Supermoon or Full Moon and the amount of light it reflects is the highest one. You should not consider the whole numbers and in this notation adopted by Weatherbit it never gets equal neither to 1 nor 0.
Look closely at the highest digits to the right of the decimal point (the first three ones). Those are the indicators of the light intensity corresponding to the position of the Moon at each given moment. You have to determine the lower and upper limit of the Moon's growth.
For my part, I'd recommend 1 nice Dashboard little widget (which I hunted down on one of the Dashboard widget sites) named "DashPhoon" I use many year and a calendar subscription that lets me keep track of the Moon phases.

The widget displays relevant information in several formats, has a plenty of options. I post the GDrive public link (report if problems downloading).

https://drive.google.com/file/d/1VrO212V89tKYEcDCDSo2tCMwcBcQM_WN/view?usp=drivesdk


In addition to that I subscribed to a very excellent Moon phases at http://www.webcal.fi/en-US/calendars.php, it's right on the top, hit "Subscribe". That way you'll be able to keep abreast of the Moon's movement.
 

Wowfunhappy

macrumors member
Original poster
Mar 12, 2019
88
79
If (and this is just an assumption) these real numbers reference luminosity of the Moon then this sequence starts to make sense, especially if you round up to the first decimal position after the decimal point: it goes up to 0.9 (April 7 is max because 969437 > than 996235) and then gradually moves down.
Oh... I really hope that's not what's going on, because that would make the numbers useless. They did call the property moonphase, you'd think it would actually indicate what phase the moon is in, not just how much light it's putting out...

Thanks for the tip about the calendar, but I don't actually care to know what phase of the moon is in, I just want the widget to work correctly. It was a nice touch in the original. But if we can't get good data I guess the moon will just always be full...
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.