www.homeseer.com

Go Back   HomeSeer Message Board > HomeSeer > How-To's

How-To's This area provides in-depth information on how to do something in HomeSeer or home automation.

Reply
 
Thread Tools Display Modes
  #1  
Old November 16th, 2009, 06:12 PM
HiTech's Avatar
HiTech HiTech is offline
Seer Deluxe
 
Join Date: Oct 2001
Location: Texas
Posts: 282
Default Using Davis “WeatherLink” SW and HomeSeer

The discussion for this "How To" can be found here.

This is method 1, see method 2 below.

I recently started using the Davis WeatherLink software with great success to create data to use in HomeSeer. This should work with any Davis weather station and I use the wireless Vantage Pro 2 connected with a “USB Data Logger”. The only requirement is you must connect the weather station to a computer and run the WeatherLink software 24/7. It is possible to accomplish this by running WeatherLink on a separate computer from HomeSeer, but that will not be discussed here.

The basic steps are:
1. Turn on the internet feature in WeatherLink and configure it to place weather data in HomeSeer’s “html” folder. This could include sharing the HomeSeer html folder and having WeatherLink running on a separate computer. By mapping the drive location of HomeSeer you could have WeatherLink place the files in the correct place.
2. Create the devices to be used in HomeSeer and use the provide script in HomeSeer to gather the weather data. Events can then be created with triggers or conditions to react to your weather conditions.

I am providing my “WeatherStation.txt” script as a sample to help you get started, but first we need to setup WeatherLink.

At this point you want to be sure to have the latest WeatherLink software found on the Davis website. I am currently using version 5.9. WeatherLink v5.9 is an update, so you will need to install the version that came with your weather station and then perform this update. Be sure WeatherLink is connected and your weather station is completely setup in WeatherLink before proceeding to the next step.

With your weather station now connected and the WeatherLink software running on your HomeSeer machine, we will start by creating the template files used by WeatherLink.

1. Open notepad and type (omit the spaces) < !--ForecastStr-- > Then save this file as “Forecast.htx” to the path of your weather station. Example: my default path is “C:\WeatherLink\Monticello\Templates” where “Moticello” is the name of my station. You have just created your first .html template. Wasn’t that easy!

2. Open notepad again and type (omit the spaces) < !--outsideTemp-- > Then save this file as “OutSideTemp.htx” to the path of your weather station.

3. Repeat step 2 for each new template you wish to create. I used the following weather tags:
HTML Code:
<!--barometer-->, <!--dailyRain-->, <!--ForecastStr-->, <!--outsideHeatIndex-->,
<!--outsideHumidity-->, <!--monthlyRain-->, <!--outsideTemp-->, <!--rainRate-->, 
<!--stormRain-->, <!--windChill-->, <!--windDirection--> (returns direction in 16-point compass - string), 
<!--windDir--> (returns direction in Degrees - value), <!--hiWindSpeed-->, <!--windSpeed--> 
and <!--totalRain-->
NOTE: Refer to the .htm file names in the script below so the script will work correctly. When naming the template files, be sure to match these names, Ex: WeatherLink automatically creates the “WindDirectionString.htm” used by the script below from the template file “WindDirectionString.htx”

Later you can create more templates when you have a better understanding of how the HomeSeer “WeatherStation.txt” script uses these.

NOTE: See the WeatherLink help file for more information on “template files” and “WeatherLink HTML tags” Do a search in the WeatherLink help for the complete list of “WeatherLink HTML tags”, there are a bunch.

Now we will configure the WeatherLink internet connection to use the newly created templates.

1. Create the “WeatherLink” folder in your HomeSeer\html folder prior to browsing the path in the next step.

2. Click on the “setup” menu in WeatherLink and select “internet settings…” Here you will enter the path to your HomeSeer html folder by clicking on “Internet Connection Settings” box. In the new window, click on “Connect through a local server” radio button (top left). Then click on the check box “Local Transfer Enabled” (lower left) and finally click the “Browse” button or enter the correct path in the text box (lower right) to your HomeSeer, html, WeatherLink folder. Click “OK” This is where WeatherLink will store the html files used by the HomeSeer “WeatherStation.txt” script. My path is: C:\Program Files\HomeSeer HS2\html\WeatherLink\.

3. You are now in the previous window. Click on “Configure” below the Profile 1.

4. The “Data Update Profile 1” window will open. Click on “Update every” drop down box and select the frequency you want the data updated. I use “5 min.”, but for testing use “1 min.”

5. Click on the “Starting at” text box and type “12:03a”

6. Click on the button labeled “Select Template Files” to open the “Weather Template Files for Data Upload Profile1” window.

7. Click the “ADD” button to open the “Select Files to upload” window. In this window you will select all the template files (EX: OutsideTemp.htx) we created above. We saved these files to “C:\WeatherLink\your station name\Templates” folder. After you have highlighted all your template files, click “Open”

8. You will be back at the “Weather Template Files for Data Upload Profile1” window. In the text box “Select an optional sub-directory to upload these files to:” type “Data Folder\”. Click “OK”

9. Click “OK” again to close the “Data Update Profile 1” window.

10. Click “OK” again to close the “Internet Connection Settings” window.

You have now completed the WeatherLink configuration and the .htm files should start to populate HomeSeer’s “html\WeatherLink\Data Folder” folder. We will now create the HomeSeer event and devices to gather and store this data.

Start by creating the individual devices to hold the weather data in HomeSeer. My devices are “w48” for the “Forecast”, “w50” “temperature”, “w51” “Humidity”,“w52” “Barometer”, “w53” “Wind Speed”, “w54” “Wind Direction”, “w55” ”High Wind”, “w56” “Rain Rate”, “w57” “Rain Today”, “w58” “Rain Month”,”w59” “Rain Storm”, “w60” “Rain Year”, “w61” “Heat Index” and “w62” “Wind Chill”. You can name them anything you like.

And now the final step, create a recurring event (every 1 to 3 minutes) named “Weather Updater” and the action is “Run Script”. If you are going to copy and paste the “WeatherStation.txt” script then type WeatherStation.txt in the “Existing or new script name:” box and click “Open Script Window” button. In the script window paste the following script:

NOTE: You should change the port number to the port you are using to access HS. Everywhere you see "Port" in my script you should replace it with your port number. The default port number is 80, but if you changed your port number in HS, then you should use the port listed here in your HS setup: "Tools" button, "Setup / Configuration" button, "Web Server" tab, third line down "Server port:" text box.

Code:
Sub Main()
    Dim strForecast
    strForecast = hs.GetURL("http://localhost","/WeatherLink/Data Folder/Forecast.htm",True,Port)
     If hs.DeviceValue("w48") <> strForecast Then
         Randomize()
         Call hs.SetDeviceValue("w48", Rnd * 99)
         Call hs.SetDeviceString("w48", strForecast)
     End If

    Call hs.SetDeviceValue("w50", hs.GetURL("http://localhost","/WeatherLink/Data Folder/OutSideTemp.htm",True,Port))
    Call hs.SetDeviceString("w50", hs.GetURL("http://localhost","/WeatherLink/Data Folder/OutSideTemp.htm",True,Port) & "°F")

    Call hs.SetDeviceValue("w51", hs.GetURL("http://localhost","/WeatherLink/Data Folder/Humidity.htm",True,Port))
    Call hs.SetDeviceString("w51", hs.GetURL("http://localhost","/WeatherLink/Data Folder/Humidity.htm",True,Port) & "%")

    Call hs.SetDeviceValue("w52", hs.GetURL("http://localhost","/WeatherLink/Data Folder/Barometer.htm",True,Port))
    Call hs.SetDeviceString("w52", hs.GetURL("http://localhost","/WeatherLink/Data Folder/Barometer.htm",True,Port) & "in")

    Call hs.SetDeviceValue("w53", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindSpeed.htm",True,Port))
    Call hs.SetDeviceString("w53", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindSpeed.htm",True,Port) & "mph")

    Call hs.SetDeviceValue("w54", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindDirectionValue.htm",True,Port))
    Call hs.SetDeviceString("w54", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindDirectionString.htm",True,Port))

    Call hs.SetDeviceValue("w55", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindHigh.htm",True,Port))
    Call hs.SetDeviceString("w55", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindHigh.htm",True,Port) & "mph")

    Call hs.SetDeviceValue("w56", hs.GetURL("http://localhost","/WeatherLink/Data Folder/RainRate.htm",True,Port))
    Call hs.SetDeviceString("w56", hs.GetURL("http://localhost","/WeatherLink/Data Folder/RainRate.htm",True,Port) & "in/hr")

    Call hs.SetDeviceValue("w57", hs.GetURL("http://localhost","/WeatherLink/Data Folder/DailyRain.htm",True,Port))
    Call hs.SetDeviceString("w57", hs.GetURL("http://localhost","/WeatherLink/Data Folder/DailyRain.htm",True,Port) & "in")

    Call hs.SetDeviceValue("w58", hs.GetURL("http://localhost","/WeatherLink/Data Folder/StormRain.htm",True,Port))
    Call hs.SetDeviceString("w58", hs.GetURL("http://localhost","/WeatherLink/Data Folder/StormRain.htm",True,Port) & "in")

    Call hs.SetDeviceValue("w59", hs.GetURL("http://localhost","/WeatherLink/Data Folder/MonthRain.htm",True,Port))
    Call hs.SetDeviceString("w59", hs.GetURL("http://localhost","/WeatherLink/Data Folder/MonthRain.htm",True,Port) & "in")

    Call hs.SetDeviceValue("w60", hs.GetURL("http://localhost","/WeatherLink/Data Folder/YearRain.htm",True,Port))
    Call hs.SetDeviceString("w60", hs.GetURL("http://localhost","/WeatherLink/Data Folder/YearRain.htm",True,Port) & "in")

    Call hs.SetDeviceValue("w61", hs.GetURL("http://localhost","/WeatherLink/Data Folder/HeatIndex.htm",True,Port))
    Call hs.SetDeviceString("w61", hs.GetURL("http://localhost","/WeatherLink/Data Folder/HeatIndex.htm",True,Port) & "°F")

    Call hs.SetDeviceValue("w62", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindChill.htm",True,Port))
    Call hs.SetDeviceString("w62", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindChill.htm",True,Port) & "°F")
        
End Sub

Click the “Save Script” button and then “Save Event” button.

You are done!

Note that lines 1 through 8 still need a little work, but they don’t error out. Because the forecast is a string you cannot use the device status change in conditions for this device in other events.

Also note that in the following lines of code, I set the device value for the wind direction in degrees (0-359) so you can use the device value status in event conditions, but the device string is set to the 16-point compass direction (N, NNW, SSE etc.) to display on the device page in HomeSeer.

Call hs.SetDeviceValue("w54", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindDirectionValue.htm",True,Port))
Call hs.SetDeviceString("w54", hs.GetURL("http://localhost","/WeatherLink/Data Folder/WindDirectionString.htm",True,Port))

One final note: HomeSeer automatically rounds off numbers after the decimal point for the “Device Value”. This is a basic function of HomeSeer. “Device Strings” however are displayed exactly as you would expect. Many new HomeSeer users are often confused by the differences of “Device Strings”, “Device Values” and “Device Status”. Each is unique and different in it’s own way. In the above script, “WeatherStation.txt” we deal with only the “Device Value” and “Device String” and do not use the “Device Status”. Because the “Device Value” is how conditions and triggers activate events in HomeSeer, this can be problematic when trying to use conditions in your events. For example: The “Device String” 71.6°F equals the “Device Value” of 72 and the “Device String” 71.4°F equals the “Device Value” of 71. Not such a problem for temperature, but in the case of rainfall, where the “Device String” is 0.41 inches of rain the “Device Value” is actually equal to 0 and where the “Device String” is 0.51 inches of rain the “Device Value” is actually equal to 1. Therefore, conditions and triggers will not activate an event until the rainfall is actually above 0.50 inches of rain. Restated, if you set an event to trigger at “Device Value” 1 (thinking that 1 is “1 tenth” of an inch of rain), then the event will not trigger until after it has rained 0.50 inches. In this example a multiplier of 100 is needed in the script to set the “Device Value” to 1 so that tenths of an inch of rain can be used in your conditions and triggers. It would then be understood that “Device String” 1.01 inch of rain would have the “Device Value” of 101. The same would hold true for barometric pressure, except you would need to use a multiplier of 1000 to correct the “Device Value”. The “Device String” for a barometric pressure of 30.022in would then have a “Device Value” of 30022 and you could trigger an event off of small changes in barometric pressure.

If you have any questions, feel free to post and I will try to answer ASAP.
-Rick

I would also like to thank our son, Dale (the code writing genius) for his help!

Last edited by HiTech; March 12th, 2010 at 10:17 AM. Reason: Updated for new method
Reply With Quote
  #2  
Old February 20th, 2010, 06:51 PM
HiTech's Avatar
HiTech HiTech is offline
Seer Deluxe
 
Join Date: Oct 2001
Location: Texas
Posts: 282
Default WeatherLink and HomeSeer - Method 2

Method 2 - Using Davis WeatherLink software and HomeSeer. The discussion is found here.

The new method that I have been using for over two months is now easier to set up and eliminates the hs.GetURL making it a little more efficient. This new method will create a dynamic script that HomeSeer can run in a recurring event and is capable of updating weather devices more frequently with little CPU overhead.

For years people posted the question “How do I get my Davis weather station data into HomeSeer?” The reply I saw many times was, “Purchase a Davis Data Logger (which comes with a copy of WeatherLink) and then buy another piece of software like Virtual Weather Station to interface with HomeSeer.” I’ve even read that WeatherLink would not work for this, but here it is. I run WeatherLink on my HomeSeer server and have it connected to my wireless Vantage Pro 2 with a USB Data Logger. This will work on any Davis weather station that uses a data logger. As an option, you could have a separate computer running WeatherLink and network the data into HomeSeer. The only requirement is you must connect the weather station to a computer and run the WeatherLink software 24/7.

You can also use WeatherLink to post your weather data to weather services like Weather Underground. In addition, WeatherLink also stores historical data and graphs that can be displayed on your HomeSeer web pages. We will not be discussing these options in this How-To, but it is done basically the same way using the internet profiles in WeatherLink. We could however carry on that discussion here.

The basic steps are almost the same as the first method explained earlier:
1. Create the devices to be used in HomeSeer.
2. Turn on the internet feature in WeatherLink, use the provided template and configure it to create a dynamic script in the HomeSeer/scripts folder. This script will be populated with your weather station’s data.
3. HomeSeer events can then be created with triggers or conditions to react to your weather conditions.

At this point you want to be sure to have the latest version of WeatherLink software found on the Davis website. I am currently using version 5.9. WeatherLink v5.9 is an update, so you will need to install the version that came with your weather station and then perform this update. Be sure WeatherLink is connected and your weather station is completely setup in WeatherLink before proceeding to the next step.

With your weather station now connected and the WeatherLink software running on your HomeSeer machine, we will start by manually creating the HomeSeer devices that will hold your weather data.
You may skip this step if you used the first method, as the devices are the same. My devices are “w48” for the “Forecast”, “w50” “temperature”, “w51” “Humidity”,“w52” “Barometer”, “w53” “Wind Speed”, “w54” “Wind Direction”, “w55” ”High Wind”, “w56” “Rain Rate”, “w57” “Rain Today”, “w58” “Rain Month”,”w59” “Rain Storm”, “w60” “Rain Year”, “w61” “Heat Index” and “w62” “Wind Chill”. You can name them anything you like.

Next we will create the “WeatherDevices.htx” template that WeatherLink uses to collect your weather data.
1. Open notepad or your favorite text editor and copy the following code:

HTML Code:
Sub Main()
    Dim strForecast
    strForecast = "<!--ForecastStr-->"          'Gathers forecast
     If hs.DeviceString("w48") <> strForecast Then           'Test w48 & new forecast for change
         Call hs.SetDeviceLastChange("w48", Now)          'Sets device w48 time of forecast change
         Call hs.SetDeviceString("w48", strForecast)          'Sets device w48 string to the current forecast
     End If

    Dim strTemp
    strTemp = "<!--outsideTemp-->°F"          'Gathers outside temperature
     If hs.DeviceString("w50") <> strTemp Then          'Test w50 & new temperature for change
         Call hs.SetDeviceLastChange("w50", Now)          'Sets device w50 time of temperature change
         Call hs.SetDeviceValue("w50", <!--outsideTemp-->)          'Sets device w50 value to the current temperature 
         Call hs.SetDeviceString("w50", strTemp)          'Sets device w50 string to the current temperature
    End If

    Call hs.SetDeviceValue("w51", <!--outsideHumidity-->)		'Sets device w51 value to outside humidity
    Call hs.SetDeviceString("w51", "<!--outsideHumidity-->%")          'Sets device w51 string to outside humidity

    Call hs.SetDeviceValue("w52", <!--barometer--> * 1000)          'See multiplier notes (* 1000)
    Call hs.SetDeviceString("w52", "<!--barometer-->in")

    Call hs.SetDeviceValue("w53", <!--windSpeed-->)
    Call hs.SetDeviceString("w53", "<!--windSpeed-->mph")

    Call hs.SetDeviceValue("w54", <!--windDir-->)          'windDir as degrees 0-359
    Call hs.SetDeviceString("w54", "<!--windDirection-->")          'windDirection as 16 point compass

    Call hs.SetDeviceValue("w55", <!--hiWindSpeed-->)
    Call hs.SetDeviceString("w55", "<!--hiWindSpeed-->mph")

    Call hs.SetDeviceValue("w56", <!--rainRate--> * 100)          'See multiplier notes (* 100)
    Call hs.SetDeviceString("w56", "<!--rainRate-->in/hr")

    Call hs.SetDeviceValue("w57", <!--dailyRain--> * 100)
    Call hs.SetDeviceString("w57", "<!--dailyRain-->in")

    Call hs.SetDeviceValue("w58", <!--stormRain--> * 100)
    Call hs.SetDeviceString("w58", "<!--stormRain-->in")

    Call hs.SetDeviceValue("w59", <!--monthlyRain--> * 100)
    Call hs.SetDeviceString("w59", "<!--monthlyRain-->in")

    Call hs.SetDeviceValue("w60", <!--totalRain--> * 100)
    Call hs.SetDeviceString("w60", "<!--totalRain-->in")

    strTemp = "<!--outsideHeatIndex-->°F"
     If hs.DeviceString("w61") <> strTemp Then
         Call hs.SetDeviceLastChange("w61", Now)
         Call hs.SetDeviceValue("w61", <!--outsideHeatIndex-->)
         Call hs.SetDeviceString("w61", strTemp)
    End If

    strTemp = "<!--windChill-->°F"
     If hs.DeviceString("w62") <> strTemp Then
         Call hs.SetDeviceLastChange("w62", Now)
         Call hs.SetDeviceValue("w62", <!--windChill-->)
         Call hs.SetDeviceString("w62", strTemp)
    End If
End Sub
2. Now save this file as “WeatherDevices.htx” in the templates folder of your weather station. Example: my default path is “C:\WeatherLink\Monticello\Templates” where “Moticello” is the name of my station.

Later you can modify this template when you have a better understanding of how the “weather tags” work in WeatherLink.
NOTE: See the WeatherLink help file for more information on “template files” and “WeatherLink HTML tags” Do a search in the WeatherLink help for the complete list of “WeatherLink HTML tags”, there are a bunch.

Now we will configure the WeatherLink internet connection to use the newly created template.

1. Click on the “setup” menu in WeatherLink and select “internet settings…” Here you will enter the path to your HomeSeer/scripts folder by clicking on “Internet Connection Settings” box. In the new window, click on “Connect through a local server” radio button (top left). Then click on the check box “Local Transfer Enabled” (lower left) and finally click the “Browse” button or enter the correct path in the text box (lower right) to your HomeSeer HS2 folder. This is where WeatherLink will store the dynamic script file used by the HomeSeer, “WeatherDevices.txt”. My local path is: C:\Program Files\HomeSeer HS2\. Click “OK”

2. You are now in the previous window. Click on “Configure” below the Profile 1.

3. The “Data Update Profile 1” window will open. Click on “Upload every” drop down box and select the frequency you want the data updated. I use “1 min.”, but you may use any of the listed time frequencies.

4. Click on the “Starting at” text box and type “12:03a”

5. Click on the button labeled “Select Template Files” to open the “Weather Template Files for Data Upload Profile 1” window.

6. Click the “ADD” button to open the “Select Files to upload” window. In this window you will select the template file “WeatherDevices.htx” we created above. We saved this file to “C:\WeatherLink\your station name\Templates” folder. After you have highlighted your template file, click “Open”

7. You will be back at the “Weather Template Files for Data Upload Profile 1” window. In the text box “Select an optional sub-directory to upload these files to:” type “Scripts\” (no quotes). This step will place the dynamic script in the HomeSeer/Scripts folder and the following step will convert the “WeatherDevices.htx” to a script “weatherDevices.txt” file. Now in the text box “Extension of converted “htx” Template Files” type “txt” (no quotes) and click “OK”

8. Click “OK” again to close the “Data Update Profile 1” window.

9. Click “OK” again to close the “Internet Connection Settings” window.

You have now completed the WeatherLink configuration and the newly created “WeatherDevices.txt” file should start to populate the HomeSeer HS2/script folder. We will now create the HomeSeer event to store this data in your weather devices.

The final step, in HomeSeer create a recurring event (every 1 minute) named “Weather Updater” and the action is “Run Script”. Select the existing “WeatherDevices.txt” script. If you don’t see this script check steps 1 through 9 above.

IMPORTANT: Please remember that if you wish to make changes to the dynamic script “WeatherDevices.txt” you must do so in the “WeatherDevices.htx” template found in your “C:\WeatherLink\your station name\Templates” folder. I have also found that anytime I edit the template file, I have to restart the profile or the weather data will not update. Simply click on the “setup” menu in WeatherLink and select “internet settings…”. Click on “Configure” below the Profile 1 and click on “Select Template Files” to open the “Weather Template Files for Data Upload Profile 1” window and then finally remove and re-add the “WeatherDevices.htx” template file. Click “OK” until you are out of the internet setup.

One final note about the multiplier: HomeSeer automatically rounds off numbers after the decimal point for the “Device Value”. This is a basic function of HomeSeer. “Device Strings” however are displayed exactly as you would expect. Many new HomeSeer users are often confused by the differences of “Device Strings”, “Device Values” and “Device Status”. Each is unique and different in it’s own way. In the above template/script, “WeatherDevices.htx” we deal with only the “Device Value” and “Device String” and do not use the “Device Status”. Because the “Device Value” is how our conditions and triggers activate events in HomeSeer, this can be problematic when trying to use conditions in your events. For example: The “Device String” 71.6°F equals the “Device Value” of 72 and the “Device String” 71.4°F equals the “Device Value” of 71. Not such a problem for temperature, but in the case of rainfall, where the “Device String” is 0.41 inches of rain the “Device Value” is actually equal to 0 and where the “Device String” is 0.51 inches of rain the “Device Value” is actually equal to 1. Therefore, conditions and triggers will not activate an event until the rainfall is actually above 0.50 inches of rain. In this example a multiplier of 100 is added to the script to adjust the “Device Value” so that tenths and hundredths of an inch of rain can be used in your conditions and triggers. It would then be understood that “Device String” 1.01 inch of rain would have the “Device Value” of 101. The same would hold true for barometric pressure, except we use a multiplier of 1000 to correct the “Device Value”. The “Device String” for a barometric pressure of 30.022in would then have a “Device Value” of 30022 and you could trigger an event off of small changes in barometric pressure.

Your feedback is welcome! If you have any questions, feel free to post here and I will try to answer ASAP.
-Rick

I would also like to thank our son, Dale (the code writing genius) for his help!

Last edited by HiTech; May 29th, 2011 at 05:52 PM. Reason: clairification
Reply With Quote
Reply

Tags
davis, forecast, vantage pro, weather data, weatherlink

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 06:10 AM.


Copyright 1998-2011 HomeSeer Technologies, LLC