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
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
Comment