Announcement

Collapse
No announcement yet.

Syntax for running script in Homeseer from Allonis MyServer

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

    Syntax for running script in Homeseer from Allonis MyServer

    I am trying to figure out the syntax for running scripts in Myserver. The command builder shows all of the sections of the command as dropdowns but doesn't construct the command at the bottom.

    I tried this:

    BLML2HS|HS-Runex:etherrain.vb~runCycle~EtherRain.8; pw; 0;0;0;0;0;0;0;0

    and this:

    BLML2HS|HS-Runex~etherrain.vb~runCycle~EtherRain.8; pw; 0;0;0;0;0;0;0;0

    But nothing works. I want to pass variables to the script from MyServer otherwise I would just put the script in an event and run the event.

    I looked around for any documentation but wasn't able to find anything. Thanks for any help.

    Click image for larger version

Name:	Screen Shot 2020-07-01 at 5.16.13 PM.png
Views:	38
Size:	165.9 KB
ID:	1398169

    #2
    You would need to do this:

    Code:
    BLML2HS|HS-Runex~etherrain.vb~runCycle~EtherRain.8;pw;0;0;0;0;0;0;0;0
    Then in your script you would need to split that parameter by a semicolon

    Code:
    Public Sub runCycle(ByVal parms As String)
        Dim splitArray As String() = parms.Trim.Split(";")
        If splitArray.Length > 0 Then
            For Each parm As String In splitArray
                If parm IsNot Nothing Then
    
    *** do whatever you want with the parms ***
    
                End If
            Next
        End If
        splitArray = Nothing
    End Sub
    Cheers,
    Bob
    Web site | Help Desk | Feature Requests | Message Board

    Comment


      #3
      Thanks. One more related question. What is the syntax for calling MyServer from a script in HS3? Specifically I want to use the command SetVariable.

      Comment


        #4
        You could try this:

        Code:
        hs.PluginFunction("BLML2HS", "", "MLServeCmd", {"Macro|SetVariable|my_variable1~hi!SetVariable|my_variable2~there"})
        Cheers,
        Bob
        Web site | Help Desk | Feature Requests | Message Board

        Comment


          #5
          Thanks for the response. I am trying to use this in a vbscript .vbs file and it doesn't seem to work. This an extensive script that I had running on HS2 and I would rather note convert to vb. Is there a syntax that would work in .vbs? I have tried all of the logical versions I can think of. Thanks for your help.

          Comment


            #6
            I would convert it to .vb as vbs is very old
            Post the script and I will have a look at it for you
            Cheers,
            Bob
            Web site | Help Desk | Feature Requests | Message Board

            Comment


              #7
              I am in the process of converting some legacy HS2 scripts over to HS3. I have been keeping HS2 running for a number of functions that were low priority to switch. Here are the two scripts I am working on - controlling my sprinklers. Thanks for offering to help - if you want to provide some pointers on things I need to be addressing that would help. I am self-taught on vb so looking to use this as a learning experience.

              Code:
              sub Sprinkler(parms)
              
              Dim result
              Dim temp
              Dim data1
              Dim data2
              Dim hParm
              dim Program1Zone1Length, Program2Zone1Length, Program3Zone1Length, Program4Zone1Length, Program5Zone1Length, Program6Zone1Length, Program1TotalLength
              dim Program1StartTime
              dim RainSensor, ManualMode
              dim command
              
              'Called by:
              '
              ' Two parameters:
              ' data1 - Command 1
              ' data2 - Command 2
              
              
              
              hParm = split(parms,";")
              data1 = hParm(0) '
              data2 = hParm(1)
              
              hs.writelog "Sprinkler", "+++++++++++++++++++++++++++++++++++ SPRINKLER START +++++++++++++++++++++++++++++++++++ "
              hs.writelog "sprinkler.vbs", "-> Parameters - " & script & " with data1 - " & data1 & " and data2 - " & data2
              
              
              ' Retrieve variables
              CurrentProgramZone1Length = hs.devicestring("1350")
              CurrentProgramZone2Length = hs.devicestring("1351")
              CurrentProgramZone3Length = hs.devicestring("1352")
              CurrentProgramZone4Length = hs.devicestring("1353")
              CurrentProgramZone5Length = hs.devicestring("1354")
              CurrentProgramZone6Length = hs.devicestring("1355")
              Program1Zone1Length = hs.devicestring("1356")
              Program1Zone2Length = hs.devicestring("1357")
              Program1Zone3Length = hs.devicestring("1358")
              Program1Zone4Length = hs.devicestring("1359")
              Program1Zone5Length = hs.devicestring("1360")
              Program1Zone6Length = hs.devicestring("1361")
              Program2Zone1Length = hs.devicestring("1362")
              Program2Zone2Length = hs.devicestring("1363")
              Program2Zone3Length = hs.devicestring("1364")
              Program2Zone4Length = hs.devicestring("1365")
              Program2Zone5Length = hs.devicestring("1366")
              Program2Zone6Length = hs.devicestring("1367")
              Program3Zone1Length = hs.devicestring("1368")
              Program3Zone2Length = hs.devicestring("1369")
              Program3Zone3Length = hs.devicestring("1370")
              Program3Zone4Length = hs.devicestring("1371")
              Program3Zone5Length = hs.devicestring("1372")
              Program3Zone6Length = hs.devicestring("1373")
              Program1StartTime = hs.devicestring("1374")
              Program1EndTime = hs.devicestring("1377")
              Program2StartTime = hs.devicestring("1375")
              Program2EndTime = hs.devicestring("1378")
              Program3StartTime = hs.devicestring("1376")
              Program3EndTime = hs.devicestring("1379")
              TimeInterval5 = hs.devicevalue("1380")
              TimeInterval15 = hs.devicevalue("1381")
              TimeInterval60 = hs.devicevalue("1382")
              RainSensor = hs.devicevalue("1341")
              ManualMode = hs.devicevalue("1383")
              
              
              'hs.writelog "Sprinkler", "TimeInterval5 = " & TimeInterval5
              'hs.writelog "Sprinkler", "TimeInterval15 = " & TimeInterval15
              'hs.writelog "Sprinkler", "TimeInterval60 = " & TimeInterval60
              
              
              
              select case data1
              case "RESET"
              select case data2
              case "ALL"
              ' Reset all zones to defaults - used only if homeseer variables get wiped out
              
              ' Test script command
              ' hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~3~NoRepeat~" & Program1Zone1Length & "~minutes~sprinklerzone1done~off"
              'hs.Plugin("BLML2HS", "", "MLServeCmd", new Object(){"SetTimer~3~NoRepeat~" & Program1Zone1Length & "~minutes~sprinklerzone1done~off"})
              
              'hs.PluginFunction("BLML2HS", "", "MLServeCmd", {"Macro|SetVariable|my_variable1~hi!SetVariable|my_variable2 ~there"})
              'level = hs.PluginFunction("Z-Wave", "", "AccessLevel", nothing)
              
              ' hs.PluginFunction("Plugin Name","","Function",New Object(){"paramater1","parameter2","parameter3"})
              
              result = nhs.PluginFunction ("BLML2HS", "", "MLServeCmd", {"Macro|SetVariable|my_variable1_test~hi!SetVariable|my_vari able2_test~there"})
              
              ' hs.SetDeviceString "1356", Program1Zone1Length, True
              hs.writelog "SPRINKLER", "Resetting all variables"
              
              ' Program 1
              hs.setdevicestring("1356"), 40, True
              hs.setdevicestring("1357"), 40, True
              hs.setdevicestring("1358"), 40, True
              hs.setdevicestring("1359"), 40, True
              hs.setdevicestring("1360"), 25, True
              hs.setdevicestring("1361"), 25, True
              hs.setdevicestring("2713"), 210, True
              ' Program 2
              hs.setdevicestring("1362"), 40, True
              hs.setdevicestring("1363"), 40, True
              hs.setdevicestring("1364"), 40, True
              hs.setdevicestring("1365"), 40, True
              hs.setdevicestring("1366"), 0, True
              hs.setdevicestring("1367"), 0, True
              hs.setdeviceString("2714"), 160, True
              ' Program 3
              hs.setdevicestring("1368"), 0, True
              hs.setdevicestring("1369"), 0, True
              hs.setdevicestring("1370"), 0, True
              hs.setdevicestring("1371"), 0, True
              hs.setdevicestring("1372"), 25, True
              hs.setdevicestring("1373"), 25, True
              hs.setdevicestring("2715"), 50, True
              ' Program 4
              hs.setdevicestring("2728"), 20, True
              hs.setdevicestring("2729"), 20, True
              hs.setdevicestring("2730"), 20, True
              hs.setdevicestring("2731"), 20, True
              hs.setdevicestring("2732"), 20, True
              hs.setdevicestring("2733"), 20, True
              hs.setdevicestring("2734"), 120, True
              
              hs.setdevicestring("1374"), "03:00:00 AM", True
              hs.setdevicestring("1377"), "06:40:00 AM", True
              hs.setdevicestring("1375"), "03:00:00 AM", True
              hs.setdevicestring("1378"), "05:40:00 AM", True
              hs.setdevicestring("1376"), "03:00:00 AM", True
              hs.setdevicestring("1379"), "03:50:00 AM", True
              hs.setdevicestring("2735"), "03:50:00 AM", True
              
              
              hs.SetDeviceValueByRef 1381, 100, True
              hs.SetDeviceValueByRef 1382, 0, True
              hs.SetDeviceValueByRef 2738, 100, True
              
              end select
              case "PROGRAM"
              select case data2
              case "1"
              ' Program Name - Full Cycle
              ' This sets up all of the parameters for Program 1 and starts Zone 1. Subsequent zones will be called when the zones end.
              hs.writelog "Sprinkler", "******************** Starting Sprinkler Program Full Cycle *****************************"
              if RainSensor = 2 then
              status_string = now & " - Rain Sensor is On so Automatic Program not Started"
              hs.writelog "Sprinkler", "******************** Stopped Sprinkler Program 1 Full Cycle - Rain *****************************"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "1349", status_string, True
              ' I disabled the following log update because it was updating everytime the sprinkler program ran
              'Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
              'filetxt.WriteLine(status_string)
              'filetxt.Close
              else
              ' Setting CurrentProgramZoneLength variables with values found in Program1Zone1Length variables
              hs.SetDeviceString "1350", Program1Zone1Length, True
              hs.SetDeviceString "1351", Program1Zone2Length, True
              hs.SetDeviceString "1352", Program1Zone3Length, True
              hs.SetDeviceString "1353", Program1Zone4Length, True
              hs.SetDeviceString "1354", Program1Zone5Length, True
              hs.SetDeviceString "1355", Program1Zone6Length, True
              hs.SetDeviceString "2726", CurrentProgramTotalLength, True
              
              CurrentProgramTotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              
              ' Setting all zone status variables to off - probably not necessary as they should be off
              ' - but if a program is loaded when another program is running this will take care of it
              ' - this will trigger events for each of these zones to send off commands to CStar through sprinkler2.vbs
              ' - this is problematic - sending off to any specific zone causes sprinkler2.vbs to cascade to the next zone - will comment and need to check
              REM hs.SetDeviceString "2706", "Off", True
              REM hs.SetDeviceValue "Q3", 3
              REM hs.SetDeviceString "2707", "Off", True
              REM hs.SetDeviceValue "Q4", 3
              REM hs.SetDeviceString "2708", "Off", True
              REM hs.SetDeviceValue "Q5", 3
              REM hs.SetDeviceString "2709", "Off", True
              REM hs.SetDeviceValue "Q6", 3
              REM hs.SetDeviceString "2710", "Off", True
              REM hs.SetDeviceValue "Q7", 3
              REM hs.SetDeviceString "2711", "Off", True
              REM hs.SetDeviceValue "Q8", 3
              
              ' Setting information variables
              hs.SetDeviceString "2727", "Running", True
              hs.SetDeviceString "2712", "Program 1 - Full Cycle", True
              
              ' Set timers for all zones in MainLobby
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~3~NoRepeat~" & Program1Zone1Length & "~minutes~sprinklerzone1done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~4~NoRepeat~" & Program1Zone2Length & "~minutes~sprinklerzone2done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~5~NoRepeat~" & Program1Zone3Length & "~minutes~sprinklerzone3done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~6~NoRepeat~" & Program1Zone4Length & "~minutes~sprinklerzone4done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~7~NoRepeat~" & Program1Zone5Length & "~minutes~sprinklerzone5done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~8~NoRepeat~" & Program1Zone6Length & "~minutes~sprinklerzone6done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & CurrentProgramTotalLength & "~minutes~sprinklertotaldone~off"
              
              ' Start timer for all zones
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|Enable~9"
              
              ' Turn on first zone to start cascade
              ' This in turn will trigger the event to call sprinkler2.vbs and turn on this zone
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE1;ON;SPRINKLER.VBS")
              'hs.SetDeviceString "2706", "On", True
              'hs.SetDeviceValue "Q3", 2
              ' Call Etherrain with all variables
              hs.writelog "sprinkler", "Calling etherrain with zone1 : " & cint(Program1Zone1Length) & " zone2 : " & Program1Zone2Length & " zone 3 : " & Program1Zone3Length & " zone 4 : " & Program1Zone5Length & " zone 5 : " & Program1Zone5Length & " zone 6 : " & Program1Zone6Length
              ' Issue etherrain command
              command = cint(Program1Zone1Length) & ";" & Program1Zone2Length & ";" & Program1Zone3Length & ";" & Program1Zone4Length & ";" & Program1Zone5Length & ";" & Program1Zone6Length & ";0;0"
              'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
              error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw;" & command,False,False)
              end if
              case "2"
              ' This sets up all of the parameters for Program 2 and starts Zone 1. Subsequent zones will be sprinkled when the zones end.
              hs.writelog "Sprinkler", "******************** Starting Sprinkler Program Front Garden *****************************"
              if RainSensor = 2 then
              status_string = now & " - Rain Sensor is On so Automatic Program not Started"
              hs.writelog "Sprinkler", "******************** Stopped Sprinkler Program 2 Front Garden - Rain *****************************"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "1349", status_string, True
              ' I disabled the following log update because it was updating everytime the sprinkler program ran
              'Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
              'filetxt.WriteLine(status_string)
              'filetxt.Close
              else
              ' Turn on Sprinkler Controller Main Switch and Master valve
              ' hs.SendToComPort 4, "SPRINKLER=MAINON" & vbCR
              ' hs.SendToComPort 4, "SPRINKMASTVAL0" & vbCR
              
              CurrentProgramTotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              
              hs.SetDeviceString "2727", "Running", True
              hs.SetDeviceString "2712", "Program 2 - Front Garden", True
              hs.SetDeviceString "1350", Program2Zone1Length, True
              hs.SetDeviceString "1351", Program2Zone2Length, True
              hs.SetDeviceString "1352", Program2Zone3Length, True
              hs.SetDeviceString "1353", Program2Zone4Length, True
              hs.SetDeviceString "1354", Program2Zone5Length, True
              hs.SetDeviceString "1355", Program2Zone6Length, True
              hs.SetDeviceString "2726", CurrentProgramTotalLength, True
              
              REM hs.SetDeviceString "2706", "Off", True
              REM hs.SetDeviceValue "Q3", 3
              REM hs.SetDeviceString "2707", "Off", True
              REM hs.SetDeviceValue "Q4", 3
              REM hs.SetDeviceString "2708", "Off", True
              REM hs.SetDeviceValue "Q5", 3
              REM hs.SetDeviceString "2709", "Off", True
              REM hs.SetDeviceValue "Q6", 3
              REM hs.SetDeviceString "2710", "Off", True
              REM hs.SetDeviceValue "Q7", 3
              REM hs.SetDeviceString "2711", "Off", True
              REM hs.SetDeviceValue "Q8", 3
              
              ' Set timers for all zones
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~3~NoRepeat~" & Program2Zone1Length & "~minutes~sprinklerzone1done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~4~NoRepeat~" & Program2Zone2Length & "~minutes~sprinklerzone2done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~5~NoRepeat~" & Program2Zone3Length & "~minutes~sprinklerzone3done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~6~NoRepeat~" & Program2Zone4Length & "~minutes~sprinklerzone4done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~7~NoRepeat~" & Program2Zone5Length & "~minutes~sprinklerzone5done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~8~NoRepeat~" & Program2Zone6Length & "~minutes~sprinklerzone6done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & CurrentProgramTotalLength & "~minutes~sprinklertotaldone~off"
              
              ' Start timer for all zones
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|Enable~9"
              
              ' Turn on first zone to start cascade
              hs.SetDeviceString "2706", "On", True
              hs.SetDeviceValue "Q3", 2
              
              ' Issue Etherrain command
              command = cint(Program2Zone1Length) & ";" & Program2Zone2Length & ";" & Program2Zone3Length & ";" & Program2Zone4Length & ";" & Program2Zone5Length & ";" & Program2Zone6Length & ";0;0"
              'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
              error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw;" & command,False,False)
              
              
              end if
              case "3"
              ' This sets up all of the parameters for Program 3 and starts Zone 1. Subsequent zones will be called when the zones end.
              hs.writelog "Sprinkler", "******************** Starting Sprinkler Program Back Garden *****************************"
              if RainSensor = 2 then
              status_string = now & " - Rain Sensor is On so Automatic Program not Started"
              hs.writelog "Sprinkler", "******************** Stopped Sprinkler Program 3 Back Garden - Rain *****************************"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "1349", status_string, True
              ' I disabled the following log update because it was updating everytime the sprinkler program ran
              'Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
              'filetxt.WriteLine(status_string)
              'filetxt.Close
              else
              ' Turn on Sprinkler Controller Main Switch and Master valve
              ' hs.SendToComPort 4, "SPRINKLER=MAINON" & vbCR
              ' hs.SendToComPort 4, "SPRINKMASTVAL0" & vbCR
              
              CurrentProgramTotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              
              hs.SetDeviceString "2727", "Running", True
              hs.SetDeviceString "2712", "Program 3 - Back Garden", True
              hs.SetDeviceString "1350", Program3Zone1Length, True
              hs.SetDeviceString "1351", Program3Zone2Length, True
              hs.SetDeviceString "1352", Program3Zone3Length, True
              hs.SetDeviceString "1353", Program3Zone4Length, True
              hs.SetDeviceString "1354", Program3Zone5Length, True
              hs.SetDeviceString "1355", Program3Zone6Length, True
              hs.SetDeviceString "2726", CurrentProgramTotalLength, True
              
              REM hs.SetDeviceString "2706", "Off", True
              REM hs.SetDeviceValue "Q3", 3
              REM hs.SetDeviceString "2707", "Off", True
              REM hs.SetDeviceValue "Q4", 3
              REM hs.SetDeviceString "2708", "Off", True
              REM hs.SetDeviceValue "Q5", 3
              REM hs.SetDeviceString "2709", "Off", True
              REM hs.SetDeviceValue "Q6", 3
              REM hs.SetDeviceString "2710", "Off", True
              REM hs.SetDeviceValue "Q7", 3
              REM hs.SetDeviceString "2711", "Off", True
              REM hs.SetDeviceValue "Q8", 3
              
              ' Set timers for all zones
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~3~NoRepeat~" & Program3Zone1Length & "~minutes~sprinklerzone1done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~4~NoRepeat~" & Program3Zone2Length & "~minutes~sprinklerzone2done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~5~NoRepeat~" & Program3Zone3Length & "~minutes~sprinklerzone3done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~6~NoRepeat~" & Program3Zone4Length & "~minutes~sprinklerzone4done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~7~NoRepeat~" & Program3Zone5Length & "~minutes~sprinklerzone5done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~8~NoRepeat~" & Program3Zone6Length & "~minutes~sprinklerzone6done~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & CurrentProgramTotalLength & "~minutes~sprinklertotaldone~off"
              
              ' Start timer for all zones
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|Enable~9"
              
              ' Turn on first zone to start cascade
              hs.SetDeviceString "2706", "On", True
              hs.SetDeviceValue "Q3", 2
              
              ' Issue Etherrain command
              command = cint(Program3Zone1Length) & ";" & Program3Zone2Length & ";" & Program3Zone3Length & ";" & Program3Zone4Length & ";" & Program3Zone5Length & ";" & Program3Zone6Length & ";0;0"
              'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
              error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw;" & command,False,False)
              
              
              end if
              end select
              
              case "PROG1"
              ' Handle changes in start and end time of program
              CurrentProgramTotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              select case data2
              case "PRESET1"
              hs.SetDeviceString "1356", 40, True
              hs.SetDeviceString "1357", 40, True
              hs.SetDeviceString "1358", 40, True
              hs.SetDeviceString "1359", 40, True
              hs.SetDeviceString "1360", 25, True
              hs.SetDeviceString "1361", 25, True
              case "PRESET2"
              hs.SetDeviceString "1356", 1, True
              hs.SetDeviceString "1357", 1, True
              hs.SetDeviceString "1358", 1, True
              hs.SetDeviceString "1359", 1, True
              hs.SetDeviceString "1360", 1, True
              hs.SetDeviceString "1361", 1, True
              
              case "STARTDN"
              if TimeInterval5 = 2 then
              Program1StartTime=dateadd("n",-5,Program1StartTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              Program1EndTime = dateadd("n",+CurrentProgramTotalLength,Program1StartTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              elseif TimeInterval15 = 2 then
              Program1StartTime=dateadd("n",-15,Program1StartTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              Program1EndTime = dateadd("n",+CurrentProgramTotalLength,Program1StartTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              else
              Program1StartTime=dateadd("n",-60,Program1StartTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              Program1EndTime = dateadd("n",+CurrentProgramTotalLength,Program1StartTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              end if
              hs.SetDeviceString "1374", cstr(Program1StartTime), True
              hs.SetDeviceString "1377", Program1EndTime, True
              case "STARTUP"
              if TimeInterval5 = 2 then
              Program1StartTime=dateadd("n",+5,Program1StartTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              Program1EndTime = dateadd("n",+CurrentProgramTotalLength,Program1StartTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              elseif TimeInterval15 = 2 then
              hs.writelog "sprinkler", "Increasing Start time from : " & Program1StartTime
              Program1StartTime=dateadd("n",+15,Program1StartTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              Program1EndTime = dateadd("n",+CurrentProgramTotalLength,Program1StartTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              hs.writelog "sprinkler", "to : " & Program1StartTime
              else
              Program1StartTime=dateadd("n",+60,Program1StartTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              Program1EndTime = dateadd("n",+CurrentProgramTotalLength,Program1StartTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              end if
              hs.SetDeviceString "1374", Program1StartTime, True
              hs.SetDeviceString "1377", Program1EndTime, True
              case "ENDDN"
              if TimeInterval5 = 2 then
              Program1EndTime=dateadd("n",-5,Program1EndTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              Program1StartTime = dateadd("n",-CurrentProgramTotalLength,Program1EndTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              elseif TimeInterval15 = 2 then
              Program1EndTime=dateadd("n",-15,Program1EndTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              Program1StartTime = dateadd("n",-CurrentProgramTotalLength,Program1EndTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              else
              Program1EndTime=dateadd("n",-60,Program1EndTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              Program1StartTime = dateadd("n",-CurrentProgramTotalLength,Program1EndTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              end if
              hs.SetDeviceString "1374", Program1StartTime, True
              hs.SetDeviceString "1377", Program1EndTime, True
              case "ENDUP"
              if TimeInterval5 = 2 then
              Program1EndTime=dateadd("n",+5,Program1EndTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              Program1StartTime = dateadd("n",-CurrentProgramTotalLength,Program1EndTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              elseif TimeInterval15 = 2 then
              Program1EndTime=dateadd("n",+15,Program1EndTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              Program1StartTime = dateadd("n",-CurrentProgramTotalLength,Program1EndTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              else
              Program1EndTime=dateadd("n",+60,Program1EndTime)
              Program1EndTime = FormatDateTime(Program1EndTime, 3)
              Program1StartTime = dateadd("n",-CurrentProgramTotalLength,Program1EndTime)
              Program1StartTime = FormatDateTime(Program1StartTime, 3)
              end if
              hs.SetDeviceString "1374", Program1StartTime, True
              hs.SetDeviceString "1377", Program1EndTime, True
              end select
              
              case "PROG2"
              ' Handle changes in start and end time of program
              CurrentProgramTotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              select case data2
              case "PRESET1"
              hs.SetDeviceString "1362", 40, True
              hs.SetDeviceString "1363", 40, True
              hs.SetDeviceString "1364", 40, True
              hs.SetDeviceString "1365", 40, True
              hs.SetDeviceString "1366", 0, True
              hs.SetDeviceString "1367", 0, True
              case "PRESET2"
              hs.SetDeviceString "1362", 1, True
              hs.SetDeviceString "1363", 1, True
              hs.SetDeviceString "1364", 1, True
              hs.SetDeviceString "1365", 1, True
              hs.SetDeviceString "1366", 0, True
              hs.SetDeviceString "1367", 0, True
              
              
              case "STARTDN"
              if TimeInterval5 = 2 then
              Program2StartTime=dateadd("n",-5,Program2StartTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              Program2EndTime = dateadd("n",+CurrentProgramTotalLength,Program2StartTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              elseif TimeInterval15 = 2 then
              Program2StartTime=dateadd("n",-15,Program2StartTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              Program2EndTime = dateadd("n",+CurrentProgramTotalLength,Program2StartTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              else
              Program2StartTime=dateadd("n",-60,Program2StartTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              Program2EndTime = dateadd("n",+CurrentProgramTotalLength,Program2StartTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              end if
              hs.SetDeviceString "1375", cstr(Program2StartTime), True
              hs.SetDeviceString "1378", Program2EndTime, True
              case "STARTUP"
              if TimeInterval5 = 2 then
              Program2StartTime=dateadd("n",+5,Program2StartTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              Program2EndTime = dateadd("n",+CurrentProgramTotalLength,Program2StartTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              elseif TimeInterval15 = 2 then
              Program2StartTime=dateadd("n",+15,Program2StartTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              Program2EndTime = dateadd("n",+CurrentProgramTotalLength,Program2StartTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              else
              Program2StartTime=dateadd("n",+60,Program2StartTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              Program2EndTime = dateadd("n",+CurrentProgramTotalLength,Program2StartTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              end if
              hs.SetDeviceString "1375", Program2StartTime, True
              hs.SetDeviceString "1378", Program2EndTime, True
              case "ENDDN"
              if TimeInterval5 = 2 then
              Program2EndTime=dateadd("n",-5,Program2EndTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              Program2StartTime = dateadd("n",-CurrentProgramTotalLength,Program2EndTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              elseif TimeInterval15 = 2 then
              Program2EndTime=dateadd("n",-15,Program2EndTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              Program2StartTime = dateadd("n",-CurrentProgramTotalLength,Program2EndTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              else
              Program2EndTime=dateadd("n",-60,Program2EndTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              Program2StartTime = dateadd("n",-CurrentProgramTotalLength,Program2EndTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              end if
              hs.SetDeviceString "1375", Program2StartTime, True
              hs.SetDeviceString "1378", Program2EndTime, True
              case "ENDUP"
              if TimeInterval5 = 2 then
              Program2EndTime=dateadd("n",+5,Program2EndTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              Program2StartTime = dateadd("n",-CurrentProgramTotalLength,Program2EndTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              elseif TimeInterval15 = 2 then
              Program2EndTime=dateadd("n",+15,Program2EndTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              Program2StartTime = dateadd("n",-CurrentProgramTotalLength,Program2EndTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              else
              Program2EndTime=dateadd("n",+60,Program2EndTime)
              Program2EndTime = FormatDateTime(Program2EndTime, 3)
              Program2StartTime = dateadd("n",-CurrentProgramTotalLength,Program2EndTime)
              Program2StartTime = FormatDateTime(Program2StartTime, 3)
              end if
              hs.SetDeviceString "1375", Program2StartTime, True
              hs.SetDeviceString "1378", Program2EndTime, True
              end select
              
              case "PROG3"
              ' Handle changes in start and end time of program
              CurrentProgramTotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              select case data2
              case "PRESET1"
              hs.SetDeviceString "1368", 0, True
              hs.SetDeviceString "1369", 0, True
              hs.SetDeviceString "1370", 0, True
              hs.SetDeviceString "1371", 0, True
              hs.SetDeviceString "1372", 25, True
              hs.SetDeviceString "1373", 25, True
              case "PRESET2"
              hs.SetDeviceString "1368", 0, True
              hs.SetDeviceString "1369", 0, True
              hs.SetDeviceString "1370", 0, True
              hs.SetDeviceString "1371", 0, True
              hs.SetDeviceString "1372", 1, True
              hs.SetDeviceString "1373", 1, True
              
              
              case "STARTDN"
              if TimeInterval5 = 2 then
              Program3StartTime=dateadd("n",-5,Program3StartTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              Program3EndTime = dateadd("n",+CurrentProgramTotalLength,Program3StartTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              elseif TimeInterval15 = 2 then
              Program3StartTime=dateadd("n",-15,Program3StartTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              Program3EndTime = dateadd("n",+CurrentProgramTotalLength,Program3StartTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              else
              Program3StartTime=dateadd("n",-60,Program3StartTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              Program3EndTime = dateadd("n",+CurrentProgramTotalLength,Program3StartTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              end if
              hs.SetDeviceString "1376", cstr(Program3StartTime), True
              hs.SetDeviceString "1379", Program3EndTime, True
              
              case "STARTUP"
              if TimeInterval5 = 2 then
              Program3StartTime=dateadd("n",+5,Program3StartTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              Program3EndTime = dateadd("n",+CurrentProgramTotalLength,Program3StartTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              elseif TimeInterval15 = 2 then
              Program3StartTime=dateadd("n",+15,Program3StartTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              Program3EndTime = dateadd("n",+CurrentProgramTotalLength,Program3StartTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              else
              Program3StartTime=dateadd("n",+60,Program3StartTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              Program3EndTime = dateadd("n",+CurrentProgramTotalLength,Program3StartTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              end if
              hs.SetDeviceString "1376", Program3StartTime, True
              hs.SetDeviceString "1379", Program3EndTime, True
              case "ENDDN"
              if TimeInterval5 = 2 then
              Program3EndTime=dateadd("n",-5,Program3EndTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              Program3StartTime = dateadd("n",-CurrentProgramTotalLength,Program3EndTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              elseif TimeInterval15 = 2 then
              Program3EndTime=dateadd("n",-15,Program3EndTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              Program3StartTime = dateadd("n",-CurrentProgramTotalLength,Program3EndTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              else
              Program3EndTime=dateadd("n",-60,Program3EndTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              Program3StartTime = dateadd("n",-CurrentProgramTotalLength,Program3EndTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              end if
              hs.SetDeviceString "1376", Program3StartTime, True
              hs.SetDeviceString "1379", Program3EndTime, True
              case "ENDUP"
              if TimeInterval5 = 2 then
              Program3EndTime=dateadd("n",+5,Program3EndTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              Program3StartTime = dateadd("n",-CurrentProgramTotalLength,Program3EndTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              elseif TimeInterval15 = 2 then
              Program3EndTime=dateadd("n",+15,Program3EndTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              Program3StartTime = dateadd("n",-CurrentProgramTotalLength,Program3EndTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              else
              Program3EndTime=dateadd("n",+60,Program3EndTime)
              Program3EndTime = FormatDateTime(Program3EndTime, 3)
              Program3StartTime = dateadd("n",-CurrentProgramTotalLength,Program3EndTime)
              Program3StartTime = FormatDateTime(Program3StartTime, 3)
              end if
              hs.SetDeviceString "1376", Program3StartTime, True
              hs.SetDeviceString "1379", Program3EndTime, True
              end select
              
              case "PROG1ZONE1"
              select case data2
              case "UP"
              Program1Zone1Length = hs.devicestring("1356")
              Program1Zone1Length = Program1Zone1Length + 1
              hs.SetDeviceString "1356", Program1Zone1Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              'hs.writelog "Sprinkler", Program1Zone1Length & " | " & Program1Zone2Length & " | " & Program1Zone3Length & " | " & Program1Zone4Length & " | " & Program1Zone5Length & " | " & Program1Zone6Length & " | " & Program1TotalLength
              case "DN"
              Program1Zone1Length = hs.devicestring("1356")
              Program1Zone1Length = Program1Zone1Length - 1
              hs.SetDeviceString "1356", Program1Zone1Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              'hs.writelog "Sprinkler", Program1Zone1Length & " | " & Program1Zone2Length & " | " & Program1Zone3Length & " | " & Program1Zone4Length & " | " & Program1Zone5Length & " | " & Program1Zone6Length & " | " & Program1TotalLength
              end select
              
              case "PROG1ZONE2"
              select case data2
              case "UP"
              Program1Zone2Length = hs.devicestring("1357")
              Program1Zone2Length = Program1Zone2Length + 1
              hs.SetDeviceString "1357", Program1Zone2Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              'hs.writelog "Sprinkler", Program1Zone1Length & " | " & Program1Zone2Length & " | " & Program1Zone3Length & " | " & Program1Zone4Length & " | " & Program1Zone5Length & " | " & Program1Zone6Length & " | " & Program1TotalLength
              case "DN"
              Program1Zone2Length = hs.devicestring("1357")
              Program1Zone2Length = Program1Zone2Length - 1
              hs.SetDeviceString "1357", Program1Zone2Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              'hs.writelog "Sprinkler", Program1Zone1Length & " | " & Program1Zone2Length & " | " & Program1Zone3Length & " | " & Program1Zone4Length & " | " & Program1Zone5Length & " | " & Program1Zone6Length & " | " & Program1TotalLength
              end select
              
              case "PROG1ZONE3"
              select case data2
              case "UP"
              Program1Zone3Length = hs.devicestring("1358")
              Program1Zone3Length = Program1Zone3Length + 1
              hs.SetDeviceString "1358", Program1Zone3Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              case "DN"
              Program1Zone3Length = hs.devicestring("1358")
              Program1Zone3Length = Program1Zone3Length - 1
              hs.SetDeviceString "1358", Program1Zone3Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              end select
              
              case "PROG1ZONE4"
              select case data2
              case "UP"
              Program1Zone4Length = hs.devicestring("1359")
              Program1Zone4Length = Program1Zone4Length + 1
              hs.SetDeviceString "1359", Program1Zone4Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              case "DN"
              Program1Zone4Length = hs.devicestring("1359")
              Program1Zone4Length = Program1Zone4Length - 1
              hs.SetDeviceString "1359", Program1Zone4Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              end select
              
              case "PROG1ZONE5"
              select case data2
              case "UP"
              Program1Zone5Length = hs.devicestring("1360")
              Program1Zone5Length = Program1Zone5Length + 1
              hs.SetDeviceString "1360", Program1Zone5Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              case "DN"
              Program1Zone5Length = hs.devicestring("1360")
              Program1Zone5Length = Program1Zone5Length - 1
              hs.SetDeviceString "1360", Program1Zone5Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              end select
              
              case "PROG1ZONE6"
              select case data2
              case "UP"
              Program1Zone6Length = hs.devicestring("1361")
              Program1Zone6Length = Program1Zone6Length + 1
              hs.SetDeviceString "1361", Program1Zone6Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              case "DN"
              Program1Zone6Length = hs.devicestring("1361")
              Program1Zone6Length = Program1Zone6Length - 1
              hs.SetDeviceString "1361", Program1Zone6Length, True
              Program1TotalLength = cint(Program1Zone1Length) + cint(Program1Zone2Length) + cint(Program1Zone3Length) + cint(Program1Zone4Length) + cint(Program1Zone5Length) + cint(Program1Zone6Length)
              hs.SetDeviceString "2713", Program1TotalLength, True
              end select
              
              case "PROG2ZONE1"
              select case data2
              case "UP"
              Program2Zone1Length = hs.devicestring("1362")
              Program2Zone1Length = Program2Zone1Length + 1
              hs.SetDeviceString "1362", Program2Zone1Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              case "DN"
              Program2Zone1Length = hs.devicestring("1362")
              Program2Zone1Length = Program2Zone1Length - 1
              hs.SetDeviceString "1362", Program2Zone1Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              end select
              
              case "PROG2ZONE2"
              select case data2
              case "UP"
              Program2Zone2Length = hs.devicestring("1363")
              Program2Zone2Length = Program2Zone2Length + 1
              hs.SetDeviceString "1363", Program2Zone2Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              case "DN"
              Program2Zone2Length = hs.devicestring("1363")
              Program2Zone1Length = Program2Zone2Length - 1
              hs.SetDeviceString "1363", Program2Zone2Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              end select
              
              case "PROG2ZONE3"
              select case data2
              case "UP"
              Program2Zone3Length = hs.devicestring("1364")
              Program2Zone3Length = Program2Zone3Length + 1
              hs.SetDeviceString "1364", Program2Zone3Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              case "DN"
              Program2Zone3Length = hs.devicestring("1364")
              Program2Zone3Length = Program2Zone3Length - 1
              hs.SetDeviceString "1364", Program2Zone1Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              end select
              
              case "PROG2ZONE4"
              select case data2
              case "UP"
              Program2Zone4Length = hs.devicestring("1365")
              Program2Zone4Length = Program2Zone4Length + 1
              hs.SetDeviceString "1365", Program2Zone4Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              case "DN"
              Program2Zone4Length = hs.devicestring("1365")
              Program2Zone4Length = Program2Zone4Length - 1
              hs.SetDeviceString "1365", Program2Zone4Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              end select
              
              case "PROG2ZONE5"
              select case data2
              case "UP"
              Program2Zone5Length = hs.devicestring("1366")
              Program2Zone5Length = Program2Zone5Length + 1
              hs.SetDeviceString "1366", Program2Zone5Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              case "DN"
              Program2Zone5Length = hs.devicestring("1366")
              Program2Zone5Length = Program2Zone5Length - 1
              hs.SetDeviceString "1366", Program2Zone5Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              end select
              
              case "PROG2ZONE6"
              select case data2
              case "UP"
              Program2Zone6Length = hs.devicestring("1367")
              Program2Zone6Length = Program2Zone6Length + 1
              hs.SetDeviceString "1367", Program2Zone6Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              case "DN"
              Program2Zone6Length = hs.devicestring("1367")
              Program2Zone6Length = Program2Zone6Length - 1
              hs.SetDeviceString "1367", Program2Zone6Length, True
              Program2TotalLength = cint(Program2Zone1Length) + cint(Program2Zone2Length) + cint(Program2Zone3Length) + cint(Program2Zone4Length) + cint(Program2Zone5Length) + cint(Program2Zone6Length)
              hs.SetDeviceString "2714", Program2TotalLength, True
              end select
              
              case "PROG3ZONE1"
              select case data2
              case "UP"
              Program3Zone1Length = hs.devicestring("1368")
              Program3Zone1Length = Program3Zone1Length + 1
              hs.SetDeviceString "1368", Program3Zone1Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              case "DN"
              Program3Zone1Length = hs.devicestring("1368")
              Program3Zone1Length = Program3Zone1Length - 1
              hs.SetDeviceString "1368", Program3Zone1Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              end select
              
              case "PROG3ZONE2"
              select case data2
              case "UP"
              Program3Zone2Length = hs.devicestring("1369")
              Program3Zone2Length = Program3Zone2Length + 1
              hs.SetDeviceString "1369", Program3Zone2Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              case "DN"
              Program3Zone2Length = hs.devicestring("1369")
              Program3Zone2Length = Program3Zone2Length - 1
              hs.SetDeviceString "1369", Program3Zone2Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              end select
              
              case "PROG3ZONE3"
              select case data2
              case "UP"
              Program3Zone3Length = hs.devicestring("1370")
              Program3Zone3Length = Program3Zone3Length + 1
              hs.SetDeviceString "1370", Program3Zone3Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              case "DN"
              Program3Zone3Length = hs.devicestring("1370")
              Program3Zone3Length = Program3Zone3Length - 1
              hs.SetDeviceString "1370", Program3Zone3Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              end select
              
              case "PROG3ZONE4"
              select case data2
              case "UP"
              Program3Zone4Length = hs.devicestring("1371")
              Program3Zone4Length = Program3Zone4Length + 1
              hs.SetDeviceString "1371", Program3Zone4Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              case "DN"
              Program3Zone4Length = hs.devicestring("1371")
              Program3Zone4Length = Program3Zone4Length - 1
              hs.SetDeviceString "1371", Program3Zone4Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              end select
              
              case "PROG3ZONE5"
              select case data2
              case "UP"
              Program3Zone5Length = hs.devicestring("1372")
              Program3Zone5Length = Program3Zone5Length + 1
              hs.SetDeviceString "1372", Program3Zone5Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              case "DN"
              Program3Zone5Length = hs.devicestring("1372")
              Program3Zone5Length = Program3Zone5Length - 1
              hs.SetDeviceString "1372", Program3Zone5Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              end select
              
              case "PROG3ZONE6"
              select case data2
              case "UP"
              Program3Zone6Length = hs.devicestring("1373")
              Program3Zone6Length = Program3Zone6Length + 1
              hs.SetDeviceString "1373", Program3Zone6Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              case "DN"
              Program3Zone6Length = hs.devicestring("1373")
              Program3Zone6Length = Program3Zone6Length - 1
              hs.SetDeviceString "1373", Program3Zone6Length, True
              Program3TotalLength = cint(Program3Zone1Length) + cint(Program3Zone2Length) + cint(Program3Zone3Length) + cint(Program3Zone4Length) + cint(Program3Zone5Length) + cint(Program3Zone6Length)
              hs.SetDeviceString "2715", Program3TotalLength, True
              end select
              
              case "ALL"
              select case data2
              REM case "ON"
              REM ' Commstar controlled full on
              REM hs.SendToComPort 4, "SPRINKLER=FULL" & vbCR
              REM hs.writelog "Sprinkler", "Full On"
              case "OFF"
              
              ' Issue Etherrain Stop
              error = hs.RunScriptFunc("EtherRain.vb","stopCycle","EtherRain.8; pw",False,False)
              'error = hs.runex("EtherRain.vb", "stopCycle","EtherRain.8; pw")
              'error = hs.runex "EtherRain.vb", "stopCycle","EtherRain.8; pw"
              ' Turn off timers in MainLobby - these are only for display and don't actually trigger anything
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Disable~3"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Disable~4"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Disable~5"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Disable~6"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Disable~7"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Disable~8"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Disable~9"
              ' Turn off Zones
              hs.SetDeviceString "2706", "Off", True
              hs.SetDeviceValue "Q3", 3
              hs.SetDeviceString "2707", "Off", True
              hs.SetDeviceValue "Q4", 3
              hs.SetDeviceString "2708", "Off", True
              hs.SetDeviceValue "Q5", 3
              hs.SetDeviceString "2709", "Off", True
              hs.SetDeviceValue "Q6", 3
              hs.SetDeviceString "2710", "Off", True
              hs.SetDeviceValue "Q7", 3
              hs.SetDeviceString "2711", "Off", True
              hs.SetDeviceValue "Q8", 3
              ' Update main status variable and program running variable - used to show sprinkler status in MainLobby
              hs.SetDeviceString "2727", "Stopped", True
              hs.SetDeviceString "2712", "None", True
              case "NEXT"
              'Q3-Q8 hold status of current zone on/off
              
              end select
              case "MANUAL"
              select case data2
              case "UP"
              ManualLength = hs.devicestring("2738")
              ManualLength = ManualLength + 1
              hs.SetDeviceString "2738", ManualLength, True
              case "DN"
              ManualLength = hs.devicestring("2738")
              ManualLength = ManualLength - 1
              hs.SetDeviceString "2738", ManualLength, True
              end select
              
              case "ZONE1"
              Select case data2
              case "TOGGLE"
              if ManualMode = 2 then
              ' Turning Zone 1 on manually
              ' Checking status of zone
              temp = hs.devicevalue("2706")
              Select case temp
              case 2
              ' Sprinkler On, turn it off
              'hs.SetDeviceString "2706", "Off", True
              'hs.SetDeviceValue "Q3", 3
              ManualLength = 0
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.zone1.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.all.off"
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE1;OFF;SPRINKLER.VBS")
              case 3
              ' Sprinkler Off, turn it on
              ' Get manual zone run time...
              ManualLength = hs.devicestring("2738")
              ' Set zone 1 timer length in MainLobby
              ' New syntax : Timers|SetTimer~3~OneTime~1 to Any Number~Minutes~Macro Command~Enable
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~3~NoRepeat~" & ManualLength & "~minutes~sprinklerzone1done~off"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & ManualLength & "~minutes~sprinklertotaldone~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~3~OneTime~" & ManualLength & "~minutes~sprinkler.zone1.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~9~OneTime~" & ManualLength & "~minutes~sprinkler.all.off"
              hs.SetDeviceString "1350", ManualLength, True
              ' Start total program length timer
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~9"
              'hs.SetDeviceString "2706", "On", True
              'hs.SetDeviceValue "Q3", 2
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE1;ON;SPRINKLER.VBS")
              error = hs.RunScriptFunc("sprinkler2.vbs","Sprinkler2","ZONE1;ON;SPR INKLER.VBS",False,False)
              end select
              else
              hs.writelog "Sprinkler", "Zone 1 manual and on automatic"
              status_string = now & " - Zone 1 Manual but Sprinklers are on automatic - switch to manual"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "2706", "Off", True
              hs.SetDeviceValue "Q3", 3
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLCmd|Msg~All~Sprinkler~System in Automatic Mode - Please switch to manual to operate zones individually~3"
              end if
              end select
              
              case "ZONE2"
              Select case data2
              case "TOGGLE"
              if ManualMode = 2 then
              ' Turning Zone 2 on manually
              ' Checking status of zone
              temp = hs.devicevalue("2707")
              Select case temp
              case 2
              ' Sprinkler On, turn it off
              'hs.SetDeviceString "2707", "Off", True
              'hs.SetDeviceValue "Q4", 3
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.zone2.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.all.off"
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE2;OFF;SPRINKLER.VBS")
              case 3
              ' Sprinkler Off, turn it on
              ' Get manual zone run time...
              ManualLength = hs.devicestring("2738")
              ' Set zone 2 timer length in MainLobby
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~4~NoRepeat~" & ManualLength & "~minutes~sprinklerzone1done~off"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & ManualLength & "~minutes~sprinklertotaldone~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~4~OneTime~" & ManualLength & "~minutes~sprinkler.zone2.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~9~OneTime~" & ManualLength & "~minutes~sprinkler.all.off"
              hs.SetDeviceString "1351", ManualLength, True
              ' Start total program length timer
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~9"
              hs.SetDeviceString "2707", "On", True
              hs.SetDeviceValue "Q4", 2
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE2;ON;SPRINKLER.VBS")
              error = hs.RunScriptFunc("sprinkler2.vbs","Sprinkler2","ZONE2;ON;SPR INKLER.VBS",False,False)
              end select
              else
              hs.writelog "Sprinkler", "Zone 2 manual and on automatic"
              status_string = now & " - Zone 2 Manual but Sprinklers are on automatic - switch to manual"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "2707", "Off", True
              hs.SetDeviceValue "Q4", 3
              end if
              end select
              
              case "ZONE3"
              Select case data2
              case "TOGGLE"
              if ManualMode = 2 then
              ' Turning Zone 3 on manually
              ' Checking status of zone
              temp = hs.devicevalue("2708")
              Select case temp
              case 2
              ' Sprinkler On, turn it off
              'hs.SetDeviceString "2708", "Off", True
              'hs.SetDeviceValue "Q5", 3
              hs.writelog "Sprinkler", "Zone 3 Toggle - Sprinkler On - Turning Zone 3 Off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.zone3.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.all.off"
              'error = hs.runex("sprinkler2.vbs", "Sprinkler3","ZONE1;OFF;SPRINKLER.VBS")
              case 3
              ' Sprinkler Off, turn it on
              ' Get manual zone run time...
              ManualLength = hs.devicestring("2738")
              ' Set zone 3 timer length in MainLobby
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~5~NoRepeat~" & ManualLength & "~minutes~sprinklerzone1done~off"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & ManualLength & "~minutes~sprinklertotaldone~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~5~OneTime~" & ManualLength & "~minutes~sprinkler.zone3.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~9~OneTime~" & ManualLength & "~minutes~sprinkler.all.off"
              hs.SetDeviceString "1352", ManualLength, True
              ' Start total program length timer
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~9"
              hs.SetDeviceString "2708", "On", True
              hs.SetDeviceValue "Q5", 2
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE3;ON;SPRINKLER.VBS")
              error = hs.RunScriptFunc("sprinkler2.vbs","Sprinkler2","ZONE3;ON;SPR INKLER.VBS",False,False)
              end select
              else
              hs.writelog "Sprinkler", "Zone 3 manual and on automatic"
              status_string = now & " - Zone 3 Manual but Sprinklers are on automatic - switch to manual"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "2708", "Off", True
              hs.SetDeviceValue "Q5", 3
              end if
              end select
              
              case "ZONE4"
              Select case data2
              case "TOGGLE"
              if ManualMode = 2 then
              ' Turning Zone 4 on manually
              ' Checking status of zone
              temp = hs.devicevalue("2709")
              Select case temp
              case 2
              ' Sprinkler On, turn it off
              'hs.SetDeviceString "2709", "Off", True
              'hs.SetDeviceValue "Q6", 3
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.zone4.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.all.off"
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE4;OFF;SPRINKLER.VBS")
              case 3
              ' Sprinkler Off, turn it on
              ' Get manual zone run time...
              ManualLength = hs.devicestring("2738")
              ' Set zone 3 timer length in MainLobby
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~6~NoRepeat~" & ManualLength & "~minutes~sprinklerzone1done~off"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & ManualLength & "~minutes~sprinklertotaldone~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~6~OneTime~" & ManualLength & "~minutes~sprinkler.zone4.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~9~OneTime~" & ManualLength & "~minutes~sprinkler.all.off"
              hs.SetDeviceString "1353", ManualLength, True
              ' Start total program length timer
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~9"
              hs.SetDeviceString "2709", "On", True
              hs.SetDeviceValue "Q6", 2
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE4;ON;SPRINKLER.VBS")
              error = hs.RunScriptFunc("sprinkler2.vbs","Sprinkler2","ZONE4;ON;SPR INKLER.VBS",False,False)
              end select
              else
              hs.writelog "Sprinkler", "Zone 4 manual and on automatic"
              status_string = now & " - Zone 4 Manual but Sprinklers are on automatic - switch to manual"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "2709", "Off", True
              hs.SetDeviceValue "Q6", 3
              end if
              end select
              
              case "ZONE5"
              Select case data2
              case "TOGGLE"
              if ManualMode = 2 then
              ' Turning Zone 5 on manually
              ' Checking status of zone
              temp = hs.devicevalue("2710")
              Select case temp
              case 2
              ' Sprinkler On, turn it off
              'hs.SetDeviceString "2710", "Off", True
              'hs.SetDeviceValue "Q7", 3
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.zone5.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.all.off"
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE5;OFF;SPRINKLER.VBS")
              case 3
              ' Sprinkler Off, turn it on
              ' Get manual zone run time...
              ManualLength = hs.devicestring("2738")
              ' Set zone 3 timer length in MainLobby
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~7~NoRepeat~" & ManualLength & "~minutes~sprinklerzone1done~off"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & ManualLength & "~minutes~sprinklertotaldone~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~7~OneTime~" & ManualLength & "~minutes~sprinkler.zone5.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~9~OneTime~" & ManualLength & "~minutes~sprinkler.all.off"
              hs.SetDeviceString "1354", ManualLength, True
              ' Start total program length timer
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~9"
              hs.SetDeviceString "2710", "On", True
              hs.SetDeviceValue "Q7", 2
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE5;ON;SPRINKLER.VBS")
              error = hs.RunScriptFunc("sprinkler2.vbs","Sprinkler2","ZONE5;ON;SPR INKLER.VBS",False,False)
              end select
              else
              hs.writelog "Sprinkler", "Zone 5 manual and on automatic"
              status_string = now & " - Zone 5 Manual but Sprinklers are on automatic - switch to manual"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "2710", "Off", True
              hs.SetDeviceValue "Q7", 3
              end if
              end select
              
              case "ZONE6"
              Select case data2
              case "TOGGLE"
              if ManualMode = 2 then
              ' Turning Zone 6 on manually
              ' Checking status of zone
              temp = hs.devicevalue("2711")
              Select case temp
              case 2
              ' Sprinkler On, turn it off
              'hs.SetDeviceString "2711", "Off", True
              'hs.SetDeviceValue "Q8", 3
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.zone6.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Macro|sprinkler.all.off"
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE6;OFF;SPRINKLER.VBS")
              case 3
              ' Sprinkler Off, turn it on
              ' Get manual zone run time...
              ManualLength = hs.devicestring("2738")
              ' Set zone 3 timer length in MainLobby
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~8~NoRepeat~" & ManualLength & "~minutes~sprinklerzone1done~off"
              'hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.MLTimer|SetTimer~9~NoRepeat~" & ManualLength & "~minutes~sprinklertotaldone~off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~8~OneTime~" & ManualLength & "~minutes~sprinkler.zone6.off"
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|SetTimer~9~OneTime~" & ManualLength & "~minutes~sprinkler.all.off"
              hs.SetDeviceString "1355", ManualLength, True
              ' Start total program length timer
              hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~9"
              hs.SetDeviceString "2711", "On", True
              hs.SetDeviceValue "Q8", 2
              'error = hs.runex("sprinkler2.vbs", "Sprinkler2","ZONE6;ON;SPRINKLER.VBS")
              error = hs.RunScriptFunc("sprinkler2.vbs","Sprinkler2","ZONE6;ON;SPR INKLER.VBS",False,False)
              end select
              else
              hs.writelog "Sprinkler", "Zone 6 manual and on automatic"
              status_string = now & " - Zone 6 Manual but Sprinklers are on automatic - switch to manual"
              hs.SetDeviceString "1347", status_string, True
              hs.SetDeviceString "2711", "Off", True
              hs.SetDeviceValue "Q8", 3
              end if
              end select
              
              end select
              
              hs.writelog "Sprinkler", "+++++++++++++++++++++++++++++++++++ SPRINKLER END +++++++++++++++++++++++++++++++++++ "
              
              
              End Sub

              Comment


                #8
                Here is the other script related to this in case it is useful:

                Code:
                sub Sprinkler2(parms)
                
                Dim result
                Dim temp
                Dim data1
                Dim data2
                Dim hParm
                dim Program1Zone1Length, Program2Zone1Length, Program3Zone1Length, Program4Zone1Length, Program5Zone1Length, Program6Zone1Length, Program1TotalLength
                dim Program1StartTime
                dim filesys, filetxt
                dim RainSensor, ManualMode
                
                
                Const ForReading = 1, ForWriting = 2, ForAppending = 8
                
                Set filesys = CreateObject("Scripting.FileSystemObject")
                
                ' Q72, Q73 - Status variables for screen in MainLobby showing Last Event and Last Program
                
                
                'Called by:
                '
                ' Two parameters:
                ' data1 - Zone - ALL, ZONE1..6
                ' data2 - Command - ON, OFF
                ' data3 - Calling script or event
                
                REM hs.Writelog "Info","In script Sprinkler2.vbs"
                
                
                hParm = split(parms,";")
                data1 = hParm(0) '
                data2 = hParm(1)
                data3 = hParm(2)
                
                hs.writelog "Sprinkler2", "+++++++++++++++++++++++++++++++++++ SPRINKLER2 START +++++++++++++++++++++++++++++++++++ "
                
                hs.writelog "sprinkler2", "Parameters | data1 - " & data1 & " | data2 - " & data2 & " | data3 - " & data3
                
                
                
                'hs.writelog "Debug", "In sprinkler2.vbs - Data1 : " & data1
                'hs.writelog "Debug", "In sprinkler2.vbs - Data2 : " & data2
                'hs.writelog "Debug", "In sprinkler2.vbs - Data3 : " & data3
                
                ' Retrieve variables
                ' Pulling stored strings:
                CurrentProgramZone1Length = hs.devicestring("1350")
                CurrentProgramZone2Length = hs.devicestring("1351")
                CurrentProgramZone3Length = hs.devicestring("1352")
                CurrentProgramZone4Length = hs.devicestring("1353")
                CurrentProgramZone5Length = hs.devicestring("1354")
                CurrentProgramZone6Length = hs.devicestring("1355")
                Program1Zone1Length = hs.devicestring("1356")
                Program1Zone2Length = hs.devicestring("1357")
                Program1Zone3Length = hs.devicestring("1358")
                Program1Zone4Length = hs.devicestring("1359")
                Program1Zone5Length = hs.devicestring("1360")
                Program1Zone6Length = hs.devicestring("1361")
                Program2Zone1Length = hs.devicestring("1362")
                Program2Zone2Length = hs.devicestring("1363")
                Program2Zone3Length = hs.devicestring("1364")
                Program2Zone4Length = hs.devicestring("1365")
                Program2Zone5Length = hs.devicestring("1366")
                Program2Zone6Length = hs.devicestring("1367")
                Program3Zone1Length = hs.devicestring("1368")
                Program3Zone2Length = hs.devicestring("1369")
                Program3Zone3Length = hs.devicestring("1370")
                Program3Zone4Length = hs.devicestring("1371")
                Program3Zone5Length = hs.devicestring("1372")
                Program3Zone6Length = hs.devicestring("1373")
                Program1StartTime = hs.devicestring("1374")
                Program1EndTime = hs.devicestring("1377")
                Program2StartTime = hs.devicestring("1375")
                Program2EndTime = hs.devicestring("1378")
                Program3StartTime = hs.devicestring("1376")
                Program3EndTime = hs.devicestring("1379")
                ' Pulling device on/off status
                TimeInterval5 = hs.devicevalue("1380")
                TimeInterval15 = hs.devicevalue("1381")
                TimeInterval60 = hs.devicevalue("1382")
                Program1Enable = hs.devicevalue("1386")
                Program2Enable = hs.devicevalue("1387")
                Program3Enable = hs.devicevalue("1388")
                ProgramModeSchedule = hs.devicevalue("1385")
                SprinklerMonday = hs.devicevalue("2716")
                SprinklerTuesday = hs.devicevalue("2717")
                SprinklerWednesday = hs.devicevalue("2718")
                SprinklerThursday = hs.devicevalue("2719")
                SprinklerFriday = hs.devicevalue("2720")
                SprinklerSaturday = hs.devicevalue("2721")
                'hs.writelog "Sprinkler2", "SprinklerSaturday is " & SprinklerSaturday
                SprinklerSunday = hs.devicevalue("2722")
                SprinklerOddDays = hs.devicevalue("2725")
                SprinklerEvenDays = hs.devicevalue("2724")
                SprinklerInterval = hs.devicevalue("2723")
                RainSensor = hs.devicevalue("1341")
                ManualMode = hs.devicevalue("1383")
                
                REM Program1StartTime=dateadd("n",-5,Program1StartTime)
                REM Program1StartTime = FormatDateTime(Program1StartTime, 3)
                REM Program1EndTime = dateadd("n",+CurrentProgramTotalLength,Program1StartTime)
                REM Program1EndTime = FormatDateTime(Program1EndTime, 3)
                
                
                select case data1
                
                case "PROGRAM"
                select case data2
                case "CHECKSTARTPROGRAM"
                ' Called every 5 minutes to see if a program needs to be started.
                hs.writelog "Sprinkler2", "The current Sprinkler time is : " & time & " and I am checking to see if the sprinklers need to run"
                if ProgramModeSchedule = 100 then
                hs.writelog "Sprinkler2", "ProgramModeSchedule = " & ProgramModeSchedule & " - Program Mode is On"
                elseif ProgramModeSchedule = 0 then
                hs.writelog "Sprinkler2", "ProgramModeSchedule = " & ProgramModeSchedule & " - Program Mode is Off"
                end if
                if Program1Enable = 100 then
                hs.writelog "Sprinkler2", "Program1Enable = " & Program1Enable & " - Program 1 is Enabled"
                elseif Program1Enable = 0 then
                hs.writelog "Sprinkler2", "Program1Enable = " & Program1Enable & " - Program 1 is Disabled"
                end if
                if RainSensor = 100 then
                hs.writelog "Sprinkler2", "RainSensor = " & RainSensor & " - Rain Sensor is On"
                elseif RainSensor = 0 then
                hs.writelog "Sprinkler2", "RainSensor = " & RainSensor & " - Rain Sensor is Off"
                end if
                hs.writelog "Sprinkler2", "ProgramModeSchedule = " & ProgramModeSchedule
                ' ******************** ProgramModeSchedule is 0 or 100, not 2 from HS2 - need to find and fix all of these references.a
                if ProgramModeSchedule = 2 then
                dayofweek = Weekday(Date)
                hs.writelog "Sprinkler2", " ************ Program Mode Schedule is On"
                hs.writelog "Sprinkler2", " ************ Weekday - " & dayofweek
                dayofmonth = Day(Date)
                'hs.writelog "Sprinkler2", " ************ Day of Month - " & dayofmonth
                currenttime = FormatDateTime(time, 3)
                currenthour = Hour(currenttime)
                currentminute = Minute(currenttime)
                If dayofmonth Mod 2 = 0 Then
                'hs.writelog "Sprinkler2", "EVEN"
                evenday = 1
                oddday = 0
                Else
                'hs.writelog "Sprinkler2", "ODD"
                oddday = 1
                evenday = 0
                End If
                if SprinklerOddDays = 2 then
                'Odd is true
                if oddday = 1 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "OK TO GO!"
                else
                oktogo = 0
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was an even numbered day and they are set to run only on odd days."
                hs.SetDeviceString "1348", status_string, True
                end if
                elseif SprinklerEvenDays = 2 then
                'Even is true
                if evenday = 1 then
                oktogo = 1
                else
                oktogo = 0
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was an odd numbered day and they are set to run only on even days."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if SprinklerSunday = 2 then
                hs.writelog "Sprinkler2", " ************ Sunday"
                hs.writelog "Sprinkler2", " ************ Dayofweek - " & dayofweek
                
                if dayofweek = 1 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "Sunday - OK TO GO!"
                else
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was a Sunday and they are set not to run on this day."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if SprinklerMonday = 2 then
                if dayofweek = 2 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "Monday - OK TO GO!"
                else
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was a Monday and they are set not to run on this day."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if SprinklerTuesday = 2 then
                if dayofweek = 3 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "Tuesday - OK TO GO!"
                else
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was a Tuesday and they are set not to run on this day."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if SprinklerWednesday = 2 then
                if dayofweek = 4 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "Wednesday - OK TO GO!"
                else
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was a Wednesday and they are set not to run on this day."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if SprinklerThursday = 2 then
                if dayofweek = 5 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "Thursday - OK TO GO!"
                else
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was a Thursday and they are set not to run on this day."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if SprinklerFriday = 2 then
                if dayofweek = 6 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "Friday - OK TO GO!"
                else
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was a Friday and they are set not to run on this day."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if SprinklerSaturday = 2 then
                'hs.writelog "Sprinkler2", "It's Saturday - checking to see if sprinklers should be turned on"
                if dayofweek = 7 then
                oktogo = 1
                'hs.writelog "Sprinkler2", "Saturday - OK TO GO!"
                else
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | The sprinklers didn't run last night because it was a Saturday and they are set not to run on this day."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                if oktogo = 1 then
                if Program1Enable = 2 then
                Program1Hour = Hour(Program1StartTime)
                Program1Minute = Minute(Program1StartTime)
                'hs.writelog "Sprinkler2", "currenttime is " & currenttime & " currentminute is " & currentminute & " currenthour is " & currenthour & " Program1Hour is " & Program1Hour & " Program1Minute is " & Program1Minute
                if Program1Hour = currenthour then
                if Program1Minute = currentminute then
                if RainSensor <> 2 then
                'hs.writelog "Sprinkler2", "Starting Sprinkler Program 1 on automatic schedule"
                'error = hs.runex("sprinkler.vbs", "Sprinkler","PROGRAM;1;SPRINKLER2.VBS")
                error = hs.RunScriptFunc("sprinkler.vbs","Sprinkler","PROGRAM;1;SPRI NKLER2.VBS",False,False)
                'error = hs.runex("EtherRain.vb", "runNamedCycle","EtherRain.8; Full")
                status_string = now & " | Sprinkler Program 1"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "1349", status_string, True
                Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
                filetxt.WriteLine(status_string)
                filetxt.Close
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 2
                status_string = now & " | Sprinkler Program 1 ran last night"
                hs.SetDeviceString "1348", status_string , True
                elseif RainSensor = 2 then
                status_string = now & " | Rain Sensor is On so Automatic Program 1 not Started"
                'hs.writelog "Sprinkler2", "Sprinklers not started because rain sensor is on"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "1349", status_string, True
                ' I disabled the following log update because it was updating everytime the sprinkler program ran - turned back on
                Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
                filetxt.WriteLine(status_string)
                filetxt.Close
                hs.writelog "Sprinkler", "******************** Stopped Sprinkler Automatic Program 1 - Rain *****************************"
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | Sprinkler program 1 was scheduled to run last night but didn't because it was raining."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                end if
                elseif Program2Enable = 2 then
                Program2Hour = Hour(Program2StartTime)
                Program2Minute = Minute(Program2StartTime)
                if Program2Hour = currenthour then
                if Program2Minute = currentminute then
                if RainSensor <> 2 then
                'error = hs.runex("sprinkler.vbs", "Sprinkler","PROGRAM;2;SPRINKLER2.VBS")
                error = hs.RunScriptFunc("sprinkler.vbs","Sprinkler","PROGRAM;2;SPRI NKLER2.VBS",False,False)
                'error = hs.runex("EtherRain.vb", "runNamedCycle","EtherRain.8; Front")
                hs.writelog "Sprinkler2", "Starting Sprinkler Program 2 on automatic schedule"
                status_string = now & " | Sprinkler Program 2"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "1349", status_string, True
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 2
                status_string = now & " | Sprinkler Program 2 ran last night"
                hs.SetDeviceString "1348", status_string , True
                elseif RainSensor = 2 then
                status_string = now & " | Rain Sensor is On so Automatic Program 2 not Started"
                'hs.writelog "Sprinkler2", "Sprinklers not started because rain sensor is on"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "1349", status_string, True
                ' I disabled the following log update because it was updating everytime the sprinkler program ran - turned back on
                Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
                filetxt.WriteLine(status_string)
                filetxt.Close
                hs.writelog "Sprinkler", "******************** Stopped Sprinkler Automatic Program 2 - Rain *****************************"
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | Sprinkler program 2 was scheduled to run last night but didn't because it was raining."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                end if
                elseif Program3Enable = 2 then
                Program3Hour = Hour(Program3StartTime)
                Program3Minute = Minute(Program3StartTime)
                if Program3Hour = currenthour then
                if Program3Minute = currentminute then
                if RainSensor <> 2 then
                'error = hs.runex("sprinkler.vbs", "Sprinkler","PROGRAM;3;SPRINKLER2.VBS")
                error = hs.RunScriptFunc("sprinkler.vbs","Sprinkler","PROGRAM;3;SPRI NKLER2.VBS",False,False)
                'error = hs.runex("EtherRain.vb", "runNamedCycle","EtherRain.8; Back")
                hs.writelog "Sprinkler2", "Starting Sprinkler Program 3 on automatic schedule"
                status_string = now & " | Sprinkler Program 3"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "1349", status_string, True
                Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
                filetxt.WriteLine(status_string)
                filetxt.Close
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 2
                status_string = now & " | Sprinkler Program 3 ran last night."
                hs.SetDeviceString "1348", status_string , True
                elseif RainSensor = 2 then
                status_string = now & " | Rain Sensor is On so Automatic Program 3 not Started"
                'hs.writelog "Sprinkler2", "Sprinklers not started because rain sensor is on"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "1349", status_string, True
                ' I disabled the following log update because it was updating everytime the sprinkler program ran - turned back on
                Set filetxt = filesys.OpenTextFile("vacalog.txt", ForAppending, True)
                filetxt.WriteLine(status_string)
                filetxt.Close
                hs.writelog "Sprinkler", "******************** Stopped Sprinkler Automatic Program 3 - Rain *****************************"
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                status_string = now & " | Sprinkler program 3 was scheduled to run but didn't because it was raining."
                hs.SetDeviceString "1348", status_string , True
                end if
                end if
                end if
                end if
                end if
                else
                ' ProgramModeSchedule <> 2 - So Automatic Program Not on
                ' Setting Status and String of Ran Last Night Status Variable:
                hs.SetDeviceValue "Q2", 3
                hs.SetDeviceString "1348", "The Sprinklers did not run last night because they are disabled.", True
                end if
                end select
                
                
                case "ZONE1"
                ' Single Zone Execution
                'hs.writelog "Sprinkler2", "Current Program Zone 1 Length - > " & CurrentProgramZone1Length
                select case data2
                case "ON"
                if CurrentProgramZone1Length > 0 then
                'hs.writelog "Sprinkler2", " - > CurrentProgramZone1Length is greater than 0 so turning on Zone 1"
                ' Start Zone 1 timer
                hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~3"
                hs.writelog "Sprinkler2", "Turning on Zone1 for " & CurrentProgramZone1Length & " minutes"
                status_string = now & " | Starting Zone 1 for " & CurrentProgramZone1Length & " minutes"
                hs.SetDeviceString "1347", status_string, True
                ' Call Etherrain with all variables
                hs.writelog "sprinkler", "Calling etherrain with zone1 : " & cint(CurrentProgramZone1Length) & " zone2 : " & 0 & " zone 3 : " & 0 & " zone 4 : " & 0 & " zone 5 : " & 0 & " zone 6 : " & 0
                ' Issue etherrain command
                command = cint(CurrentProgramZone1Length) & ";" & 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";0;0"
                'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
                error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw; " & command,False,False)
                hs.SetDeviceString "2706", "On", True
                hs.SetDeviceValue "Q3", 2
                else
                hs.writelog "Sprinkler2", "Zone 1 On called for but timer is 0 so doing nothing"
                status_string = now & " | Stopping Zone 1 - timer is set to 0"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2706", "Off", True
                hs.SetDeviceValue "Q3", 3
                end if
                case "OFF"
                hs.writelog "Sprinkler2", "Turning off Zone1"
                status_string = now & " | Stopping Zone 1"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2706", "Off", True
                hs.SetDeviceValue "Q3", 3
                'error = hs.runex("EtherRain.vb", "stopCycle","EtherRain.8; pw")
                error = hs.RunScriptFunc("EtherRain.vb","stopCycle","EtherRain.8; pw",False,False)
                end select
                case "ZONE2"
                'hs.writelog "Sprinkler2", "Current Program Zone2 Length - > " & CurrentProgramZone2Length
                select case data2
                case "ON"
                if CurrentProgramZone2Length > 0 then
                'hs.writelog "Sprinkler2", " - > CurrentProgramZone2Length is greater than 0 so turning on Zone 2"
                ' Start Zone 2 timer
                hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~4"
                'hs.writelog "Sprinkler2", "Turning on Zone2"
                status_string = now & " | Starting Zone 2"
                hs.SetDeviceString "1347", status_string, True
                hs.writelog "Sprinkler2", "Turning on Zone2 for " & CurrentProgramZone2Length & " minutes"
                status_string = now & " | Starting Zone 2 for " & CurrentProgramZone2Length & " minutes"
                hs.SetDeviceString "1347", status_string, True
                ' Call Etherrain with all variables
                hs.writelog "sprinkler", "Calling etherrain with zone1 : " & 0 & " zone2 : " & cint(CurrentProgramZone2Length) & " zone 3 : " & 0 & " zone 4 : " & 0 & " zone 5 : " & 0 & " zone 6 : " & 0
                ' Issue etherrain command
                command = 0 & ";" & cint(CurrentProgramZone2Length) & ";" & 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";0;0"
                'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
                error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw",False,False)
                hs.SetDeviceString "2707", "On", True
                hs.SetDeviceValue "Q4", 2
                else
                'hs.writelog "Sprinkler2", "Zone 2 On called for but timer is 0 so doing nothing"
                status_string = now & " | Stopping Zone 2 - timer is set to 0"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2707", "Off", True
                hs.SetDeviceValue "Q4", 3
                end if
                case "OFF"
                hs.writelog "Sprinkler2", "Turning off Zone2"
                status_string = now & " | Stopping Zone 2"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2707", "Off", True
                hs.SetDeviceValue "Q4", 3
                'error = hs.runex("EtherRain.vb", "stopCycle","EtherRain.8; pw")
                error = hs.RunScriptFunc("EtherRain.vb","stopCycle","EtherRain.8; pw",False,False)
                end select
                case "ZONE3"
                'hs.writelog "Sprinkler2", "Current Program Zone 3 Length - > " & CurrentProgramZone3Length
                select case data2
                case "ON"
                if CurrentProgramZone3Length > 0 then
                'hs.writelog "Sprinkler2", " - > CurrentProgramZone3Length is greater than 0 so turning on Zone 3"
                ' Start Zone 3 timer
                hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~5"
                'hs.writelog "Sprinkler2", "Turning on Zone3"
                status_string = now & " | Starting Zone 3"
                hs.SetDeviceString "1347", status_string, True
                hs.writelog "Sprinkler2", "Turning on Zone3 for " & CurrentProgramZone3Length & " minutes"
                status_string = now & " | Starting Zone 3 for " & CurrentProgramZone3Length & " minutes"
                hs.SetDeviceString "1347", status_string, True
                ' Call Etherrain with all variables
                hs.writelog "sprinkler", "Calling etherrain with zone1 : " & 0 & " zone2 : " & 0 & " zone 3 : " & cint(CurrentProgramZone3Length) & " zone 4 : " & 0 & " zone 5 : " & 0 & " zone 6 : " & 0
                ' Issue etherrain command
                command = 0 & ";" & 0 & ";" & cint(CurrentProgramZone3Length) & ";" & 0 & ";" & 0 & ";" & 0 & ";0;0"
                'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
                error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw; " & command,False,False)
                hs.SetDeviceString "2708", "On", True
                hs.SetDeviceValue "Q5", 2
                else
                'hs.writelog "Sprinkler2", "Zone 3 On called for but timer is 0 so doing nothing"
                status_string = now & " | Stopping Zone 3 - timer is set to 0"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2708", "Off", True
                hs.SetDeviceValue "Q5", 3
                end if
                case "OFF"
                hs.writelog "Sprinkler2", "Turning off Zone3"
                status_string = now & " | Stopping Zone 3"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2708", "Off", True
                hs.SetDeviceValue "Q5", 3
                'error = hs.runex("EtherRain.vb", "stopCycle","EtherRain.8; pw")
                error = hs.RunScriptFunc("EtherRain.vb","stopCycle","EtherRain.8; pw",False,False)
                end select
                case "ZONE4"
                'hs.writelog "Sprinkler2", "Current Program Zone 4 Length - > " & CurrentProgramZone4Length
                select case data2
                case "ON"
                if CurrentProgramZone4Length > 0 then
                'hs.writelog "Sprinkler2", " - > CurrentProgramZone4Length is greater than 0 so turning on Zone 4"
                ' Start Zone 4 timer
                hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~6"
                'hs.writelog "Sprinkler2", "Turning on Zone4"
                status_string = now & " | Starting Zone 4"
                hs.SetDeviceString "1347", status_string, True
                hs.writelog "Sprinkler2", "Turning on Zone4 for " & CurrentProgramZone4Length & " minutes"
                status_string = now & " | Starting Zone 4 for " & CurrentProgramZone4Length & " minutes"
                hs.SetDeviceString "1347", status_string, True
                ' Call Etherrain with all variables
                hs.writelog "sprinkler", "Calling etherrain with zone1 : " & 0 & " zone2 : " & 0 & " zone 3 : " & 0 & " zone 4 : " & cint(CurrentProgramZone4Length) & " zone 5 : " & 0 & " zone 6 : " & 0
                ' Issue etherrain command
                command = 0 & ";" & 0 & ";" & 0 & ";" & cint(CurrentProgramZone4Length) & ";" & 0 & ";" & 0 & ";0;0"
                'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
                error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw; " & command,False,False)
                hs.SetDeviceString "2709", "On", True
                hs.SetDeviceValue "Q6", 2
                else
                'hs.writelog "Sprinkler2", "Zone 4 On called for but timer is 0 so doing nothing"
                status_string = now & " | Stopping Zone 4 - timer is set to 0"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2709", "Off", True
                hs.SetDeviceValue "Q6", 3
                end if
                case "OFF"
                hs.writelog "Sprinkler2", "Turning off Zone4"
                status_string = now & " | Stopping Zone 4"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2709", "Off", True
                hs.SetDeviceValue "Q6", 3
                'error = hs.runex("EtherRain.vb", "stopCycle","EtherRain.8; pw")
                error = hs.RunScriptFunc("EtherRain.vb","stopCycle","EtherRain.8; pw",False,False)
                end select
                case "ZONE5"
                'hs.writelog "Sprinkler2", "Current Program Zone 5 Length - > " & CurrentProgramZone5Length
                select case data2
                case "ON"
                if CurrentProgramZone5Length > 0 then
                'hs.writelog "Sprinkler2", " - > CurrentProgramZone5Length is greater than 0 so turning on Zone 5"
                ' Start Zone 5 timer
                hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~7"
                'hs.writelog "Sprinkler2", "Turning on Zone5"
                status_string = now & " | Starting Zone 5"
                hs.SetDeviceString "1347", status_string, True
                hs.writelog "Sprinkler2", "Turning on Zone5 for " & CurrentProgramZone5Length & " minutes"
                status_string = now & " | Starting Zone 5 for " & CurrentProgramZone5Length & " minutes"
                hs.SetDeviceString "1347", status_string, True
                ' Call Etherrain with all variables
                hs.writelog "sprinkler", "Calling etherrain with zone1 : " & 0 & " zone2 : " & 0 & " zone 3 : " & 0 & " zone 4 : " & 0 & " zone 5 : " & cint(CurrentProgramZone5Length) & " zone 6 : " & 0
                ' Issue etherrain command
                command = 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";" & cint(CurrentProgramZone5Length) & ";" & 0 & ";0;0"
                'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
                error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw; " & command,False,False)
                hs.SetDeviceString "2710", "On", True
                hs.SetDeviceValue "Q7", 2
                else
                'hs.writelog "Sprinkler2", "Zone 5 On called for but timer is 0 so doing nothing"
                status_string = now & " | Stopping Zone 5 - timer is set to 0"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2710", "Off", True
                hs.SetDeviceValue "Q7", 3
                end if
                case "OFF"
                hs.writelog "Sprinkler2", "Turning off Zone5"
                status_string = now & " | Stopping Zone 4"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2710", "Off", True
                hs.SetDeviceValue "Q7", 3
                'error = hs.runex("EtherRain.vb", "stopCycle","EtherRain.8; pw")
                error = hs.RunScriptFunc("EtherRain.vb","stopCycle","EtherRain.8; pw",False,False)
                end select
                case "ZONE6"
                'hs.writelog "Sprinkler2", "Current Program Zone 6 Length - > " & CurrentProgramZone6Length
                select case data2
                case "ON"
                if CurrentProgramZone6Length > 0 then
                'hs.writelog "Sprinkler2", " - > CurrentProgramZone5Length is greater than 0 so turning on Zone 6"
                ' Start Zone 6 timer
                hs.plugin("MLHSPlugin").MLServeCMD "MLServeCmd.Timers|Enable~8"
                'hs.writelog "Sprinkler2", "Turning on Zone6"
                status_string = now & " | Starting Zone 6"
                hs.SetDeviceString "1347", status_string, True
                hs.writelog "Sprinkler2", "Turning on Zone6 for " & CurrentProgramZone6Length & " minutes"
                status_string = now & " | Starting Zone 6 for " & CurrentProgramZone6Length & " minutes"
                hs.SetDeviceString "1347", status_string, True
                ' Call Etherrain with all variables
                hs.writelog "sprinkler", "Calling etherrain with zone1 : " & 0 & " zone2 : " & 0 & " zone 3 : " & 0 & " zone 4 : " & 0 & " zone 5 : " & 0 & " zone 6 : " & cint(CurrentProgramZone6Length)
                ' Issue etherrain command
                command = 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";" & 0 & ";" & cint(CurrentProgramZone6Length) & ";0;0"
                'error = hs.runex("EtherRain.vb", "runCycle","EtherRain.8; pw; " & command)
                error = hs.RunScriptFunc("EtherRain.vb","runCycle","EtherRain.8; pw; " & command,False,False)
                hs.SetDeviceString "2711", "On", True
                hs.SetDeviceValue "Q8", 2
                else
                'hs.writelog "Sprinkler2", "Zone 6 On called for but timer is 0 so doing nothing"
                status_string = now & " | Stopping Zone 6 - timer is set to 0"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2711", "Off", True
                hs.SetDeviceValue "Q8", 3
                end if
                case "OFF"
                hs.writelog "Sprinkler2", "Turning off Zone6"
                status_string = now & " | Stopping Zone 6"
                hs.SetDeviceString "1347", status_string, True
                hs.SetDeviceString "2711", "Off", True
                hs.SetDeviceValue "Q8", 3
                'error = hs.runex("EtherRain.vb", "stopCycle","EtherRain.8; pw")
                error = hs.RunScriptFunc("EtherRain.vb","stopCycle","EtherRain.8; pw",False,False)
                end select
                end select
                
                hs.writelog "Sprinkler2", "+++++++++++++++++++++++++++++++++ SPRINKLER2 END ++++++++++++++++++++++++++++++++++++ "
                
                End Sub

                Comment

                Working...
                X