Rule
As introduced in general concepts, a rule is a tool that you can use to monitor your assets and be notified of abnormal situations or events. Senfi can send you email, SMS or notify your operators in the dashboard when, for example, a Fire is detected in a building, when a Lift has broken down, or when a Machine is overdue for maintenance. Rule is the tool you can use to configure these notifications.
A rule in Senfi comprises of:
- Inputs
- Conditions
- Output
- Actions
- Rule execution options
Inputs are evaluated by Conditions to generate a single boolean Output. When value of Output changes, Actions, such as email and dashboard alerts, are executed. Rule execution options allows you to configure how the Rule should execute. e.g: how often the Rule is evaluated, when to execute Actions etc.
Inputs --> Conditions --> Output
Output Changed --> Actions
Contents
Example
- Input: iot_weighingscale_v1.battery_level
- Condition: < 20
- Action: Email reminder to replace battery
- Rule execution option: Immediately (means evaluate this rule whenever there is any incoming measurement)
Inputs, Conditions and Output
Before adding a Rule, you should already have an event or situation that you wish to be notified about. The event or situation should be one that can be detected by monitoring data received by Senfi.
Select, as Inputs, the Metrics and Measurements from which the event or situation can be detected from. Then, construct the set of Conditions that will evaluate to true when event or situation occurs. The result of said Conditions is the Output of the Rule.
Actions
Whenever Output changes (from true to false and vice versa), Actions may be executed. Actions includes sending an email, sms, request to a webhook or triggering an alert in the dashboard.
Content of Actions
Depending on the Action, different content options are available. Some examples is the title & body of an email, message text for SMS, and body content for webhook request. You will be able to describe the event or situation that has happened to the recipient of the notification in the content of an Action
To further aid you in describing the event, you can embed the value of an Input in the content of an Action. To learn how to embed, take a look at this example
Rule execution options
By setting Evaluate Type to Immediate or Polling, you can choose to execute a Rule when new values are received for any Input Measurements, or periodically, regardless of whether any Input Measurements have changed.
If Rule is set to run periodically (Polling), you must specify how often a Rule is executed by setting Intervals in seconds.
Detailed Example
The event that you would like to be notified about is potential fire in a building. There are temperature sensors throughout the building. When a reading from any temperature sensor exceeds 60°C, a fire has probably broken out near the sensor. You would like to be notified by email of such an occurrence.
- The Input in this example would be the metric and measurement that readings from temperature sensor is sent to. e.g: iot_temperature_sensor_v1.temperature
- Condition is iot_temperature_sensor_v1.temperature > 60
- Action is email, with body text: "Potential fire detected in room: ${iot_temperature_sensor_v1.room}. Temperature in the room is ${iot_temperature_sensor_v1.temperature}°C"
With the above Rule configured, when iot_temperature_sensor.temperature goes from 59 to 61, an email will be sent with the body text: "Potential fire detected in room: #03-00. Temperature in the room is 61°C"
Note: "room" is a Tag of the iot_temperature_sensor_v1 measurement which indicates which room the sensor is in.