- Use case
- Prerequisites
- Alarm rules configuration
- Import alarm rules
- Verify alarm triggering
- See also
- Next steps
Use case
Assume your refrigeration equipment is equipped with a temperature sensor that periodically publishes telemetry data to ThingsBoard.
The normal operating temperature range is between 2 °C and 5 °C.
If the reported temperature goes outside this range, it should be treated as an abnormal condition.
Your objective is to:
- Create an alarm when the temperature drops below 2 °C or rises above 5 °C
- Automatically clear the alarm when the temperature returns to the acceptable range
Although this scenario is simplified, it demonstrates a common telemetry monitoring pattern applicable to real-world IoT deployments such as cold storage, food logistics, and industrial refrigeration systems.
To keep the focus on platform capabilities rather than manual setup, the guide uses predefined alarm rule configurations that can be imported directly into ThingsBoard. This allows you to quickly understand how alarm rules work, examine their logic, and reuse or adapt them for your own IoT scenarios.
Prerequisites
Before proceeding, review the Alarm rules documentation, which explains the concepts of alarm creation, trigger conditions, and alarm lifecycle management used in this guide.
You will also need a device to test alarm triggering. You can use an existing device or create a new one by following these steps:
- Navigate to Entities ⇾ Devices.
- Click the + (Add) button in the top-right corner and select Add new device.
- Create the device with the following parameters:
• Device name: Thermometer
• Device profile: thermostat - Click Add to complete the device creation.
The device is now ready to publish telemetry and be used for alarm rule testing.
Recommendation: Apply alarm rules at the device profile level to avoid duplicating configurations across multiple devices of the same type and to ensure consistent alarm
Alarm rules configuration
You need to create two separate alarm rules, each responsible for a specific temperature threshold and alarm type.
High temperature alarm rule
- Alarm type: High temperature
- Create alarm when: temperature > 5 °C
- Clear alarm when: temperature ≤ 5 °C
Low temperature alarm rule
- Alarm type: Low temperature
- Create alarm when: temperature < 2 °C
- Clear alarm when: temperature ≥ 2 °C
Each alarm rule is evaluated every time telemetry is received from the target entity:
- The incoming temperature value is read
- The value is compared against the create and clear conditions
- If a condition matches, the alarm is created, updated, or cleared
Import alarm rules
Import High temperature alarm rule
- Download the High temperature alarm rule configuration file.
- Go to Alarms ⇾ Alarm rules.
- Click the + (Add) in the top-right corner, and select Import alarm rule.
- Specify your device or device profile as target entity.
- Click Add to complete the import.
Import Low temperature alarm rule
- Download the Low temperature alarm rule configuration file.
- In Alarms ⇾ Alarm rules, click the + (Add) and select Import alarm rule.
- Specify your device or device profile as target entity.
- Click Add.
Verify alarm triggering
To verify that the alarm rules work correctly, publish several temperature values.
The easiest way is to use Check connectivity. Alternatively, use the commands below.
Replace $ACCESS_TOKEN with the device access token.
-
Trigger the High temperature alarm.
Publish a temperature value above the upper threshold (for example, 7 °C).1
curl -v -X POST https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header Content-Type:application/json --data "{temperature:7}"
-
Clear High temperature alarm.
Publish a temperature value within the normal range (for example, 4 °C).1
curl -v -X POST https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header Content-Type:application/json --data "{temperature:4}"
-
Trigger Low temperature alarm.
Publish a temperature value below the lower threshold (for example, 1 °C).1
curl -v -X POST https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header Content-Type:application/json --data "{temperature:1}"
-
Clear Low temperature alarm.
Publish a temperature value within the acceptable range again (for example, 4 °C).1
curl -v -X POST https://thingsboard.cloud/api/v1/$ACCESS_TOKEN/telemetry --header Content-Type:application/json --data "{temperature:4}"
After each step, observe the alarm state in the Alarms page or on a dashboard to confirm correct behavior.
See also
Next steps
-
Getting started guides - These guides provide quick overview of main ThingsBoard features. Designed to be completed in 15-30 minutes.
-
Connect your device - Learn how to connect devices based on your connectivity technology or solution.
-
Data visualization - These guides contain instructions on how to configure complex ThingsBoard dashboards.
-
IoT Data analytics - Learn how to use rule engine to perform basic analytics tasks.
-
Advanced features - Learn about advanced ThingsBoard features.
-
Contribution and Development - Learn about contribution and development in ThingsBoard.