No announcement yet.

Canadian Weather Script

  • Filter
  • Time
  • Show
Clear All
new posts

  • Canadian Weather Script

    Here's my first script. It's written for Canadians wanting to see the fruits of their tax payers dollars at work by getting the weather from Environment Canada. If you find any problems post here or drop me a line and I'll see what I can do.

    I have not tested the Humidex functionality and don't expect it to be testable anytime soon, especially as I look out the window here in Calgary right now :-). Yesterday's snow storm was nice as it allowed me to test the Weather Warning stuff.


    From the file header:


    This script extracts the weather for a Canadian location from Environment
    Canada's webpage and formats it for display on a users Homeseer webpage.
    It displays the following information on the Homeseer webpage:

    Current weather condition with the appropriate icon displayed
    Current Temperature, Pressure, Visibility, Humidity
    Current wind direction and speed with direction icon
    Current windchill, dewpoint or humidex depending on conditions
    Normal High, Low and Mean temperatures for that day
    Yesterday's High, Low and Precipitation
    Five day weather forecast including today
    Weather warning status

    Temperatures are displayed in a variable colour to highlight them. Colour
    ranges from Dark blue for coldest to Dark Red for Warmest. See "Colourize
    Temperature" function for more info.

    Wind directions are expanded from their acronyms (N, NE, NNE etc.) provided
    on the Env. Canada webpage into their full length names (North, North East,
    North North East etc.).

    Weather warnings are displayed in purple if they are active for your location.


    Place Canada_Weather.txt in Homeseer scripts directory and all images in
    \html\envcanadaicons directory under Homeseer directory.

    Your location must be supported by Env. Canada. Start here to determine your
    locations info: When you get to
    the webpage for your location record the last 3 characters of the URL. For
    example Calgary's location webpage is:

    Name of place to be spoken and displayed by Homeseer (need not match Env
    Canada webpage, ex: "Calgary").

    last 3 chars. of URL (for Calgary example above would be YYC)

    This tells the script what string on the webpage delineates the start of the
    locations weather forecast. For the Calgary webpage example, the forecast is
    always delineated by "City of Calgary:".

    Examples for the above 3 user configuration constants are provided below.

    The script uses 15 virtual devices to store the weather info for display. The
    user must create these in Homeseer and enter them in the config. section below.
    The default is w1 to w15.

    If the user wishes to have the script speak the weather every time it runs, set
    this value to TRUE otherwise leave it as FALSE.

    This causes debugging information to be placed in the Homeseer log every time
    the script runs. It generates lots of info so unless you are having problems,
    leave it as FALSE.


    All weather variables are stored as Global Vars. They are referenced by the
    weather house code (default "w") and units 1 - 15. Individual "Speak_"
    subroutines are provided to speak every weather variable (normals and yesterday
    are gouped in 1 subroutine each). For example lets say you want an event to
    speak just the Forecast, the following script would suffice:

    #include Canada_Weather.txt

    Sub Main()

    Call Speak_Current_Weather()
    Call Speak_Temperature()
    Call Speak_Pressure()
    Call Speak_Wind()
    Call Speak_Humidity()
    Call Speak_Visibility()
    Call Speak_Variable()
    Call Speak_Normals()
    Call Speak_Yesterday()
    Call Speak_Forecast()
    Call Speak_Warning()

    End Sub

    Available routines are: Speak_Temperature

    Speak_Variable speaks either the Windchill, Dewpoint or Humidex depending on
    which is available.

    Note: This script was my first and borrows from great work by DSTEINEURO and
    many other Homeseer script contributors. For updates check the homeseer msg.
    board at:

    Attached Files

  • #2
    Excellent script! Extremely well documented! Once I got the TAGs correct for the forecast it work like a charm.

    Very nice!


    • #3
      Well done - works great. The only problem I had setting it up was to create a reoccuring event to run the Canada_Weather.txt script once in a while to update the virtual device with the current forcast. I set it up to run every three hours.

      I also added a few hs.waitevents into the canada_weather script because it does take a while to run.

      (Config is in my profile)


      • #4
        Glad you like it Bryan,

        I have the script running once every 15 minutes on my machine. I've seen the Calgary webpage update at least that often, the Chinook winds and their associated 20 degree C temp. changes in < 1 hour help to prove this :-).

        I forgot to mention you have to set up a recurring event to run the script. I'll add that to the readme/header.

        I'm not that up on hs.waitevents other than what I just read in the help file. On my machine, except for the speaking, the script is done in ~1 second (based on the "Scripts Running: Canada_Weather.txt" in the bottom left of HS window). This is with a cable modem internet connection and a 700MHz celeron win2k Homeseer server. Is it just the speaking that gives you a problem or does it all take a long time?

        I shouldn't assume that everyone has a fast connection and PC like I do. Let me know what the scoop is and I can add in the hs.waitevents for others.

        I used to live in Regina. Your weather info will have a lot of blue in it from October to March ;-)


        P.S. In keeping with Rich's forum rearrangement lets move this to the new Script Library Discussion

        [This message was edited by paulrimmer on Tuesday, 29 January 2002 at 12:25 AM.]