nyssaroscoe / wunderground_widget

A jQuery library to render a current weather widget on a website using Weather Underground's API
MIT License
1 stars 1 forks source link

Current weather icon showing tomorrow's forecast? #1

Open timuckun opened 3 years ago

timuckun commented 3 years ago

Hi.

Looking at the code and the return from the wunderground API the datepart[0] are null every time I pull them so it looks like it's always showing tomorrow's icon. Am I reading the code wrong or misunderstanding the returned data?

Thanks.

nyssaroscoe commented 3 years ago

After 3pm for whatever station your pulling data from, datepart[0] is null, and I have found no way to retrieve today's icon at that point. I think this is a weird feature to have with the wunderground API, but I can only work with what I have. Unfortunately that means tomorrow's icon. If you find a way still retrieve the icon for today after 3pm, I will be happy to implement it in the code base.

timuckun commented 3 years ago

Interesting.

Two ideas...

  1. Cache the data in local storage. That's kind of iffy I guess, conditions can change fast.
  2. Fetch the conditions from the nearest location. I have been trying to find some documentation for the wunderground api but can't find any way to pull in a city or "nearest airport" or anything like that. Do you know if the full API (not just the PWS) is documented anywhere?
nyssaroscoe commented 3 years ago

Caching data locally wont really work, as you have to visit the page sometime before 3 for it to even exist in the cache. If the first time you visit the page is after 3, then your still in the same boat.

Fetching the conditions from the nearest local station that would have the icon, would be a timezone away, and thus even more inaccurate. It's the 3pm issue again.

The full API can be found here: https://docs.google.com/document/d/1eKCnKXI9xnoMGRRzOL1xPCBihNV2rOet08qpE_gArAY/edit There is no icon associated with current conditions, and I have to pull that from the forecast. I have no idea, why there is no icon with the current conditions, and I haven't been able to figure out where wunderground itself is pulling the current conditions icon.

timuckun commented 3 years ago

I set up three different locations on my WU page and watched the console for XHR requests. I did see a bunch of these.

https://api.weather.com/v3/location/near? apiKey=6532d6454b8aa370768e63d6ba5a832e& geocode=-37.717%2C175.994& product=airport& subproduct=major&format=json

and

https://api.weather.com/v3/location/point? apiKey=6532d6454b8aa370768e63d6ba5a832e& language=en-US&geocode=-37.737%2C175.981&format=json

These are undocumented in the PWS api document and I haven't tried them yet myself but I plan on doing some experiments to see where it gets me.