Announcement

Collapse
No announcement yet.

triggering on the day after

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

    triggering on the day after

    Hopefully I am missing something basic, but I am looking to find a way to trigger an event 'the day after' a specific day...

    What I want to do, is to trigger an event at 1:30am on a Sunday morning - but only the Sunday morning on the day after the 2nd Saturday of the month, and I can't seem to find a way.

    At the moment, I've got it working using the 2nd Sunday of the month, which works most of the time, but if the month starts on a Sunday, then it would be the 3rd Sunday of the month.

    For instance, May 2008, starts on a Thursday. The 2nd Saturday is the 10th, and the 2nd Sunday is the 11th, so the 2nd Sunday would work fine in this case.

    However June 2008 starts on a Sunday. The 2nd Saturday is the 14th, and I want to trigger the event on the 15th, which in this case is the 3rd Sunday, and not the 2nd.

    What am I missing? And if I'm not missing anything, is there any way to get round this, without putting specific dates into the triggers.


    G

    #2
    While not an elegant solution, you could do this with two events and a virtual device. Make your first event one that is triggered by a condition and make that condition be the 2nd saturday of the month. Set a virtual device to ON. Now create a second event that runs every Sunday but also requries the virtual device is ON. Within your actions turn the virtual device back OFF.

    Comment


      #3
      Ok, this is of the top of my head. It's a conversion of script I use to remind me of garden rubish collections which only occur every so often. In your case you would have an event set to trigger every saturday and run the following event at whatever time you wish the happening to happen the next day.
      Code:
      Sub Main(parm as object)
       
       Dim DOW as Integer = 1   ' Saturday
       Dim Inst as Integer = 1     ' First instance (First Saturday of the month)
       Dim bReturn As Boolean
       
       bReturn = hs.IsSpecialDay(DOW, Inst,)
       If bReturn = True Then
       
      dim T
      dim lo_event
      T=dateadd ("N",+1440,NOW) ' this is the time lapse before trigger the example is 24 hours
      hs.NewTimeEvent "It's the first Sunday",T,"",1,1,1,1,1,1,1,"",1,"First Sunday.txt","System"
         Set lo_event = hs.getEventEx ("It's the first Sunday")
         lo_event.misc2 = &H80 ' Include this object (=event) in power failure recvory
         lo_event.misc = &H4010  ' Disable logging and set 'delete after trigger'
       
       
      end if
       
      End Sub
      First Sunday.txt is a script which you must write to do whatever it is you wish to do that sunday, all this will do is create an event to run that script then delete the event after it has run then recreate it on the first Saturday of the following month.

      Untested, but should work. I'm going to try it myself as I like the idea.
      sigpic
      A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

      Comment


        #4
        Originally posted by Msekelsky View Post
        While not an elegant solution, you could do this with two events and a virtual device......
        Hmm, spend Aggies trying to come up with an idea, and when I post it you have beaten me to the post.

        Yes like your idea, it's probably a lot more simple. Mine is better of course, if it works!
        sigpic
        A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

        Comment


          #5
          Originally posted by Gogs View Post
          Yes like your idea, it's probably a lot more simple. Mine is better of course, if it works!
          If it works it can meet the "elegant" requirement.

          Comment


            #6
            Another approach would be a conditional event trigger:

            Today is the SECOND Saturday of Any Month AND
            Time is at 1:30 AM

            Action: run a script like...

            Sub Main(Parm as Object)
            hs.waitsecs(60) ' to ensure the delayed event doesn't trigger immediately
            hs.NewTimeEvent("delayed event","1:30 am", "", 1, 1, 1, 1, 1, 1, 1, "", 1, "YourActionScript.txt","")
            hs.EnableEvent("delayed event")
            End Sub

            I haven't tried this but it ought to work.
            Real courage is not securing your Wi-Fi network.

            Comment


              #7
              OK, I see that during the time I was writing that, Gogs beat me to it.
              But, I just tried it and the event was created ready to fire. I too can think of some applications for this.
              Real courage is not securing your Wi-Fi network.

              Comment


                #8
                Originally posted by Msekelsky View Post
                If it works it can meet the "elegant" requirement.
                I may find out if G tries it.

                I wonder what the "Aggies" are in my last post!

                It is a new word for a virus of the Brain meaning I spent some time comming up with the idea.

                Even if G does not give it a twirl, I am going to because if it works it opens up a lot of simple ways of doing thing which i have a long script to do.

                Per example, this is my garden rubbish collection script, it works perfectly, but I have to re-write all the dates every year, and I also have one that triggers the night before, and that has to be re-written every year.

                How much simpler, if my elegant idea works, NO?
                Code:
                sub main()
                d=date
                if left(d,5)="02/04" or left(d,5)="16/04" or left(d,5)="30/04" or left(d,5)="14/05" or left(d,5)="28/05" or left(d,5)="11/06" or left(d,5)="25/06" or left(d,5) = "09/07" or left(d,5) = "23/07" or left(d,5) = "06/08" or left(d,5) = "20/08" or left(d,5) = "03/09" or left(d,5) = "17/09" or left(d,5) = "01/10" or left(d,5) = "15/10" or left(d,5) = "29/10" then
                i=hs.NewEventGetRef("Garden Rubbish")
                set ev=hs.geteventByRef(i)
                ev.ev_trig_func=2
                ev.ev_abs_time=3
                ev.ev_trig_hc="A"
                ev.ev_trig_dc="15"
                ev.misc=&H10+&H4000
                hs.AddAction i,3,"People.Pay attention here. Tomorrow is garden rubbish day. Have you put the bucket out?","Control:Livingroom",True
                set ev=nothing
                end if
                end sub
                sigpic
                A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                Comment


                  #9
                  Originally posted by Wadenut View Post
                  OK, I see that during the time I was writing that, Gogs beat me to it.
                  But, I just tried it and the event was created ready to fire. I too can think of some applications for this.
                  Sir, I did not beat you to it, it was never a competition. Obviously, because of the time difference, I read it before you did, and replied.

                  All input is always welcome, regardless of order of posting, you may be correct I have never tested what I posted, just straight of the top of my head, but I think once the syntax is corrected it would work.

                  Take care.
                  sigpic
                  A founder member of "The HA Pioneer Group" otherwise known as the "Old farts club!"

                  Comment


                    #10
                    Originally posted by Gogs View Post
                    Sir, I did not beat you to it, it was never a competition.
                    No competition implied, nor intended. I was only commenting on my own "Aggies" dreaming it up...
                    Real courage is not securing your Wi-Fi network.

                    Comment


                      #11
                      Trigger on the Saturday, then put a 24 hour delay on the event action(s). HomeSeer will create delayed device actions or delayed events, and they will be carried out a day later, even if HS is restarted.
                      Regards,

                      Rick Tinker (a.k.a. "Tink")

                      Comment


                        #12
                        Originally posted by Rick Tinker View Post
                        Trigger on the Saturday, then put a 24 hour delay on the event action(s). HomeSeer will create delayed device actions or delayed events, and they will be carried out a day later, even if HS is restarted.

                        I don't think any of us realized that.
                        And the winner is..... Tink!
                        Real courage is not securing your Wi-Fi network.

                        Comment


                          #13
                          Course Tink is the winner.
                          So I'll take a stab at honorable mention...
                          I think this will work.
                          Stuart

                          Use a conditional event
                          If sunday and time is 1:30am

                          then run a script
                          sub main ()
                          if day(now) > or = 9 and day(now) < or = 15 then trigger event
                          end if
                          end sub

                          Comment

                          Working...
                          X