I wanted something that could track historical device usage in my home, so I created the RunTimer2 driver. It doesn't create a lot of fields (five per timer), but it does have a powerful reporting mechanism based on TextLists and the StaticListBrowser. I have included the driver, some pictures and a popup template for viewing the data. ┬Here is the driver documentation
Broderware/Run Timer2
Description:
This driver gives the ability to record and track statistics about how often and how long a device has been running.
It provides field information about the duration of the current run, the number and duration of runs in the last 24 hours.
It also provides a StringList based report mechanism which lists all runs in the last 24 hours, and d/w/m/y summary information.
The driver also allows you to configure the time at which your day begins (default 00:00:00) for summary and Today information.
Quirks and Limitations:
The 24 hour state of all timers is saved in a file when the driver shuts down (and every 20minutes).
When the driver restarts it will read this state and seamlessly continue its work if the state is less than a day old.
Any device transitions that occur during the downtime will, of course, be missed.
However the driver will react to new state when it restarts, so if a device was off when this driver shutdown and it
is on when the driver restarts, this driver will assume the device has just turned on.
The daily summary information for each timer is stored in a spreadsheet friendly csv file
CQC\CQCData\MacroFileRoot\Drivers\RunTimer2\<moniker>_<timer>_daily.csv at the beginning of each new day.
If this driver is not running at the beginning of the day summary information will be lost for the previous day.
To find out if the timed device is on or off with high accuracy, the driver relies on field triggers and a single event (described below).
Polling is available as an option as well and is performed at 10 second intervals.
Connection Details:
This driver does not make a connection to any device or port. It uses SimpleFldClient to talk to other drivers.
Config File
Timers must be configured by creating a file
CQC\CQCData\MacroFileRoot\Drivers\RunTimer2\<moniker>_config.csv
Each line contains TimerName, Moniker.FieldName[!], RunningValue, Comparator, startDelay, stopDelay (params after RunningValue optional)
The ! after FieldName indicates that polling is required for this timer.
The Comparator parameter indicates the desired comparison. So far = (default), >, and < are supplied.
Comparisons are now performed in the field's data type. Note: Time data is a TimeStamp in Hex (i.e. 0x36B9DDA7D46140)
StartDelay and StopDelay (seconds) are used for devices that glitch a little, but aren't truly started (or stopped)
until they have been in the new state for a while.
Here are some sample lines from my config file:
AtticFan, Security.Output020, True
SpaHeat, Pool.SpaHeatActive, True
FurnaceALow, FurnaceA.S1_Demand, 1
FurnaceAMed, FurnaceA.S1_Demand, 2
FurnaceAHigh, FurnaceA.S1_Demand, 3
FrontDoor, Security.PhysZone001, Violated
LaundryWasher, Power2.RESMON#LaundryWasher~Watts, 6, >, 5, 10
LaundryDryer, Power2-.RESMON#LaundryDryer~Watts!, 20, >
TimeTest, Variables.CarTimeWest, 0x36B9DDA7D46140, >
PGEPowerFail, Power1.RESMON#Panel~Voltage, 100, <
END
Field names are created automatically for a given run timer name.
Because of that, the names entered during the driver install process must be unique, and conform to normal field naming restrictions.
To force the driver to reload its configuration, use the Server Administration window to Pause/Resume the driver.
Driver Fields
<Name>_TimeThisRun R Time Duration of the current run if running, zero otherwise
<Name>_Runs24HRs R Card4 Number of runs in the last 24 hours
<Name>_Time24HRs R Time Total Run Time in the last 24 hours
<Name>_RunsToday R Card4 Number of runs today (since the beginning of the day)
<Name>_TimeToday R Time Total Run Time today (since the beginning of the day)
Commands
To notify the driver that a timer has turned on or off you can send it a command:
ID=Moniker.Field
ToSet=NewFieldValue
To support non-polled fields add a Trigger to the timer fields, and create a single event to call the driver.
To reduce the number of events for fields that have lots of values (i.e. Watts) only send triggers if expression is true,
use the identical expression, and enable Bidirectional latching (Dean added this for me in 5.3.913).
Here is the event you need:
Is Field Change
Is Device Ready this_moniker
Logic: All True
Action
Devices::SendDrvCmd(this_moniker, %(TEvRTV:SrcField), %(TEvRTV:NewFldVal))
QueryText
This driver supports the QueryText function for extracting detailed report information.
The ID should be set to the TimerName, and the Value should be one of:
24HRs Returns a stringlist with start, stop and elapsed time for all runs in the last 24HRs
24HRs.Runs Returns the number of runs started in the last 24HRs (get the stringlist first)
24HRs.Time Returns the total run time in the last 24HRs HH:MM:SS (get the stringlist first)
Today Returns a stringlist with start, stop and elapsed time for all runs today
Today.Runs Returns the number of runs today (get the stringlist first)
Today.Time Returns the total run time today HH:MM:SS (get the stringlist first)
Daily Returns a stringlist with the date, number of runs, total time for all days (including today)
Weekly Returns the list of data summarized by week
Monthly Returns the list of data summarized by month
Yearly Returns the list of data summarized by year
<type>! The ! modifier eliminates uninteresting periods (i.e. no runs and no time)
<type>.Periods Returns the total number of periods in the result (get the stringlist first)
<type>.Runs Returns the total number of runs ever (get the stringlist first)
<type>.Time Returns the total run time ever DD:HH:MM (get the stringlist first)
<type>.Lines Returns the total number of lines in the daily log file (get the stringlist first)
<type>.LastPeriodRuns Returns the number of runs in the last (current) period (get the stringlist first)
<type>.LastPeriodTime Returns the runtime of the last (current) period (get the stringlist first)
Also note: after the period name you might see an *, this means there was some missing data during that period.
If you see an !, it means there is no data at all for the period.
Hopefully graphing support will be added in the future...
Broderware/Run Timer2
Description:
This driver gives the ability to record and track statistics about how often and how long a device has been running.
It provides field information about the duration of the current run, the number and duration of runs in the last 24 hours.
It also provides a StringList based report mechanism which lists all runs in the last 24 hours, and d/w/m/y summary information.
The driver also allows you to configure the time at which your day begins (default 00:00:00) for summary and Today information.
Quirks and Limitations:
The 24 hour state of all timers is saved in a file when the driver shuts down (and every 20minutes).
When the driver restarts it will read this state and seamlessly continue its work if the state is less than a day old.
Any device transitions that occur during the downtime will, of course, be missed.
However the driver will react to new state when it restarts, so if a device was off when this driver shutdown and it
is on when the driver restarts, this driver will assume the device has just turned on.
The daily summary information for each timer is stored in a spreadsheet friendly csv file
CQC\CQCData\MacroFileRoot\Drivers\RunTimer2\<moniker>_<timer>_daily.csv at the beginning of each new day.
If this driver is not running at the beginning of the day summary information will be lost for the previous day.
To find out if the timed device is on or off with high accuracy, the driver relies on field triggers and a single event (described below).
Polling is available as an option as well and is performed at 10 second intervals.
Connection Details:
This driver does not make a connection to any device or port. It uses SimpleFldClient to talk to other drivers.
Config File
Timers must be configured by creating a file
CQC\CQCData\MacroFileRoot\Drivers\RunTimer2\<moniker>_config.csv
Each line contains TimerName, Moniker.FieldName[!], RunningValue, Comparator, startDelay, stopDelay (params after RunningValue optional)
The ! after FieldName indicates that polling is required for this timer.
The Comparator parameter indicates the desired comparison. So far = (default), >, and < are supplied.
Comparisons are now performed in the field's data type. Note: Time data is a TimeStamp in Hex (i.e. 0x36B9DDA7D46140)
StartDelay and StopDelay (seconds) are used for devices that glitch a little, but aren't truly started (or stopped)
until they have been in the new state for a while.
Here are some sample lines from my config file:
AtticFan, Security.Output020, True
SpaHeat, Pool.SpaHeatActive, True
FurnaceALow, FurnaceA.S1_Demand, 1
FurnaceAMed, FurnaceA.S1_Demand, 2
FurnaceAHigh, FurnaceA.S1_Demand, 3
FrontDoor, Security.PhysZone001, Violated
LaundryWasher, Power2.RESMON#LaundryWasher~Watts, 6, >, 5, 10
LaundryDryer, Power2-.RESMON#LaundryDryer~Watts!, 20, >
TimeTest, Variables.CarTimeWest, 0x36B9DDA7D46140, >
PGEPowerFail, Power1.RESMON#Panel~Voltage, 100, <
END
Field names are created automatically for a given run timer name.
Because of that, the names entered during the driver install process must be unique, and conform to normal field naming restrictions.
To force the driver to reload its configuration, use the Server Administration window to Pause/Resume the driver.
Driver Fields
<Name>_TimeThisRun R Time Duration of the current run if running, zero otherwise
<Name>_Runs24HRs R Card4 Number of runs in the last 24 hours
<Name>_Time24HRs R Time Total Run Time in the last 24 hours
<Name>_RunsToday R Card4 Number of runs today (since the beginning of the day)
<Name>_TimeToday R Time Total Run Time today (since the beginning of the day)
Commands
To notify the driver that a timer has turned on or off you can send it a command:
ID=Moniker.Field
ToSet=NewFieldValue
To support non-polled fields add a Trigger to the timer fields, and create a single event to call the driver.
To reduce the number of events for fields that have lots of values (i.e. Watts) only send triggers if expression is true,
use the identical expression, and enable Bidirectional latching (Dean added this for me in 5.3.913).
Here is the event you need:
Is Field Change
Is Device Ready this_moniker
Logic: All True
Action
Devices::SendDrvCmd(this_moniker, %(TEvRTV:SrcField), %(TEvRTV:NewFldVal))
QueryText
This driver supports the QueryText function for extracting detailed report information.
The ID should be set to the TimerName, and the Value should be one of:
24HRs Returns a stringlist with start, stop and elapsed time for all runs in the last 24HRs
24HRs.Runs Returns the number of runs started in the last 24HRs (get the stringlist first)
24HRs.Time Returns the total run time in the last 24HRs HH:MM:SS (get the stringlist first)
Today Returns a stringlist with start, stop and elapsed time for all runs today
Today.Runs Returns the number of runs today (get the stringlist first)
Today.Time Returns the total run time today HH:MM:SS (get the stringlist first)
Daily Returns a stringlist with the date, number of runs, total time for all days (including today)
Weekly Returns the list of data summarized by week
Monthly Returns the list of data summarized by month
Yearly Returns the list of data summarized by year
<type>! The ! modifier eliminates uninteresting periods (i.e. no runs and no time)
<type>.Periods Returns the total number of periods in the result (get the stringlist first)
<type>.Runs Returns the total number of runs ever (get the stringlist first)
<type>.Time Returns the total run time ever DD:HH:MM (get the stringlist first)
<type>.Lines Returns the total number of lines in the daily log file (get the stringlist first)
<type>.LastPeriodRuns Returns the number of runs in the last (current) period (get the stringlist first)
<type>.LastPeriodTime Returns the runtime of the last (current) period (get the stringlist first)
Also note: after the period name you might see an *, this means there was some missing data during that period.
If you see an !, it means there is no data at all for the period.
Hopefully graphing support will be added in the future...