Rules
How Rules Work
Every rule expresses a single statement: when all of these conditions are met, run these actions in order. That is the entire model; everything else is detail settings.
Conditions are combined with AND. A rule fires once at the moment all conditions become true together, and does not fire repeatedly while they remain true. To fire again, at least one condition must become false and then true again.
Conditions
A condition defines the situation to monitor. Clicking + Add condition shows twelve condition types.
| Condition | Monitors |
|---|---|
| AI Camera | Camera video: people, faces, plates, fire, codes, text, or targets you trained. |
| Schedule | Days of the week and time ranges. |
| Interval | A repeating cycle at a fixed interval. |
| I/O Device | A sensor reading or a board input. |
| MQTT · Modbus · OPC UA · User Defined Comm | Values received from a broker, a PLC, or a custom protocol. |
| Telegram | Messages received by your bot. |
| Sound Classification | Sounds such as breaking glass, a barking dog, or an alarm. |
| Speech To Text (STT) | A spoken phrase. |
| Custom Condition | Evaluations the other types cannot express, written with blocks or a script. |
Conditions can be combined. A camera condition plus a schedule yields "a person, at night only"; a camera condition plus a sensor reading yields "a person, only while the machine is running".
Camera Condition Settings
- Camera and analysis. Select existing ones, or create them from this panel.
- Evaluation criteria. The Condition list depends on the analysis: a face analysis offers known/unknown, a plate analysis offers registered/unregistered.
- Target. Conditions that require a name show the Target value field: an object class, a person, a plate, or text.
- Confidence and duration. Set the certainty threshold and Sustained for. The remaining settings are under Advanced.
Sub conditions: evaluating only at firing time
Conditions are evaluated continuously unless configured otherwise. Changing one to a sub condition makes it evaluate once, at the instant all other conditions are met, to decide whether the actions run.
A typical use is a second camera: when the doorbell is pressed (evaluated continuously), check whether the face at the door is registered (evaluated only at that moment). The second camera does not need to be analyzed all day.
Use Change to sub condition in the row menu. The list shows a Sub badge, and there is no hold time setting, because a sub condition is evaluated once at firing time rather than monitored continuously.
A rule requires at least one ordinary condition. A rule consisting only of sub conditions can never fire, so Reflex blocks that change and explains why.
Ask LLM: re-verifying a detection with an LLM
The Ask LLM switch in the camera condition panel sits outside Advanced Options, directly below Sustained for. When enabled, Reflex captures photos at the moment the condition matches and sends them to an LLM; the actions run only if the LLM approves. Use it as an additional verification step for conditions prone to false positives.
| Field | Description |
|---|---|
| LLM connection | The LLM provider to query. Create one from this panel if none exists. |
| Query | The question sent to the LLM. Required. Example: "Is a person actually knocking on the door?" |
| Shots | Number of photos to send. 1 to 10. |
| Interval | Time between shots. 0 to 5,000 ms. |
Each rule can have at most one, and a camera condition is required to enable it.
Controlling Repeat Firing
Two settings prevent excessive alerts. Both are in the camera condition panel.
| Setting | Behavior | Raise it when |
|---|---|---|
| Sustained for | The detection must last this long before the rule fires. Momentary detections are ignored. | Alerts occur for targets that were not actually present. |
| Reset after | After the actions run, the condition must remain unmet for this long before the rule can fire again. | The same situation is reported repeatedly. |
At a busy entrance, lowering Reset after is often the better choice, so that each person is recorded separately rather than merged into one event. Leaving it empty makes it equal to the hold time.
Additional settings for movement conditions
Movement detected and No movement add two settings.
| Movement margin (px) | The center of a detected box must move farther than this value to count as movement. Raise it to ignore small jitter, lower it to detect slow movement. |
| Still duration | The target must remain still for this long to count as stopped. This also prevents a jittery object from re-firing repeatedly. |
Actions
Clicking + Add action shows sixteen actions.
| Purpose | Actions |
|---|---|
| Send notifications | Push Notification, Email, Telegram |
| Keep records | Logging |
| Play sound | Play Media, Text to Speech (TTS) |
| Control equipment | I/O Device, Zigbee Control, Modbus, OPC UA, User Defined Comm |
| Integrate with software | MQTT Publish, HTTP Request, SQL Database, Shell Command |
| Wait | Delay |
Actions run top to bottom, and rows can be dragged to reorder them. Order matters when an action takes time: a notification that takes one second delays everything after it by that amount. Insert a Delay between actions to space them out, for example to play a warning, wait, and only then cut power.
Keeping Event Records
The Logging action writes the moment to the event log with a photo, and optionally a video clip. The log is only useful with this action, so including one in most rules is recommended.
| Setting | Description |
|---|---|
| Name | Required. The name used for this entry in the log, the CSV, and the printed report. A number is filled in automatically; replace it with an identifiable name. |
| Target | What to record: a camera, an analysis, or a value. |
| Type | Snapshot or Video Clip. A photo is captured even with a clip, for the list thumbnail. |
| Pre-event · Post-event | How many seconds of video to include before and after the moment. |
| Video length | A fixed duration, or While detected, which records for as long as the detection lasts. |
The three targets record different information.
| Target | Records |
|---|---|
| Camera | Photos and video only. Use it to attach another camera as supporting context, including cameras this rule does not watch. |
| Analysis | The photo plus the AI's judgment. This is the only target whose AI results can be corrected from the log later. |
| Value | The reading at the moment the rule fired, with no attachment. |
Managing Rules
| Task | Method |
|---|---|
| Rename | Click the name at the top of the middle area and edit it. |
| Duplicate | Duplicate in the rule's row menu. Conditions, actions, and settings are copied. |
| Delete | Delete in the row menu. The contained conditions and actions are deleted as well. |
| Suspend | The switch beside the rule name. Rules, individual conditions, and individual actions each have one. |
Switching an item off is a safe operation: its settings are preserved and it can be re-enabled at any time.