One of my favourite scenes from the awesome movie Iron Man is the scene where J.A.R.V.I.S, the AI assistant wakes up the house with the current weather. J.A.R.V.I.S also opens the blinds and turns on the lights.
Something as simple as the blinds opening and the weather being announced can be a real “wow” factor. Now that my CastleHUB has arrived, it’s time to put the power of CastleOS’s scripting system into play. It took a bit to get to this point (and special thanks to Eric Hillen), but today I’m proud to say I’ve finally got an automated weather announcement script working for CastleOS. (Next step: automating the blinds!)
Running via a recurring event, each morning the Sonos speaker in my bedroom will now play an announcement like…
Good morning. The current weather in Melbourne is Sunny at 18 degrees. Today is expected to be Sunny with a top of 31 and a low of 14.
The weather data is fetched in real time from the Yahoo! Weather API.
To get things working nicely, I created an EXE file that takes command line arguments for the location and temperature unit. The EXE file then returns the text (with the weather) to CastleOS. CastleOS then sends that text via Text to Speech (TTS) to my Sonos speaker.
If you would like to use the console app for yourself, or if you’ve got CastleOS and want the same setup, all the code is available on Github.
For CastleOS, just follow the following steps:
- Download and extract the latest JarvisWeather.zip from Github
- Grab yourself a Forecast.io API Key. 1,000 calls per day are free!
- If you want to schedule the announcement via an event in CastleOS, you’ll need to also grab the core_service_action_script.cs file
- If you want to be able to ask CastleOS the current weather via a custom voice script, then you’ll need to grab the kinect_service_script.cs file
- Edit the respective script file, and be sure to set your locations Latitude and Longitude. You can use Google to work this out.
- Be sure you extract the JarvisWeather.zip to somewhere on your computer running CastleOS or the CastleHUB, and set the location to JarvisWeather.exe in your .cs script
- Upload your Kinect/Action script to CastleOS
- Setup your event or custom voice command