Kaz, why not use a Timer?
The attached image shows a Timer I use in my TaskEx class. DailyTaskController has a half-hour resolution (TimeUnit=Minute and Interval=30) and triggers at 1 minute after midnight as specifed by Filter=* 1 0 * * * (like Unix cron: Seconds Minutes Hours DayOfMonth Months DayOfWeek). When it triggers, the OnChangeTrigger script is executed.
If you've used the Class Wizard to create a new serial device class called 8870DT, you now have a new module that has a
Timers container.
- Right-click Timers and select: New > Timer
- Check the online help to configure the Timer's properties.
- Right-click the newly created Timer and select: New > Property Change and then select Trigger.
- Enter the appropriate script to update the thermostat.
Based on your example :
devices.customDevices.8870DT.setDate.send = TRUE
devices.customDevices.8870DT.setTime.send = TRUE
I believe you have created two Commands,
setDate and
setTime, like those shown in the second attached image.
TxTextData contains the data to be sent to the thermostat. However, you'll have to update this string, to the current date/time, before sending it. This operation can occur in the
OnChangeTrigger script.
IMPORTANT: You've created a class called 8870DT. The first character of the class's name should be alphabetic, never numeric. This rule comes from VBScript's naming conventions. This class name will cause problems when you attempt to write scripts with it. In the attached image, I've renamed it to DT8870.
The
OnChangeTrigger script will look something like this:
Code:
' Update the date string to be sent to the the thermostat (SN0 DATE=MMDDYY)
Devices.CustomDevices.DT8870.setDate.TxTextData = _
"SN0 DATE=" & _
gZeroPad(month(now), 2) & _
gZeroPad(day(now), 2) & _
right(year(now), 2)
' Send the string to the thermostat
Devices.CustomDevices.DT8870.setDate.send = true
' Update the time string to be sent to the the thermostat (SN0 TIME=HHMM)
Devices.CustomDevices.DT8870.setTime.TxTextData = _
"SN0 TIME=" & _
gZeroPad(hour(now), 2) & _
gZeroPad(minute(now), 2)
' Send the string to the thermostat
Devices.CustomDevices.DT8870.setTime.send = true
I don't know if you need the ZeroPad function. If "SN0 DATE=MMDDYY" means that Month (MM) must be represented by two digits, you'll have to prepend a zero if the month is less than 10 (i.e. "08" for August and not just "8"). Put the gZeroPad function in GlobalScripts and it'll be accessible to all Modules.
Code:
' Pad a number with leading zeros
function gZeroPad(sNumber, iWidth)
gZeroPad = right(string(iWidth, "0") & sNumber, iWidth)
end function
BTW, I'd appreciate it if you could point me in the direction of the updated Aprilaire documentation. My version doesn't mention the DATE and TIME options.