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
Weather tile not importing
#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)


Using $index from response
Weather tile not importing
#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:


#12

I am trying to use the new weather service to give me just the icon for today’s weather as a tile on my dashboard. I want this tile :

Screenshot_2019-03-19%20TWC%20Weather%20-%20webCoRE%20Wiki%20-%20Web-enabled%20Community's%20own%20Rule%20Engine

I am using :

:wu-v4-{$twcweather.forecast.daypart[0].iconCode[0]}

But I cannot get the syntax correct.


#13

Give this a try:

format(":wu-v4-%s:", $twcweather.forecast.daypart[0].iconCode[0])

#14

@kayvint, thanks for the help. I am clearly over my head here. I’m running a test piston until I understand what is going on. But I still cannot get a valid piston tile.

format(":wu-v4-%s:", $twcweather.forecast.daypart[0].iconCode[0])

I do not understand the "wu-v4-%s:" part. Specifically the -%s part.

#15

The prefix for the icons is usually either “twc-” or “wu-v4-” as seen here:
temp
(a large list can be found here)
It’s totally your preference which image set you use.


The suffix is a number that represents the forecast conditions for that time period.
Found with the code:
$twcweather.forecast.daypart[0].iconCode[INDEX]


Unfortunately, I don’t have freetime at the moment to give you a sample piston.

Hopefully someone has one at the ready for you.


#16

@kayvint, @WCmore Thanks guys…



#17

Can someone point me to more information on the -%s part? I searched but could not find much.


#18

The wiki has good information on this, specifically the Functions reference page.


#19

In layman’s terms, the %s is the string returned from that loop’s query.
(In your case, the iconCode)


#20

Webcore is very new to me. I have tried to get tiles to show up. I see nothing. I have piston in tiles area and I guess the tiles are to show up somewhere but I see nothing. Under logs the piston completes. Anyone have any idea what I am doing wrong.

Thanks,

Al