Advanced Rule Engine E-Mail and Webhook Templates
This guide shows you how you can use the rule engines template language to create custom alerting messages that include sensor information.
Introduction
The Rule Engine in our Datacake IoT platform is a powerful feature that enables you to automate actions and send notifications based on data from your IoT devices. As of July 4, 2023, our Rule Engine supports the inclusion of measurement timestamps in notifications. This document guides you through the utilization of the Django Template Language within the Rule Engine for crafting highly informative and customized notification content.
Why Use Template Language?
When sending notifications, whether it's an email, SMS, or webhook, it’s often necessary to include data from sensors, and timestamps, and sometimes perform some conditional logic. This might include formatting dates, displaying values, or sending different messages based on sensor readings. The Django Template Language allows for dynamic inclusion and manipulation of content, based on the data and logic you specify.
What Can You Do with Template Language in Notifications?
Dynamic Content: Include real-time sensor data and timestamps in your notifications.
Formatting: Customize the formatting of timestamps to make them more readable or to conform to specific standards.
Conditional Logic: Use if-else statements to send different messages depending on the data.
Loops: Loop through lists of data, such as multiple sensor readings.
Combining Information: Craft comprehensive messages by combining multiple pieces of information.
Adding Hyperlinks: Include links to dashboards or additional resources.
Getting Started
This document contains examples and syntax that will help you get started with using the Django Template Language in Rule Engine notifications. From simply displaying sensor data to more advanced conditional logic, these examples will guide you through creating informative and dynamic notifications.
Please proceed through the examples to understand the various features and possibilities. Keep in mind that while this documentation provides a strong foundation, the Django Template Language is very versatile and you may find even more creative ways to utilize it in your notifications.
Including Sensor Data
Include the value of a sensor measurement in your notification.
Including Measurement Timestamp in UTC
Include the timestamp of the measurement in UTC ISO format.
Including Measurement Timestamp in Local Timezone
Include the timestamp of the measurement in the rule's timezone using the datetime
filter.
Timestamp is provided in the time zone you selected on your rule! Make sure to select the correct one.
Custom Date Formatting
Customize the date format using strftime syntax.
Combining Information
Combine multiple pieces of information into a single message.
Including Hyperlinks
Include a hyperlink, possibly to a dashboard or additional resources.
Note: You can combine these examples and syntax to create complex and informative notifications according to your requirements.
Last updated