===== Timers =====
{{indexmenu_n>840}}
The timer feature is based on the software utility "cron". The purpose is to trigger reoccurring actions such as "Set register" or "Force alarm". Cron expressions are entered into each of the "Time setting" fields to describe the periodic interval for an action. The cron expressions work as filters. At the beginning of every second, the timer evaluates each filter's true or false status. If all of the cron expression are true compared to the current date & time the action will be triggered.
"Time settings" span from seconds to months and also allow for days of the week to be specified. The cron expressions allow tremendous flexibility. Numbers can be entered to be true once during a specific second, minute, day, or month, or special characters such as commas, dashes, slashes and asterisks, allow the timer to skip, span, alternate or always be true. For more information see [[https://en.wikipedia.org/wiki/Cron]]
Timers run on the ezeio, therefore reference the time zone set in the configuration of the individual ezeio.
**Example 1: If all filters have an asterisk (*), then the timer will be triggered every second**
{{ ezeio2:userinterface:configuration:time_set_tick.png?direct | }}
**Example 2: If minute is set to 0, day is set 31 and month to 12, the timer will trigger 60 times during the first minute of every hour on December 31st**
{{ ezeio2:userinterface:configuration:time_set_newyears.png?direct | }}
==== Unit of time filters =====
When a new timer is created, the default setting in each time setting field is "0". //This timer configuration will never trigger as there is no month zero//. Hover over each field for tips on scheduling multiple triggers per unit of time. More information is available in the next section "special characters".
The basic format of each unit of time is described below.
**Day of the week** - Enter the day/s of the week you wish to be true (0 = Sunday) or enter an asterisk (*) to make true every day of the week.
**Month** (1 to 12) - Enter the month/s of the year you wish to be true (1 = January) or enter an asterisk (*) to make true every month.
**Day** (of the month) - Enter the day/s of the month you wish to be true (1 through 31) or enter an asterisk (*) to make true every day of the month.
**Hour** (of the day) - Enter the hour/s of the day you wish to be true (0 to 23) or enter an asterisk (*) to make true every hour of the day/s.
**Minute** (of the hour) - Enter the minute/s of the hour/s you wish to be true (0 to 59) or enter an asterisk (*) to make true every minute of the hour/s.
**Second** (of the minute) - Enter the second/s of a minute/s you wish to be true (0 to 59) or enter an asterisk (*) to make true every second of the minute/s.
==== Special characters =====
As mentioned above special characters can be used to describe multiple increments or spans within a unit of time. Examples are shown in the table below.
| **Character** | **Function / Meaning** | **Example** |
| Asterisk (*) | * means true | Minute * = true every minute of within an hour |
| Comma (,) | Separate multiple units of time | 5,37,49 True if = 5 or 37 or 49 |
| Dash (-) | Spans from the beginning value through the ending value | 7-53 True from 7 through 53 |
| Forward slash (/) | Beginning at __x__ and then every __y__ | 2/3 = 2, 5, 8, 11, 14, 17 or Feb, May, Aug, Nov|
==== Timer Actions ====
These actions allow the direct manipulation of "Fields", registers, alarms, and user script, based on the reoccurring trigger and settings described below.
| **Action** | **Description** | **Index** | **Parameter** | **Value** |
| Set Field | Replace Field's value with value specified in action | Field # | N/A | New value |
| Adjust Field | Reduce or increase Field's value by amount specified in action | Field # | N/A | Adjustment value |
| Set Register | Replace registers' value with value specified in action | Device # | Register # | New value |
| Adjust Register | Reduce or increase registers' value by amount specified in action | Device # | Register # | Adjustment value |
| Force Alarm | Immediately triggers __alarm actions__ associated with an alarm | Alarm # | N/A | N/A |
| Force Restore | Restores alarm and triggers __restore actions__ associated with an alarm | Alarm # | N/A | N/A |
| Script Action | | | | |
**Example 1:** Reset counter daily with "Set Field".
* Weekday = *
* Month = *
* Day = *
* Hour = 23
* Minute = 59
* Second = 59
* Command = Set Field
* Index (Field #) = 6
* Parameter = (Not applicable)
* Value = 0
**Example 2:** Send a message with data and/or statuses every day at 3:25pm using "Force alarm".
* Weekday = *
* Month = *
* Day = *
* Hour = 15
* Minute = 25
* Second = 0
* Command = Force Alarm
* Index (alarm #) = 3
* Parameter = (Not applicable)
* Value = (Not applicable)