Custom Navigation Tiles - How to make a Dynamic Weather Tile using Weather Underground API

Yes use this:

{CALL:weather.forecast('ZA','Jeffrey's_Bay','9c4fxxxxxx','c')}

Nicely done, Thanks you. Awesome!

2 Likes

The nice script was written by @emre he deserves that credit for making it so dynamic. Its a great example of writing a nice script and how to use various jscript functions. I learned a lot from it and was able to write my own scripts easier by studying his weather script.

2 Likes

What I would like to know is can you get a nice big Symbol like the default tiles? Tried a few things but have not seem it done yetā€¦ Of course its only cosmetic and not a high priority.

try <font segoe ui symbol><size 40>insert symbol here</size></font>

Other than these defaults you should be able to use any symbol font youā€™ve installed on your computer.

1 Like

Sorry @emre tried a few things but does not work?

<font segoe ui symbol><size 40><sym>ī‡œ</sym></size></font><linebreak/> <size 48><bold>Work Period</bold></size> 

AND

<font segoe ui symbol><size 40><sym>ī‡œ</sym></size></font><size 48><bold>Work Period</bold></size>

Obviously the correct symbol was pasted in the code above. Either result I still get a tiny weeny symbol:

Really want one of these below or something bigger than aboveā€¦

EDIT: Will add this is minor cosmetics, just bugging me thatā€™s all :grimacing:

You can experiment with block tags to get result you like.

1 Like

Nup, donā€™t get it? I can create a bigger symbol (new), but It effect the rest of the text by adjusting all the sizing like so:

The Formatting:

<font segoe ui symbol><block left><size 180><sym>ī‡œ</sym></size></block></font><linebreak/><size 48><bold>Work Period</bold></size>

Alignment seems ineffective and I know it just lack of understanding but I fail to see how I can cut the tile in half like the default tilesā€¦

Try this:

<block><size 100><sym>ī‡œ</sym></size><size 50> Work Periods</size></block>
{CALL:weather.forecast('AR','Newark','APIKEY','f')}

1 Like

Thanks kendash - almost similar result, so thatā€™s good I was close. I trying to achieve the big symbol like shown in the reports tile above but this must be some internal formatting thing. It would almost mean placing a ā€œtableā€ - 2 cells in the tile using 1 side for a large symbol and the other side for text.

Happy to conclude this experiment.
EDIT: Yours does seem a little bigger than mine :laughing:

Well it will be hard to get exact same size because there is so much data in the script to fit in there and it auto resizes it so it fits. So its my opinion it looks better to put symbol and tile name above the data.

We can make it put symbol full size on left and script data on right but the weather data will be very small and hard to read.

Your two screenshots above might demonstrate it ā€¦ Look at the two screenshots with one on top of the other. Look at the space available to right of the large iconā€¦ then look at how if you overlap the top screenshot the script data would be on top of the last bar in the icon imageā€¦ it would have to shrink to fit that spaceā€¦making the data even smaller to read.

So we needed to find a happy balance of sizes so it looks nice.

1 Like

I have copied and paste but it does not show anything

could you please check what i am missing here

My Script

var nl = '<linebreak/>';

function forecast(region,city,key,t)
{
  if (typeof(t) == "undefined") { var t = 'f'; }
  var result = nl;
  var weather = getCurrent(region,city,key)
  result += toBlock(cdegree(weather,t)) + nl;
  var root = getForecast(region,city,key);  
  for (i = 0; i < root.length; i++) {
    result += toBlock(toTile(root[i],t)); 
  }
  return result;
}

function getForecast(region,city,key)
{
  var u = 'http://api.wunderground.com/api/'+key+'/forecast/q/'+region+'/'+city+'.json';
  var allweather = web.Download(u);
  var weather = JSON.parse(allweather);
  return weather.forecast.simpleforecast.forecastday;  
}

function getCurrent(region,city,key)
{
  var u = 'http://api.wunderground.com/api/'+key+'/conditions/q/'+region+'/'+city+'.json';
  var allweather = web.Download(u);
  var weather = JSON.parse(allweather);
  return weather.current_observation;  
}

function toBlock(content)
{
   return '<block 30,0,0,0>' + content + '</block>'
}

function toTile(forecast,t)
{
   return forecast.date.weekday_short + ' ' +sym(forecast.icon) + nl + 
     degree(forecast.high,t) + ' / ' + degree(forecast.low,t);
}

function degree(value, t)
{
   return t=='c' ? value.celsius: value.fahrenheit;
}

function cdegree(value, t)
{
   var result = t=='c' ? value.temp_c: value.temp_f;
   return '<size 70><bold>'+result+' '+degreesym(t)+'</bold></size>';
}

function degreesym(t)
{
   return t=='c' ? 'CĖš': 'FĖš';
}
function sym(icon)
{
  if(icon.indexOf('partlycloudy') != -1) return '<sym>īŠ†</sym>';
  if(icon.indexOf('cloudy') != -1) return '<sym>īŠ…</sym>';
  if(icon.indexOf('rain') != -1) return '<sym>īŠˆ</sym>';
  if(icon.indexOf('snow') != -1) return '<sym>īŠ‹</sym>';
  if(icon.indexOf('clear') != -1) return '<sym>īŠ„</sym>';
  if(icon.indexOf('sleet') != -1) return '<sym>īŠŠ</sym>'
  if(icon.indexOf('fog') != -1) return '<sym>īŠ‡</sym>'
  if(icon.indexOf('storm') != -1) return '<sym>īŠ‰</sym>'
  return icon;
}

Result

through web browser

Show your script via screenshot. Is your handler weather?

PS: I edited your image to get rid of your key, you do not want to share your private weather api key with public.

Sorry I donā€™t know what is handler weather? where can i find it

Itā€™s all in the tutorial. Read it carefully. Itā€™s about third post down by another member.

The Name is arbitrary - it can be anything you want.

The Handler is important. This is how you reference the functions in the Script.

{CALL:handler.function()}

For the screenshot below, your call would look like this:

{CALL:weather.current('Istanbul','Turkey')}
handler ^        ^ function

I tried this, but im getting nothing on my screenā€¦

Ive sort of started my till from scratch at home to play about ready for when I build the biggy. THis would be a great asset to me as I have a milkshake bar and of course everything is weather dependent.

So, ive done the scriptā€¦ Ive done the Automation COmmand and yet its not even showing a tile?

I have deleted it since but just saw this topic pop up and so thought id give it another shot.

Ill post screenshots in due course

Regards

Matt

Map the button to Display on Navigation.

You should also set your Tile Cache to a reasonable value, such as 30 or 60. This will prevent using up your allowed API ā€œhitsā€, since in most cases, there is a limit to how often you are allowed to query per day.

2 Likes

This seems obvious but you never know, also ensure your internet is working on the terminal and firewall is not blocking access.

I dont have a firewall installed, and its all on this PC at the moment I havent transferred the new setup to the terminal.

Ill have another gander at it all today, but im sure im doing something wrong

regards

Matt

Edit: I have managed to get a button on the Nav screen. It seems I needed to give it a name. So im getting there!

Edit Edit:

Ive disabled the firewall but still isnt showing :frowning: