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!