Trigger Example: Alarm Change Based on Predefined Threshold

An alarm needs to be published when a value is outside of a high value set point and a low value set point.

To solve this requirement, temperature set points are stored as attributes for what is deemed a high value and what is deemed a low value. The attributes used for these set points can be dynamically modified.

The thing's thing definition has a property for the temperature value. Attributes are used for the high and low attributes. An alarm with three states is also defined:

  • Property for temperature: temperature

  • Attribute set point for high temperature: highthreshold

  • Attribute set point for low temperature: lowthreshold

  • Alarm for temperature: tempalarm

  • Alarm States:
    • 0 = Normal

    • 1 = Low

    • 2 = High

$(event.thing.key) - The key of the thing that initiated the cloud trigger.

$(event.prop.value) - The data value of the Publish Property action (or property.publish API) that initiated the cloud trigger.

$(action.X.value) - The result value for action block X.

The system first finds the attribute for the high set point (highthreshold) for the thing that caused the event. This is in the event variable $(event.thing.key) from the suggestions list. The value is stored temporarily as $(action.0.value).

The cloud trigger then does a math.if action to compare the property value from the event, $(event.prop.value), to see if it is greater than the high threshold attribute value $(action.0.value).

The cloud trigger then does a math.if action to compare the property value from the event, $(event.prop.value), to see if it is less than the action value, $(action.3.value).