J.A.R.V.I.S inspired weather wake-up announcement for CastleOS

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:

  1. Download and extract the latest JarvisWeather.zip from Github
  2. Grab yourself a Forecast.io API Key. 1,000 calls per day are free!
  3. 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
  4. 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
  5. Edit the respective script file, and be sure to set your locations Latitude and Longitude. You can use Google to work this out.
  6. 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
  7. Upload your Kinect/Action script to CastleOS
  8. Setup your event or custom voice command
  9. Profit!
Recommended Posts
  • Pingback: J.A.R.V.I.S inspired announcement/greeting for Home Assistant – Phil Hawthorne()

  • Jacob Turnage

    Hi Phil, I’m really interested in getting this to work and I believe I followed your steps accurately despite my layman’s knowledge of coding. Do you have to have the paid version of Castle OS or a Castle Hub for this script to run properly through a Sonos speaker? When I set up the event with the custom script nothing happens. Thanks!

    • Hey Jacob,

      I must admit I have long moved on from CastleOS since I wrote this. When I wrote this there was no free version of CastleOS. I was using the CastleHUB, but the CastleHUB is still just a Windows PC underneath.

      Unfortunately for me its been a bit long now since I used this script I’m not sure if it would still work or not 🙁

Start typing and press Enter to search