Hourly Weather Forecast Tiles


#1

With the $weather API being retired, the $twcweather API’s do not provide any hourly forecast. And if you’re like me, and do want an hourly weather forecast, here’s my piston. The piston itself is not an original, i have been using it for the past…many months, and am not sure who i borrowed it from. But it has been modified to use AccuWeather’s API.

You can get a free limited use (50 calls p/day) API from them that can help you achieve this. Sign up is at developer.accuweather.com. Don’t forget to set your timezone there as the API response is based on your account timezone. The URL you need to call is:-

http://dataservice.accuweather.com/forecasts/v1/hourly/12hour/?apikey=&details=true&metric=true

You can define the variable to either use celsius/farenheit as we as 12/24 hour clock formats.

Also, accuweather’s icon code do not match with twc, so i did the matching the best i could. So both ‘:wu-v-%:’ and ‘:twc-%:’ should work.


webCoRE Update v0.3.10a.20190223 - adds $twcweather to replace discontinued $weather, bug fixes
#2

Awesome, thanks! (The code looks like it might have originated from the example on the wiki which multiple people eventually had a hand in creating and tweaking).

A few comments:

  1. Unless others want to get the forecast for Leichhardt, New South Wales, they probably should adjust the location (the 12408 before the query parameters) - The API reference allows to search for location by text.
  2. I suggest adding both the apiKey as well as the locationID as variables and then using format("http://dataservice.accuweather.com/forecasts/v1/hourly/12hour/%s?apikey=%s&details=true&metric=%s", locationKey, apiKey, useCelsius) (as an expression) as the URL
  3. The footer text always uses “C” regardless of useCelsius
  4. The icons didn’t quite work for me :cry: - I guess your weather currently is too nice to have cloudy icons :wink: This is probably related to AccuWeather not having anything for icons codes 9 & 10…
  5. Rather than checking to nt_ in the iconName (which is not going to happen), you should check for isDaylight and adjust the icon accordingly (using the wiki and the AccuWeather Icons for reference)

I’ll play around with it some more until I run out of my daily API calls…


#3

Here is an updated piston which correctly honors the use24Time in the piston state as well and should have the correct icons for both day & night. Just fill in your API key and location and you should be good to go.

In case the URL gets removed during import, use the following expression:
format("http://dataservice.accuweather.com/forecasts/v1/hourly/12hour/%s?apikey=%s&details=true&metric=%s", locationKey, apiKey, useCelsius)

The piston now also updates the tiles by clicking any of its tile (it calls itself on the hourly timer) for easier testing.

Edit: I re-uploaded the piston as the original had a small typo in it, preventing some daytime icons not to show up correctly (isDaylight vs. IsDaylight)


#4

Also, shouldn’t the request be https instead of http? Best regards. Marcelo.


#5

No, all the request are insecure (see API Reference).


#6

Thanks for the updated piston. You’re absolutely right the ‘nt’ as well as the C. Forgot that I hard coded that onto the piston rather than using the usecelsius variable.

The weather over here has been pretty amazing of late, hence was not able to play around too much with the icons that came up.

Thanks again for this.


#7

Hi, thanks. I might be doing something else incorrectly then… My piston is not working so I started troubleshooting and my first attempt was to check the http respose in a browser and got an error from the page. When I tried the same url but using https, it got a big amount of data which I suppose is the correct response but, either way, the piston still does not work as expected. The settings in webcore categories is correctly set to show tiles. Any other tips for me to check?

FYI: I’m not a developer. Just curious… :slight_smile:

1 - Response in chrome when using http:

2 - Response in chrome when using https:

3 - Piston configured as details/tile:


#8

OK – apparently https: works too (I guess you should never trust the docs :wink:)

What do you see in the console when you run the piston using the “Test” button?


#9

Hi, not sure what happened behind the scenes. Leaving the piston to run on the scheduled times didn’t work in the past days. Today when I used the “test” button, it updated the values… Thanks! :grin:


#10

Make sure the “Execute piston” command points to that same piston


#11

My bad! Lack of attention! I have selected a piston, which happens to have the same name (don’t know why I did that), from another instance! :sweat_smile: