I’ve cracked it! I have got my proto-fridge-gizmo to display the weather for London in centigrade.
The key is to tweak the YQL query to read:
select * from weather.forecast where location="UKXX0085" and u="c" &format=json
In PHP you’ll need to escape those spaces, equals sign and quote marks, so you’ll end up with a line of PHP that reads something like:
$yql = "http://query.yahooapis.com/v1/public /yql?q=select%20*%20from%20weather.forecast%20where %20location%3D\"".$zipcode."\"%20and %20u%3D\"c\"&format=json";
$zipcode is a variable that contains the location code, in our case “UKXX0085″ for London. I’m trying to add another variable so you can choose if you want temperatures in centigrade or Fahrenheit.
Next things to do:
- get this working driven from a Raspberry Pi, rather than a laptop running OS X. This might involve installing the Apache web server and maybe PHP as well.
- Make the buttons do something.
- Source some train info – this is going to be tricky as SE Train info is not publicly syndicated. I probably could show Dublin DART times more easily…