Timer Trigger (TIMER_TRIGGER)
Timer Trigger (TIMER_TRIGGER)
Overview
Timer trigger (triggerType = 1) is used to automatically execute rules at fixed time intervals or at a specific time of day. Suitable for periodic collection, scheduled control, and other scenarios.
| Trigger | Input Source | Check Timing | Suitable Scenarios | Common Risks |
|---|---|---|---|---|
| Platform Trigger | MQTT / HTTP / Cloud commands | Match fields immediately upon message arrival | Remote on/off, parameter delivery, linkage control | Inconsistent field names, duplicate messageId, insufficient permissions |
| Timer Trigger | Local clock / cron / interval | Execute when time point is reached | Periodic reporting, scheduled on/off, night mode | NTP not synced, first trigger semantics unclear |
| Event Trigger | Button, sensor, system events | Match eventId when event is published | Button control, threshold alarm, state change | Debouncing, event name spelling, cached value expiry |
| Poll Trigger | Actively read peripheral or protocol data | Check conditions every pollInterval | Modbus collection, analog threshold, distance alarm | Too frequent, serial port busy, low memory frequency reduction |
Timer trigger is suitable for "execute when it's time" rules, and is not appropriate for directly expressing "a collected value exceeds a threshold". If the action needs to collect first and then compare, consider using event trigger or poll trigger instead.
Trigger Modes
| Mode | timerMode | Description |
|---|---|---|
| Interval Mode | 0 | Trigger every N seconds |
| Daily Time Point | 1 | Trigger daily at specified HH:MM |
Field Description
| Field | Type | Description |
|---|---|---|
| triggerType | 1 | Timer trigger |
| timerMode | uint8 | 0=Interval mode, 1=Daily time point |
| intervalSec | uint32 | Interval in seconds (effective when timerMode=0) |
| timePoint | String | "HH:MM" format time point (effective when timerMode=1) |
Configuration Examples
Method 1: Web Interface Configuration (Recommended)
The peripheral execution page is shown below. When configuring timer trigger, verify whether the rule is enabled, the trigger interval or daily time point, and whether the actions are suitable for periodic execution.
Example 1: Interval Trigger (Every 60 Seconds)
Scenario: Execute a rule every 60 seconds
Configuration Steps:
Click left menu Peripheral Configuration → Switch to Peripheral Execution Management tab
Click the Add Rule button
Fill in basic configuration:
- Rule Name:
Timed Data Collection - Report Data: ✅ Enabled (when results need to be reported)
- Enable: ✅ Enabled
- Rule Name:
Configure trigger:
- Trigger Type: Select Timer Trigger
- Timer Mode: Select Fixed Interval
- Interval Time: Enter
60(60 seconds)
Configure actions: Add actions to execute
Click the Save button
Example 2: Daily Time Point Trigger (Every Day at 08:00)
Scenario: Automatically execute every day at 8 AM
Configuration Steps:
- Create rule, name:
Turn On Light on Schedule - Trigger configuration:
- Trigger Type: Select Timer Trigger
- Timer Mode: Select Daily Time Point
- Time Point: Enter
08:00(format: HH:MM)
- Configure actions: Add light-on related actions
- Click Save
💡 Tip: Daily time point mode requires successful NTP time sync, otherwise it will not trigger
Method 2: JSON Configuration File Import
Complete Rule Example
Collect Temperature and Humidity Every 5 Minutes
{
"id": "exec_dht_poll",
"name": "Timed Temp/Humidity Collection",
"enabled": false,
"execMode": 0,
"triggers": [
{
"triggerType": 1,
"triggerPeriphId": "",
"operatorType": 0,
"compareValue": "",
"timerMode": 0,
"intervalSec": 300,
"timePoint": "",
"eventId": "",
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}
],
"actions": [
{
"targetPeriphId": "dht1",
"actionType": 19,
"actionValue": "",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}
],
"protocolType": 0,
"scriptContent": "",
"reportAfterExec": true
}Turn Off Lights Every Day at 22:00
{
"id": "exec_night_off",
"name": "Nightly Auto Light Off",
"enabled": false,
"execMode": 0,
"triggers": [
{
"triggerType": 1,
"triggerPeriphId": "",
"operatorType": 0,
"compareValue": "",
"timerMode": 1,
"intervalSec": 60,
"timePoint": "22:00",
"eventId": "",
"pollResponseTimeout": 1000,
"pollMaxRetries": 2,
"pollInterPollDelay": 100
}
],
"actions": [
{
"targetPeriphId": "relay1",
"actionType": 1,
"actionValue": "",
"useReceivedValue": false,
"syncDelayMs": 0,
"execMode": 0
}
],
"protocolType": 0,
"scriptContent": "",
"reportAfterExec": false
}Precautions
- Minimum Interval: intervalSec can be set to 1 second minimum, but ≥ 5 seconds is recommended to avoid frequent execution
- NTP Dependency: Daily time point mode requires successful NTP sync (
tm_year >= 100), otherwise it is skipped - Time Window: Daily trigger fires only once within the specified minute (60-second deduplication window)
- First Trigger: Interval mode triggers immediately on start (lastTriggerTime is initially 0)
- Running Protection: If the previous execution has not completed, the current timer trigger is skipped
