Announcement

Collapse
No announcement yet.

Sequence of events 15 min apart

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

    #16
    Nothing has changed apart from the actions when start/stopping is triggered.

    Clear the device string containing the zone/time info and reset both counters via the Homeseer GUI.
    Then try again.



    Jon

    Comment


      #17
      jon00

      Followed the instructions. Same result.
      My humble analysis of the situation is that this line doesn't work and causes the script to exit without completing the process


      Result = hs.GetURL("192.168.1.202", "/control?sta=" & ZoneNumber & "&time=" & ZoneMins, False, 80)

      Comment


        #18
        If the script had an error then you would see that in the log. The action to turn on/off the zones would still be seen in the log as that is before this line.

        Go back to your last script to see if it works.
        Jon

        Comment


          #19
          Yes, the old version works well with everything proper log and proper messaging. Here is the script with my phone number masked

          Code:
          Sub Main(ByVal Parm As String)
          
          Dim ts As TimeSpan
          Dim Ref As Integer
          Dim ZoneData As String = ""
          Dim ZoneNumber As String = ""
          Dim ZoneMins As String = ""
          Dim Count As Double
          Dim Start As Double
          Dim Zones() As String
          Dim TextMessage As String = ""
          Dim DefaultTime As String = ""
          
          Try
          ' Set the reference number of the device that contains the text message as a string
          Ref = 3610
          
          ' Default time in minutes if no time is sent
          DefaultTime = "15"
          
          ' Get the zone/duration from string
          TextMessage = hs.DeviceString(Ref)
          
          ' If the device string is empty, then exit the sub
          If TextMessage = "" Then Exit Sub
          
          Zones = TextMessage.Split(",")
          
          Start = hs.CounterValue("IrrigationStart")
          Count = hs.CounterValue("IrrigationRC")
          
          If Count > Zones.GetUpperBound(0) Then ' No more data to process
          hs.WriteLog("Test", "No more data - Exit")
          ' Set devicestring to empty
          hs.SetDeviceString(Ref, "", False)
          hs.SetDeviceValueByRef(Ref, 0, True)
          hs.CounterReset("IrrigationRC")
          hs.CounterReset("IrrigationStart")
          Exit Sub
          End If
          
          If Start = 0 Then hs.TimerReset("IrrigationRC")
          
          ts = hs.TimerValue("IrrigationRC")
          
          ZoneData = Zones(Count).Trim
          
          If Integer.TryParse(ZoneData, Nothing) Then
          'Only Zone number sent
          ZoneNumber = ZoneData
          ZoneMins = DefaultTime
          Else
          ZoneNumber = ZoneData.Substring(0, ZoneData.IndexOf("/")).Trim
          If Not Integer.TryParse(ZoneNumber, Nothing) Then
          hs.Writelog("Error", "Invalid/Upspecified Zone Number " & ZoneNumber)
          Exit Sub
          End If
          
          ZoneMins = ZoneData.Substring(ZoneData.IndexOf("/") + 1).Trim
          If Not Integer.TryParse(ZoneMins, Nothing) Then ZoneMins = DefaultTime
          End If
          
          If ts.TotalSeconds >= CInt(ZoneMins) * 60 Then
          hs.WriteLog("Test", "Stopping Zone " & ZoneNumber)
          
          ' ****** Code to Trigger Zone OFF below *****
          
          hs.GetURL("192.168.1.202", "/control?sta=" & ZoneNumber & "&time=0&action=OFF", False, 80)
          hs.WriteLog("IrrbyText", "Stopping Zone: " & ZoneNumber)
          hs.SendEmail("77777777777@vtext.com", "homeseer", "", "", "Irrigation", "Zone STOPPED:" & ZoneNumber, "")
          
          ' ******************************************
          
          hs.TimerReset("IrrigationRC")
          hs.CounterIncrement("IrrigationRC")
          
          Else
          If Start = Count Then
          hs.CounterIncrement("IrrigationStart")
          hs.WriteLog("IrrbyText", "Starting Zone: " & ZoneNumber)
          hs.SendEmail("7777777777777@vtext.com", "homeseer", "", "", "Irrigation", "Zone STARTED:" & ZoneNumber, "")
          
          
          ' ****** Code to Trigger Zone ON below *****
          
          hs.GetURL("192.168.1.202", "/control?sta=" & ZoneNumber & "&time=" & ZoneMins, False, 80)
          
          
          ' ******************************************
          
          End If
          End If
          Catch Ex As Exception
          hs.WriteLog("Error", "Error in Irrigation Zone Control: " & Ex.ToString)
          End Try
          End Sub

          Comment


            #20
            Please try the following script (don't modify your existing).

            Code:
                Sub Main(ByVal Parm As String)
            
                    Dim ts As TimeSpan
                    Dim Ref As Integer
                    Dim ZoneData As String = ""
                    Dim ZoneNumber As String = ""
                    Dim ZoneMins As String = ""
                    Dim Count As Double
                    Dim Start As Double
                    Dim Zones() As String
                    Dim TextMessage As String = ""
                    Dim DefaultTime As String = ""
                    Dim Result As String = ""
            
                    Try
                        ' Set the reference number of the device that contains the text message as a string
                        Ref = 3610
            
                        ' Default time in minutes if no time is sent
                        DefaultTime = "15"
            
                        ' Get the zone/duration from string
                        TextMessage = hs.DeviceString(Ref)
            
                        ' If the device string is empty, then exit the sub
                        If TextMessage = "" Then Exit Sub
            
                        Zones = TextMessage.Split(",")
            
                        Start = hs.CounterValue("IrrigationStart")
                        Count = hs.CounterValue("IrrigationRC")
            
                        If Count > Zones.GetUpperBound(0) Then ' No more data to process
                            hs.WriteLog("Test", "No more data - Exit")
                            ' Set devicestring to empty
                            hs.SetDeviceString(Ref, "", False)
                            hs.SetDeviceValueByRef(Ref, 0, True)
                            hs.CounterReset("IrrigationRC")
                            hs.CounterReset("IrrigationStart")
                            Exit Sub
                        End If
            
                        If Start = 0 Then hs.TimerReset("IrrigationRC")
            
                        ts = hs.TimerValue("IrrigationRC")
            
                        ZoneData = Zones(Count).Trim
            
                        If Integer.TryParse(ZoneData, Nothing) Then
                            'Only Zone number sent
                            ZoneNumber = ZoneData
                            ZoneMins = DefaultTime
                        Else
                            ZoneNumber = ZoneData.Substring(0, ZoneData.IndexOf("/")).Trim
                            If Not Integer.TryParse(ZoneNumber, Nothing) Then
                                hs.Writelog("Error", "Invalid/Upspecified Zone Number " & ZoneNumber)
                                Exit Sub
                            End If
            
                            ZoneMins = ZoneData.Substring(ZoneData.IndexOf("/") + 1).Trim
                            If Not Integer.TryParse(ZoneMins, Nothing) Then ZoneMins = DefaultTime
                        End If
            
                        If ts.TotalSeconds >= CInt(ZoneMins) * 60 Then
            
                            ' ****** Code to Trigger Zone OFF below *****
            
                            hs.WriteLog("IrrbyText", "Stopping Zone: " & ZoneNumber)
                            hs.SendEmail("77777777777@vtext.com", "homeseer", "", "", "Irrigation", "Zone STOPPED:" & ZoneNumber, "")
            
                            Result = hs.GetURL("192.168.1.202", "/control?sta=" & ZoneNumber & "&time=0&action=OFF", False, 80)
                            hs.WriteLog("IrrbyText", "Controller Off Response: " & Result)
                            If Result = "" Then hs.SendEmail("7777777777777@vtext.com", "homeseer", "", "", "Irrigation", "Zone OFF FAILED:" & ZoneNumber, "")
            
            
                            ' ******************************************
            
                            hs.TimerReset("IrrigationRC")
                            hs.CounterIncrement("IrrigationRC")
            
                        Else
                            If Start = Count Then
                                hs.CounterIncrement("IrrigationStart")
            
            
                                ' ****** Code to Trigger Zone ON below *****
            
                                hs.WriteLog("IrrbyText", "Starting Zone: " & ZoneNumber)
                                hs.SendEmail("7777777777777@vtext.com", "homeseer", "", "", "Irrigation", "Zone STARTED:" & ZoneNumber, "")
            
                                Result = hs.GetURL("192.168.1.202", "/control?sta=" & ZoneNumber & "&time=" & ZoneMins, False, 80)
                                hs.WriteLog("IrrbyText", "Controller On Response: " & Result)
                                If Result = "" Then hs.SendEmail("7777777777777@vtext.com", "homeseer", "", "", "Irrigation", "Zone ON FAILED:" & ZoneNumber, "")
            
                                ' ******************************************
            
                            End If
                        End If
                    Catch Ex As Exception
                        hs.WriteLog("Error", "Error in Irrigation Zone Control: " & Ex.ToString)
                    End Try
                End Sub
            Jon

            Comment


              #21
              jon00

              This one works better as it reports both start and stop in HS4 logs. However it skipped 3 out of six messages. It could be Verizon's problem but the original script never skipped messages. Could be some timing issue as well. Attached is screen shot from my iPhone of the messages that I received.

              Testing pattern 17/1, 18/1, 27/1

              HS4 log (in reverse order)
              12/10/2021 10:49:34 AM


              Script
              IrrbyText
              Stopping Zone: 27
              12/10/2021 10:48:34 AM


              Script
              IrrbyText
              Starting Zone: 27
              12/10/2021 10:48:14 AM


              Script
              IrrbyText
              Stopping Zone: 18
              12/10/2021 10:47:14 AM


              Script
              IrrbyText
              Starting Zone: 18
              12/10/2021 10:46:54 AM


              Script
              IrrbyText
              Stopping Zone: 17
              12/10/2021 10:45:54 AM


              Script
              IrrbyText
              Starting Zone: 17

              Click image for larger version

Name:	Screenshot 2021-12-10 at 11.04.33 AM.png
Views:	149
Size:	407.5 KB
ID:	1513372

              Comment


                #22
                jon00

                ... wait I just received 2 of the missing messages with delay. One is still missing but this is a good indication that the problem is with Verizon.

                edited later: I received the last message from Verizon with 30+ minutes delay. Wondering if Verizon has problems today as I've never seen such delays before, but I'm not a regular Verizon text messaging user either.

                Comment


                  #23
                  jon00

                  I can use alternative messaging. In order to do so I need for you to call two special events in lieu of current email sending

                  StartMessage
                  StopMessage

                  and somehow to pass the Zone Number to these events. Unless you know of a better way, just put Zone Number as a value in HS4 device created for this very purpose with ref#3620.

                  Comment


                    #24
                    Delays in received text messages sent via email has been reported many times on this board.

                    It's easy to trigger an event from a script. You just use:

                    Code:
                    hs.Triggerevent ("StartMessage")
                    
                    hs.Triggerevent ("StopMessage")
                    To pass information to an event, you need the plugin you are using to accept Replacement Variables You need to find out/test if they can be used (use $date in the message to see if you see the actual date).

                    Some plugins such as pushover notifications (referring to the original one) can be operated directly via a script command.

                    Jon

                    Comment


                      #25
                      jon00

                      Thanks a lot. I can certainly manage the event triggering. Still not clear to me how to pass the value of the script's variable "Zone Number" to the event. If we forget about the plug-in and assume that "Zone Number" needs to dim a dimmer that is HS4 device and has range from 0 to 100. How do I do that?

                      Comment


                        #26
                        I would use a global variable which stores information in memory:

                        Under Ref = 3610 add:

                        Code:
                        hs.CreateVar("zoneinfo")
                        Then instead of the email code lines, you would save your text to the global variable. Example:

                        Code:
                        hs.SaveVar("zoneinfo","Zone ON FAILED:" & ZoneNumber)
                        Then use the global replacement variable in your event message:

                        Code:
                        $$GLOBALVAR[B]:[/B]zoneinfo[B]:[/B]
                        In the example given it would display Zone ON FAILED: 2 for zone 2


                        This all depends if global variables are supported by the plugin you are using to push the message.
                        Jon

                        Comment


                          #27
                          It says here https://help.homeseer.com/help/HS3/s...ment_variables that

                          $$GLOBALVAR passes along the value of the variable whereas it passes the string in your example. Will it work ?

                          Comment


                            #28
                            A global variable can store anything......
                            Jon

                            Comment


                              #29
                              Understood. Will play with it and let everyone know how it paned out.

                              Thanks a lot for the cooperation.

                              Comment


                                #30
                                Implemented everything per jon00 instructions above. Direct messaging with Big6 and Slack. No crappy Verizon service. Works like a charm.

                                Thanks again Jon.

                                Best,

                                puma

                                Comment

                                Working...
                                X