Announcement

Collapse
No announcement yet.

Monitor Rain Fall

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Monitor Rain Fall

    Hi,

    Is there a way to monitor the total amount of rain fall within a determined amount of days and use that value to trigger an event in HS3?

    The reason I ask is I want to use the this value to determine whether or not to run my irrigation system. If I can record or calculate the total rain fall in a four day period. I can choose which watering cycle to use (if any).

    Thanks

    #2
    Here's a script I wrote that will maintain that number in an ini file and also provides a virtual device with the value being the number of inches of rain and the string being something like ".25 in. since 5/13/2017". The script uses the "Rain Today" info from WeatherXML. Since this is a "running total" of the amount of rainfall during a day, and is reset to zero by NWS at midnight, you only have to run the script once a day. I suggest 11:58 pm. Note that you should have WXML do a current conditions update just before you run this script so that you get the latest info from NWS.

    The script also contains a second subroutine called "Reset". This just resets the ini file value to zero and the "reset date" to the date it is run. In your case, you could have your irrigation script do the reset whenever you run the sprinklers. The ini file is shared with another script I wrote for capturing the high/low info from WXML. If you don't need that info, then you can use a text editor to remove the extra sections from the ini file. [Or you can just ignore them. Having them there but unused does no harm.] Rename the ini file to end with .ini.

    Installation instructions are in the script. Be sure to update the device references in both subroutines!
    Code:
    ' Store Rain since last reset in an ini file as well as HS Device
    ' Written by ITguyHS - 5/13/2017
    ' 
    ' User configuration notes:
    '   Name the script to end with .vb
    '   Create a virtual device to hold the value of "total rain since reset"
    '   Look in the User Configuration section below for "total rain device" and 
    '   change the device reference to that of your device
    '   Find the device reference for the WeatherXML device for "Rain today" and 
    '   place it in the user configuration section.
    '   Place the ini file in the Homeseer "config" folder
    '   Create an event that will run the Main sub of this script at 11:55 pm 
    '   (this is because NWS resets the "rain today" at midnight
    '   Create an event that will run on dates of your choice or on-demand to run
    '   the Reset sub of this script at to reset the total rain to zero and set the
    '   last-reset date 
    '==================================================================================
    
    Sub Main(ByVal Parms as object)
    
    Dim currentrain as double
    
    Dim totalrain as string
    Dim totalrainc as string
    dim totalrainstring as string
    Dim totalraindate as string
    
    Dim Speak as string
    Dim checkcase as boolean
    
    Dim WxmlRainDevRef as integer
    Dim TotalRainDevRef as Integer
    
    
    hs.writelog("Weather Data", "Rain_since_reset.vb is running") 
    
    ' ------------------------------------------------------------------------
    ' -------------------- User Configuration starts Here --------------------
    ' ------------------------------------------------------------------------
    
    ' INSTALLATION:  
    
    ' As this script pulls the information from WeatherXML devices you already
    ' have, No Internet bandwith is used, nor do you need to be online to run this script.
    '
    ' This script should be placed in the Homeseer "scripts" folder.
    '
    ' Copy the StoreWeatherData.ini file into the Homeseer "config" folder
    '   The ini file is shared with script StoreWeatherData.vb and is used to store the values for record highs and lows
    '   as well as the total rain since reset from this script
    '
    
    ' Change the following line to the HS device references for your WeatherXML device.
    '   Use the "weather Current" devices, not the "HSTouch Current" or "HSTouch Forecast"
    
    	WxmlRainDevRef = 264            'for the WXML device "Rain today"
    
    ' Change the following line to the HS device reference you'll use for display.
    ' If you have not yet created your virtual device for this item, go do that first,
    ' then return here to enter the device references.
    
    	TotalRainDevRef = 281
    
    ' ------------------------------------------------------------------------    
    ' --------------------- User Configuration ends Here ---------------------
    ' ------------------------------------------------------------------------  
    
    ' ------------------------------------------------------------------------    
    ' --------------------- Retrieve current value from WXML ----------------
    ' ------------------------------------------------------------------------ 
    
    	If hs.DeviceExistsRef(WxmlRainDevRef) then                'Make sure the device exists
            	currentrain = hs.DeviceValueEx(WxmlRainDevRef)      'get the current "rain today" value
    		If currentrain < 0 then
    			currentrain = 0
    		End If
    	End If
    
            checkcase = IsNumeric(currentrain)
            if checkcase = False then
    		hs.writelogex("Weather Error", "Weather Data current rain value is not numeric", "#008000")
                    hs.speak(" I am sorry I could not find numerical data for current rain.", True, "")
                    hs.speak(" Please check your device reference setting in the script.", True, "")
            end if
    '------------------------------------------------------------------------
    ' if current rain is zero, exit the script
    	if currentrain = 0
    		hs.writelogex("Weather Data", "Weather Data rain-today value is zero - exiting", "#008000")
    		exit sub
    	end if
    '------------------------------------------------------------------------
    
    ' Read current Total value from the ini file. 
    
    	totalrain = hs.GetINISetting("RainData", "TotalRain", "", "StoreWeatherData.ini")
    	totalrainc = totalrain.trim()
    
    
    ' Now lets calc the new total and write new value to the file.
    
    	hs.writelogex("Weather Debug", "Current rain: " & currentrain & "  Total rain: " & totalrainc, "#008000")
    
    	totalrain = totalrain + currentrain
    
    	hs.SaveINISetting("RainData", "TotalRain", totalrain, "StoreWeatherData.ini")
    
    '--------------------------------------------------------------------------------------
     ' The following lines will pull the current Total Rain Value from the ini file, and keep the
     ' HS Device up to date, even if for some reason the device loses its value.
    
    
    	totalrain = hs.GetINISetting("RainData", "TotalRain", "", "StoreWeatherData.ini") 
    	totalraindate = hs.GetINISetting("RainData", "TotalRainResetDate", "", "StoreWeatherData.ini")
    	totalrainstring = totalrain & " in.  since  " & totalraindate
            hs.setDeviceString(TotalRainDevRef,totalrainstring,True)
            hs.setDeviceValueByRef(TotalRainDevRef,totalrain,True)
    
    	hs.writelog("Weather Data", "Rain_since_reset.vb completed normally") 
    
    end sub
    
    '==========================================================================
    
    Sub Reset(ByVal Parms as object)
    
    
    Dim totalrain as string
    Dim totalrainc as string
    Dim totalrainstring as string
    Dim totalraindate as string
    
    Dim CurDate as Date = Now
    Dim TheDate as string
    
    Dim WxmlRainDevRef as integer
    Dim TotalRainDevRef as Integer
    
    hs.writelog("Weather Data", "RESET of Rain_since_reset is running") 
    
    ' ------------------------------------------------------------------------
    ' -------------------- User Configuration starts Here --------------------
    ' ------------------------------------------------------------------------
    
    ' INSTALLATION:  
    
    ' This script should be placed in the Homeseer "scripts" folder.
    
    ' Change the following line to the HS device reference you'll use for display.
    ' If you have not yet created your virtual device for this item, go do that first,
    ' then return here to enter the device references.
    
    	TotalRainDevRef = 281
    
    ' ------------------------------------------------------------------------    
    ' --------------------- User Configuration ends Here ---------------------
    ' ------------------------------------------------------------------------  
    
    ' Get the current system Date to write to the file 
    
    	TheDate = CurDate.ToShortDateString()
    
    ' Reset the ini file record for Total Rain to zero
    	hs.SaveINISetting("RainData", "TotalRain", "0", "StoreWeatherData.ini")
    ' Set the ini file record for Total Rain Reset Date to the current date
    	hs.SaveINISetting("RainData", "TotalRainResetDate", TheDate, "StoreWeatherData.ini")
    '--------------------------------------------------------------------------------------
     ' The following lines will pull the current Total Rain Value from the ini file, and reset the
     ' HS Device.
    
    	totalrain = hs.GetINISetting("RainData", "TotalRain", "", "StoreWeatherData.ini") 
    	totalraindate = hs.GetINISetting("RainData", "TotalRainResetDate", "", "StoreWeatherData.ini")
    	totalrainstring = totalrain & " in.  since  " & totalraindate
            hs.setDeviceString(TotalRainDevRef,totalrainstring,True)
            hs.setDeviceValueByRef(TotalRainDevRef,totalrain,True)
    
    	hs.writelog("Weather Data", "RESET of Rain_since_reset completed") 
    
    end sub
    Attached Files
    Last edited by ITguyHS; May 15, 2017, 02:14 PM. Reason: Attach ini file
    Fred

    HomeSeer Pro 3.0.0.548, HS3Touch, Zwave 3.0.1.252, Envisalink DSC 3.0.0.40, WeatherXML, Z-stick, HS phone, Way2Call

    Comment


      #3
      This is Perfect! Thank you.

      I will try it out and let you know how things go

      Comment


        #4
        Hi,

        One quick question: Is there a way to trigger an update for the current conditions? In my settings, I have the schedule set for every ten minute to do an update, but is there a way to force an update automatically? in the schedule tab there's a "Run Now" tile to force an update

        Comment


          #5
          There is an option in the events to trigger an update.
          When you setup the HS event action, select weatherXML Actions. In the second dropdown select Update Location.
          You will then get a dropdown to select which location and which data type.
          Select Current for the Type.

          You can then set any of the normal actions to trigger this event.
          --
          Jeff Farmer
          HS 3, HSPhone
          My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
          Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

          Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

          Comment


            #6
            Cumulative rainfall is a good idea, but how about also being able to get the forecast rainfall? "If its going to rain .3" Monday, there is no need to run the sprinklers Monday morning, or maybe even cancel Sundays cycle". This way we can also be proactive in controlling irrigation,and not only reactive. I see the forecast amount on the web page (attached image). How can I get forecast rainfall from the plugin? Is it there and I just can't find it? or can it be added?

            Thanks
            Attached Files

            Comment


              #7
              To get the forecast data go to the HSTouch tab in weatherXML. Select the rain devices for the forecast days that you want. The value will get stored in a HS device and can be used as a condition for your events. I am on my phone right now but will check back when I get home and can post some images if you want.
              --
              Jeff Farmer
              HS 3, HSPhone
              My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
              Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

              Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

              Comment


                #8
                Thanks for the very prompt response. I do recall trying that, but I thought it created the forecast devices with % chance of precip, not amount in inches. I just rechecked and that is in fact the case. I was hoping for the value in inches
                Attached Files

                Comment


                  #9
                  I checked the xml file and I can get inches for the forecast with Weather Underground.

                  I have a new version of weatherXML that I need to release as a beta. It has some big changes in it. I will try to get it posted this weekend. Once it comes out of beta I will start working on adding new stuff.

                  We just moved and the new house has an irrigation system so I am interested in adding things that can help control it.
                  --
                  Jeff Farmer
                  HS 3, HSPhone
                  My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
                  Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

                  Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

                  Comment


                    #10
                    Originally posted by huntley1 View Post
                    This is Perfect! Thank you.

                    I will try it out and let you know how things go
                    I am using a Cumulus Evapotranspiration today value to subtract from my evaporation total.
                    When it has been raining, it will add the rain value.
                    Also when my irrigation is running it will add 1 mm/minute to the value.
                    When the value is 0 and no rain forecast for next day, irrigation will be activated at a fixed time.
                    Have it running now for a few years and is working perfect.
                    Before I bought the new weather station, I made an evaporation calculation with temperature, sunshine, wind and rain every day.
                    Peter

                    http://ohh.pcgsm.nl

                    Comment


                      #11
                      Excellent. Thanks.

                      Congratulations on the new house.

                      Comment


                        #12
                        Originally posted by CFGuy View Post
                        I checked the xml file and I can get inches for the forecast with Weather Underground.

                        I have a new version of weatherXML that I need to release as a beta. It has some big changes in it. I will try to get it posted this weekend. Once it comes out of beta I will start working on adding new stuff.

                        We just moved and the new house has an irrigation system so I am interested in adding things that can help control it.


                        I am doing a custom pull of the forecast rain 'qpf' field from the XML from my local WU personal weather station. Would love to retire my ugly script for a supported weatherXML field.
                        cheeryfool

                        Comment


                          #13
                          The qpf is what I am planning on using.

                          qpf_day and qpf_night will be separate devices.

                          I was busy unpacking some boxes this past weekend. I will try to get the beta version posted tonight.
                          Just remember, it is very important that you back up your HS directory. It won't mess up HS but could mess up the weatherXML devices. I am going to track devices by Technology Address instead of trying to keep things synced in an ini file. Unfortunately for long term weatherXML users, the address wasn't always created correctly. I have added code that fixes them. I have tested this on my install but you may have to re-create some devices.
                          --
                          Jeff Farmer
                          HS 3, HSPhone
                          My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
                          Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

                          Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

                          Comment


                            #14
                            Originally posted by CFGuy View Post
                            The qpf is what I am planning on using.

                            qpf_day and qpf_night will be separate devices.

                            I was busy unpacking some boxes this past weekend. I will try to get the beta version posted tonight.
                            Just remember, it is very important that you back up your HS directory. It won't mess up HS but could mess up the weatherXML devices. I am going to track devices by Technology Address instead of trying to keep things synced in an ini file. Unfortunately for long term weatherXML users, the address wasn't always created correctly. I have added code that fixes them. I have tested this on my install but you may have to re-create some devices.
                            Cool. Are you proposing just to pull the nearest periods or multiple day's worth of forecast data? I see that qpf_day, qpf_night and qpf_allday go out 6 days on my local PWS. I don't think I would look at more than 2 days, possibly just one, but some people might want to look further out.
                            cheeryfool

                            Comment


                              #15
                              I plan on setting it similar to the other devices. You would go to the HSTouch tab and select which of the forecast days / nights that you want the data saved to a device. It will create a device for each of the forecast days and save the forecasted amount in the device value.
                              --
                              Jeff Farmer
                              HS 3, HSPhone
                              My HS3 Plugins: CFHSExtras, Random, Restart, Tracker, WeatherXML, PanaBluRay
                              Other Plugins In Use: APCUPSD, BLOnkyo, Device History, EasyTrigger, HSTouch Server, PHLocation2, Pushover, RFXCom, UltraGCIR3, UltraMon3, UltraPioneerAVR3, X10, Z-Wave

                              Hardware: GoControl Irrigation Controler, Schlage Lever Lock, Schlage Deadbolt, Way2Call Hi-Phone, RFXCom RFXrec433 Receiver, WGL 800, TI-103, Z-Net, Pioneer 1120, Pioneer 1021, Pioneer LX302, Panasonic BDT-110, Panasonic BDT-210 x2

                              Comment

                              Working...
                              X