There is an interesting function on ST's RDS capability, the one that we can tell ST to read from a specific text file. I though that it would be really nice to include current weather data from a website, like outside temperature or next day forecast.
The data can be updated every, let's say, 5min and be displayed on PS text.
First of all you have to choose the weather info provider. Currently I'm using my city's online meteo station that uploads raw data to a website. Don't worry, you can use Google's secret weather API, so that's what I'm going to explain, below.
I'm getting the raw data from Google (actually it's Weather Underground data) every 5mins using the superb
wget (coming from linux, there is a Win version).
To extract temperature from all the data, I'm telling the batch file to search for a specific location inside the raw mess of numbers and get a specific number of characters. Then I tell the batch proggy to output just the temperature to a single text file. At the end, I setup ST to display the text file into the RDS PS.
So, you will need:
1. the wget program, from
http://users.ugent.be/~bpuype/wget/
2. the following batch program. Call it whateveryoulike.bat and place it at the same folder with wget.exe Remember to
replace YOURCITYGOESHERE to the one you are interested in. You can test it in your browser, you should see an XML file.
Code:
@echo off
del googleout.txt
del googledata.txt
wget -O googledata.txt -F "http://www.google.com/ig/api?weather=YOURCITYGOESHERE&hl=en"
setlocal EnableDelayedExpansion
for %%a in (googledata.txt) do (
for /f "tokens=1 delims=" %%b in (%%a) do (
set rec1=%%b
set ord=!rec1:~482,2!
echo !ord! >> googleout.txt
)
)
As you can see, the process goes like:
Firstly, I delete the files googleout.txt and googledata.txt that may have been created before. So I have no previous weather data at the moment, aka clean start.
I'm running wget so I can get the URL
http://www.google.com/ig/api?weather=YO ... HERE&hl=en and I'm outputing the information in the googledata.txt, in English language.
I'm telling the batchfile to search for character location 482 and get the 2 following characters that contain the temperature in Celcius. Then I output just the 2 characters to googleout.txt
Now, at the same directory as the wget.exe and my batch file you should also have googleout.txt and googledata.txt
Go to ST and add at the PS box, the path to the googleout.txt like:
Code:
2s:Temp \F"c:\yourpathhere\googleout.txt"
You are good to go!
Don't forget to make the .bat batch file to be run automatically every X minutes, so you can get fresh data! (Windows Task Scheduler)
Some thoughts:
I know it's not the perfect way to do all that stuff, but hey, it works!
I wish you could also include weather forecast for the following days. It would be cool to display on the RDS the text like "Tomorrow will be Sunny, Cloudy etc" BUT we don't know how many characters to capture from the googleout.txt file
(Any script expert to help on that?)
You have to test in your browser the URL asking Google for the weather data, so you are sure that it get's correctly your city's name.
For geeks: I know that the -F flag on wget is not really needed, but hey! switches and options are cool :p
I've written before that I'm not using Google weather data because they are not accurate for my city. I'm actually using a text file which provides tons of weather info, like humidity, winds, rain etc. Feel free to change the URL in the script and make sure that the batch get the correct characters for the info you want to display.
I hope you find it useful