All chapters
Rules
Rules turn events into outcomes. Each one reads as a sentence: WHEN an event arrives from the sources it listens to, IF its conditions hold, THEN its actions run, OTHERWISE other actions run. Rules are evaluated the moment an event arrives and, for conditions about time passing, every 30 seconds.
Anatomy of a rule#
WHEN: the trigger#
The trigger narrows which events the rule listens to. Choose its type, then filter.
| Type | Starts the rule when | Filters |
|---|---|---|
| Sensor | A sensor reports an event. | Sensor category, sensor type or specific sensors; the event's nature (alarm, restore, trouble); the event type, for example Threshold exceeded to react only to a sensor's own limit being crossed. |
| Person | A person reports an event. | Specific people, the event's nature. |
| Panel | An alarm panel reports an event. | Specific panels and zone numbers, the event's nature. |
| Schedule | A schedule switches on, off or both. | The schedules and the direction. See Schedules. |
| Condition | A state has lasted, judged on the clock rather than by an event. | For rules such as “sensor offline for 30 minutes”, “nobody has checked in” or “incident older than an hour”. |
IF: the conditions#
IF is a list of conditions that must all hold, with optional any of groups. The Advanced canvas adds nested logic, counting, sequences and sustained conditions (below). A rule with no conditions fires on every event its trigger matches.
THEN and OTHERWISE: the actions#
THEN lists the actions that run when the conditions hold; OTHERWISE lists those that run when a matching event arrives but the conditions fail. Each action has a policy for when it runs: on a new incident only (the default for notifications, so a flapping sensor does not send a mail per reading), on every event (the default for state changes) or when the incident resolves.
Conditions#
The editor offers 27 kinds of condition in five groups, plus the logic group below. Clock marks a condition that is also checked on the timer, so it can become true without any event arriving. Canvas marks one that only the Advanced canvas offers.
Sensors
| Condition | True when |
|---|---|
| Sensor typecanvas | The triggering sensor is one of these categories or types. |
| Value threshold | The reading's value is above, below or equal to a number. |
| Value change | The value changed by at least this much over the last N readings. |
| Sensor state | A sensor is online, offline, in alarm, restored, armed or disarmed. |
| Sensor offline forclock | A sensor has been offline for at least N minutes. |
| Sensor count | How many sensors at the place are in a given state. |
| Recent eventclock | An event of a kind happened (or did not) in the last N minutes. |
| Event frequency | How many events of a kind happened in the last N minutes. |
| Profile armed | An arming profile is armed (or not), or the sensor that fired is guarded by an armed profile. Intruder detection. |
| Object detected | A camera's object detection sees a person, vehicle or animal appear, optionally in a region. Not when it goes away. |
Time
| Condition | True when |
|---|---|
| Time of day | Between two times; wraps midnight. |
| Day of week | Only on these weekdays. |
| Date range | Between two calendar dates. |
| Annual period | A recurring period every year, e.g. 24 Dec to 6 Jan. |
| Sunrise / sunset | Before or after sunrise or sunset at the place. |
| Schedule | A named schedule (business hours, a maintenance window …) is active, or is not. |
| Cooldown | The rule has not fired in the last N minutes. |
| Daily limit | How many times the rule has fired today. |
Incidents
| Condition | True when |
|---|---|
| Ongoing incident | An incident is currently ongoing (optionally of a domain and minimum severity). |
| Incident older thanclock | An ongoing incident has lasted at least N minutes. |
| Incident confidence | An ongoing incident has at least this confidence. |
People
| Condition | True when |
|---|---|
| Person status | A person is online, offline or has raised a panic alarm. |
| Person not movingclock | A person has not moved for at least N minutes. |
| Person not reportingclock | A person has not checked in for at least N minutes. |
| Geofence | A person is inside or outside a geofence. |
Variables
| Condition | True when |
|---|---|
| Variable | A rule variable exists or has a value. |
| Variable number | A rule variable's number compared to a value. |
Combining conditions#
The logic group combines conditions. Groups nest on the canvas, and a rule the form cannot show opens on the canvas by itself.
| Operator | True when |
|---|---|
| All of / Any of | Every / at least one of the conditions inside is true. |
| Not / Not all of / None of | The inverse of the above. |
| Exactly one of | Exactly one condition is true. |
| At least N of / At most N of / Exactly N of | The number of true conditions meets the count. |
| In sequence | The conditions became true in the given order, within a time window. |
| Sustained for | The conditions have stayed true for the whole window. |
Actions#
A rule has 12 kinds of action. Actions run in order; a failure in one never stops the others.
| Action | What it does |
|---|---|
| Create incident | Open an incident (or add this event to the ongoing one). |
| Send email | Email one or more recipients. |
| Call webhook | HTTP request to an external URL. |
| Set variable | Set or increment a rule variable, optionally expiring. |
| Clear variable | Delete a rule variable. |
| Resolve incident | Resolve the ongoing incident of this rule. |
| Escalate incident | Raise the incident's severity or confidence. |
| Arm zone | Send an arm command to an alarm integration URL. |
| Disarm zone | Send a disarm command to an alarm integration URL. |
| Arm place | Arm a profile of a place, unless one of its sensors is open. |
| Disarm place | Disarm a profile of a place. |
| Operate device | Switch, lock, open or sound an output (light, lock, siren …), optionally for a while. |
E-mail and webhooks#
- E-mail needs outbound mail configured (
Notifications:Smtp). Without it, rule e-mails are skipped with a warning. A mail links back to the incident throughAppBaseUrl. - Webhooks make an HTTP request (GET, POST or PUT) with your headers and body. Calls go to public addresses only: private, loopback and link-local addresses are refused unless you allow them with
Webhooks:AllowedHostsorWebhooks:AllowPrivateAddresses; redirects are not followed and a call times out after 10 seconds. Resolved addresses are pinned, so a name cannot be swapped for a private address in between. - Both accept templates:
{{incident.id}},{{incident.rule}},{{incident.sensor}},{{incident.person}},{{incident.domain}},{{incident.severity}},{{incident.confidence}},{{incident.triggeredAt}},{{incident.value}},{{incident.unit}},{{event.type}},{{event.nature}},{{event.severity}},{{event.source}},{{event.value}}and{{event.at}}. Values placed in a JSON body are escaped so they cannot break out of their field. - E-mail and webhook calls are queued and delivered in the background, so a slow mail server never delays the ingest of events.
Variables#
Set variable and Clear variable maintain named values shared by every rule of the organisation: a flag such as “armed”, or a counter with increment and an optional expiry. The Variable and Variable number conditions test them. They are how one rule tells another what it saw.
Operating devices#
Operate device sends a command to an output: one output, every output of a kind at the event's place, or a zone and the zones inside it. Optionally it lasts for a number of minutes, after which the previous state is restored. Sensitive outputs such as locks, door strikes and sirens may be operated by a rule because rules are trusted. A rule never re-triggers itself through the state change its own command causes. See Devices.
Arming a place#
Arm place and Disarm place arm or disarm an arming profile of a place, the Profile armed condition tests it, and the Arming change trigger starts a rule when a profile is armed, disarmed or refused. They are not the Arm zone and Disarm zone actions, which send a command to an alarm panel's integration URL. See Arming.
Incidents from rules#
Create incident opens an incident or adds the event to the one that is ongoing for the same source and domain. Three settings on the rule shape the result:
- Grouping. One incident per sensor or person, per place (so several sensors in one place corroborate each other and raise confidence), or one for the whole organisation.
- Auto-resolve after N minutes without a new event, so a quiet incident closes by itself.
- Resolve when the source restores. A door closes, a panel zone restores, a sensor comes back online, a limit is back inside: the incident closes. For a rule that starts on a schedule, the end of the schedule resolves it, which is how a rule gets a fresh incident each day.
Keeping the noise down#
- The Cooldown condition keeps a rule from firing again within N minutes of its last firing, and Daily limit caps how often it fires in a day (in your time zone).
- Notify at most every N minutes (per source) skips e-mails and webhooks inside the window while the incident itself keeps updating.
- Grouping by place and the default new incident only policy mean a burst of readings becomes one incident and one mail.
- Each firing is recorded, and the rules list shows when each rule last fired.
Building and testing#
- Form. The default editor, laid out as WHEN, IF, THEN, OTHERWISE and Settings, with a one-sentence summary of the rule that updates as you edit.
- Advanced. A node canvas for nested logic, with zoom, fit and automatic layout. It is not keyboard-navigable; the form is the accessible path.
- Test. Replays recent stored events (the last hour, 6 hours, 24 hours or 7 days; up to 40 events) through the rule as it is on screen, unsaved. For each event it shows which conditions passed or failed and how many events would have fired the rule. Nothing is saved, sent or operated. For a schedule trigger it replays the schedule's switches instead.
- List. The rules page has search, an enabled filter and toggle, and flags a rule without conditions and actions as needing attention. Viewers see rules read-only.
Worked examples#
| Rule | WHEN | IF | THEN |
|---|---|---|---|
| After-hours entry | Sensor: category Access control, nature Alarm | Schedule “Business hours” is not active | Create incident (High); e-mail the duty officer |
| Freezer too warm | Sensor: the freezer's own limit is crossed | Daily limit: at most 3 today | Create incident; call a webhook; resolve when the value returns |
| Person at the gate at night | Sensor: the gate camera | Object detected: person, region Gate; Sunrise / sunset: after sunset | Create incident; sound the siren for 5 minutes |
| Panic | Person: any, event PanicAlarm | None | Create incident (Critical); e-mail; flash the lights |
| Lone worker went quiet | Condition: person | Person not reporting for 30 minutes | Create incident; e-mail the supervisor |