Announcement

Collapse
No announcement yet.

Event to run every 4th Thursday

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

  • #16
    Ahh. I've read it wrong too. It is a recurring 4 week trigger he wants....
    Jon

    Comment


    • #17
      My Daily Reminders script (in the library) will do this very thing quite easily. Just set the start Date/Time and set the interval to 4 weeks (or 28 days). The script is capable of running an event on cue.
      Real courage is not securing your Wi-Fi network.

      Comment


      • #18
        Would this work for you?

        Code:
        Sub Main(ByVal Parm As Object)
        
            Dim ReminderDate As New Date(2017, 4, 27)
            Dim CompareDate As Date = Now.Date
        
            If DateDiff("d", ReminderDate, compareDate) Mod 28 = 0 Then
                hs.TriggerEvent("MyEvent")
            End If
        
        End Sub
        Greig.
        Zwave = Z-Stick, 3xHSM100� 7xACT ZDM230, 1xEverspring SM103, 2xACT HomePro ZRP210.
        X10 = CM12U, 2xAM12, 1xAW10, 1 x TM13U, 1xMS13, 2xHR10, 2xSS13
        Other Hardware = ADI Ocelot + secu16, Global Cache GC100, RFXtrx433, 3 x Foscams.
        Plugings = RFXcom, ActiveBackup, Applied Digital Ocelot, BLDeviceMatrix, BLGarbage, BLLAN, Current Cost, Global Cache GC100,HSTouch Android, HSTouch Server, HSTouch Server Unlimited, NetCAM, PowerTrigger, SageWebcamXP, SqueezeBox, X10 CM11A/CM12U.
        Scripts =
        Various

        Comment


        • #19
          Originally posted by enigmatheatre View Post
          Would this work for you?

          Code:
          Sub Main(ByVal Parm As Object)
          
              Dim ReminderDate As New Date(2017, 4, 27)
              Dim CompareDate As Date = Now.Date
          
              If DateDiff("d", ReminderDate, compareDate) Mod 28 = 0 Then
                  hs.TriggerEvent("MyEvent")
              End If
          
          End Sub
          Greig.
          Can I just simply paste this into a .vb and save to the scripts folder? When I run the script with the New Date set to 2017, 4, 16 (as a test) and launch manually, the script runs but it does not start my event.

          When I launch the following script, my event does run so I know the path is right. Am I missing some prerequisite setup needed for this script to run? Thanks!

          Sub Main(ByVal Parm As Object)

          hs.TriggerEvent("Timed Events RecyclingDay")

          End Sub

          Comment


          • #20
            Originally posted by jamesk View Post
            Can I just simply paste this into a .vb and save to the scripts folder? When I run the script with the New Date set to 2017, 4, 16 (as a test) and launch manually, the script runs but it does not start my event.

            When I launch the following script, my event does run so I know the path is right. Am I missing some prerequisite setup needed for this script to run? Thanks!

            Sub Main(ByVal Parm As Object)

            hs.TriggerEvent("Timed Events RecyclingDay")

            End Sub
            What is the event name? If "Timed Events RecyclingDay" is the group plus the event name, only use the event name "RecyclingDay".
            Randy Prade
            Aurora, CO
            Prades.net

            PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

            Comment


            • #21
              Originally posted by jamesk View Post
              Can I just simply paste this into a .vb and save to the scripts folder? When I run the script with the New Date set to 2017, 4, 16 (as a test) and launch manually, the script runs but it does not start my event.
              That's only a 2 week delta, not a 4 week one. Try 2017, 4, 2 and it should trigger the event today.

              Cheers
              Al
              HS 3.0.0.548: 1990 Devices 1172 Events
              Z-Wave 3.0.1.262: 126 Nodes on one Z-Net

              Comment


              • #22
                Originally posted by sparkman View Post
                That's only a 2 week delta, not a 4 week one. Try 2017, 4, 2 and it should trigger the event today.

                Cheers
                Al
                Thanks! That was a real genius move on my part!

                Thank you all for the excellent suggestions!

                Comment


                • #23
                  Wouldn't the "Cannot re-run for: " set to somewhere between 21 - 27 days work?
                  Attached Files

                  Comment


                  • #24
                    You can calculate the number of the week with:
                    w= DatePart("ww", Now())
                    Then, for triggering an event every 4 weeks, starting week #4
                    if (DatePart("ww", Now())) Mod 4 =1
                    If week 4 is not suitable for the first week you can use w-1 or w-2 etc.

                    PHP Code:
                    'Triggering an event every4th sunday:
                    Dim DOW As Integer = DateTime.Today.DayOfWeek
                    Dim w As Integer = (DatePart("ww", Now())) Mod 4

                    If w-4 = 1 and DOW =4 Then
                        hs.TriggerEvent("MyEvent")
                    end if 
                    If you want to use HS events, you can just store w in a device once a day, then use this device value in events, that is what I use for triggering events on odd/even weeks.
                    Last edited by Pierre; May 1st, 2017, 10:14 AM. Reason: add
                    Visit zee e-maison : http://www.e-maison.com

                    Comment


                    • #25
                      Or another way with no overhead.

                      Add the following script to be run by "MyEvent"

                      Set "MyEvent" to run next Thursday by a normal 'If Time/Date is.....' trigger.

                      Now when the script runs next Thursday, it will set a new Time/Date trigger for the event in 28 days time.

                      Code:
                           Sub Main(ByVal Parm As Object)
                      
                              Dim dt As Date =  DateTime.Parse(DateTime.Today.AddDays(28) & " 08:00 AM")
                              Dim dvRef As Integer = hs.GetEventRefByName("MyEvent")
                              hs.EventSetTimeTrigger(dvRef, dt)
                              hs.SaveEventsDevices()
                              hs.EnableEvent ("MyEvent")
                      
                          End Sub
                      (Change the 08:00 AM to a suitable time)
                      Jon

                      Comment


                      • #26
                        This thread is an effective example of how diverse methods can be used to solve a problem in HS. I'm enjoying the creativity and am impressed by the innovative thinking. I hope there are still more suggestions to come.
                        Mike____________________________________________________________ __________________
                        HS3 Pro Edition 3.0.0.548

                        HW: Stargate | NX8e | CAV6.6 | Squeezebox | PCS | WGL 800RF, Rain8Net+ | RFXCOM | QSE100D | Vantage Pro | Green-Eye | X10: XTB-232, -IIR | Edgeport/8 | Way2Call | Ecobee3

                        Comment


                        • #27
                          Originally posted by Uncle Michael View Post
                          This thread is an effective example of how diverse methods can be used to solve a problem in HS. I'm enjoying the creativity and am impressed by the innovative thinking. I hope there are still more suggestions to come.
                          OK. Clearly taking from Jon's suggestion, here is a single event with a single Virtual Device "Recycle Day".

                          Click image for larger version

Name:	Capture.PNG
Views:	1
Size:	52.8 KB
ID:	1190728

                          Manually turn the device on on your first recycle day and it will be on again 4 weeks later on the same day. It will repeat indefinitely. If your recycle day changes to Wednesday, turn the device on that morning and it will be every 4th Wednesday.
                          Randy Prade
                          Aurora, CO
                          Prades.net

                          PHLocation - Pushover - EasyTrigger - UltraECM3 - Ultra1Wire3 - Arduino

                          Comment

                          Working...
                          X