Setting a State-based Triggered Alert


Situations may arise where EnOS needs to send an alert when the device is in a certain state.


For example, when the EnOS alert service is used to monitor the A/C devices of a smart building, an alert rule can be set to trigger the “A/C Offline” alert when an A/C device becomes offline. This alert would be cleared when the A/C device is online again.


EnOS currently can only trigger device alerts based on the offline state.

Alert Masking and Delay for State-based Triggered Alerts


  • Alert Masking:

    • When a particular state of a device triggers an alert, the alerts of the devices of its child nodes in the asset tree will be blocked.

    • The state-based alert of a device will be masked if alert masking is set for the device of its upper node in the asset tree.

  • Alert Delay:

    • You can set alert delays for state-based alerts, for example, where a “Device Offline” alert is triggered only when a device is offline for at least 5 minutes.

About This Task


This task uses a smart building scenario to describe how to set a state-based triggered alert. An ammeter that measures the real-time current of the refrigerator, as simulated in the Tutorial: How to Set the Alerts of Different Threshold for the Devices of the Same Model, is used to set the state-based triggered alerts.

Prerequisites


Procedure


  1. Select Alert Rule and create an alert rule based on the below. See Creating Alert Rules for how to create the alert rule.


    ../_images/state_based_alert_adv_rule.png


    At this time, the alert is set to trigger immediately when the ammeter gets offline.

  2. Copy the sample code fridgeMQTT from the Tutorial: Setting Different Alert Thresholds for Devices of the Same Model to your IDE.

  3. Run fridgeMQTT. You will be able to see from Asset Management > Device Asset that the refrigerator meter is now online.

  4. At this point, you can stop running the fridgeMQTT code block.

Results


Go to Alert Engine > Alert Records and you can see the triggered state-based alerts with the State as Real-time.


../_images/state_based_alert_result_realtime.png


If you run the fridgeMQTT code block again at this time, the State of the alert record will change to Historical.


../_images/state_based_alert_result_history.png

Impact on API


An optional parameter deviceStatus with an offline value has been added to the request parameters (Body) of the following APIs:

  • Create Alert Rule

  • Update Alert Rule

  • Search Active Alerts

  • Search History Alerts

  • Search Alert Rule


The addition serves the following purposes:

  • Create or update alert rules so that the alert can be triggered based on the device state.

  • Return the active or history alert records that were triggered based on the device state.