Announcement

Collapse
No announcement yet.

Issue Creating New Events, Console, 4 Month+ Recurring Event

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

    Issue Creating New Events, Console, 4 Month+ Recurring Event

    Hello all,

    I wrote some code, that will be executed when an OFF is given for a q2 virtual device. When that device turns off, the code is supposed to increment the date by 4 months, correct for day of the week (execut only on saturday +- 1week (as in the next comming Saturday or previous saturday at 4 months from now() ).

    The issue I have is with VB syntax:


    -------------------------------
    sub main()
    dim thisDay,dayNum,dayMon,newDate,temp
    thisDay = Day(now())
    dayNum = weekDay(now())
    thisMon = Month(now())
    thisYear = Year(now())

    thisMon = thisMon + 4
    if thisMon > 12 then
    thisMon = thisMon - 12
    thisYear = thisYear + 1
    end if
    if dayNum <> 7 then 'make it a saturday for alert
    temp = thisDay + (7 - dayNum)
    if temp > 25 then
    thisDay = thisDay - (dayNum + 1)
    end if
    end if
    newDate = thisMon + "/" + thisDay + "/" + thisYear
    hs.NewTimeEvent "Britta Trigger", "8:00 AM",newDate,0,0,0,0,0,1,1,"q2n",1,""
    end sub

    ----------------------------

    newDate = thisMon + "/" + thisDay + "/" + thisYear

    This line is NOT being liked by Homeseer. It seems to complain that I am adding in the /


    However to make the NewTimeEvent work, you need to add a date that follows the "system" format. Which I just pull out using now(), then increment 4 months. I don't need a really exact date, as the closest Saturday will work. Then when I finally change the filter, I click "OK" on a script, which resets q2 to off, and executes this script again, which 4 months from the date when the q2 was changed back to off, I should get another alert (when q2 goes to on, my Audreys have a script where they will perform an alert function using the mail LED).

    Any thoughts as to why this does not seem happy?

    Then, next step, one that runs ever 2 weeks to tell that the sheets need to be changed.

    Thanks!

    --Dan
    Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

    #2
    ok, I'm a C++ guy...

    VB apparently concatenates strings with & not +

    Also, fixed some logic, in case anyone wants the "fixed" code:

    'resets Britta Filter reminder every 4 months, on saturday only
    sub main()
    dim thisDay,dayNum,dayMon,newDate,temp
    thisDay = Day(now())
    thisMon = Month(now())
    thisYear = Year(now())

    thisMon = thisMon + 4
    if thisMon > 12 then
    thisMon = thisMon - 12
    thisYear = thisYear + 1
    end if
    newDate = thisMon & "/" & thisDay & "/" & thisYear
    dayNum = weekDay(newDate)
    if dayNum <> 7 then 'make it a saturday for alert
    temp = thisDay + (7 - dayNum)
    if temp > 25 then
    thisDay = thisDay - (dayNum + 1)
    else
    thisDay = temp
    end if
    end if
    newDate = thisMon & "/" & thisDay & "/" & thisYear
    hs.NewTimeEvent "Britta Trigger", "8:00 AM",newDate,0,0,0,0,0,1,1,"q2ff",1,""
    end sub
    Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

    Comment

    Working...
    X