State Triggers

Overview

This guide describes the process for creating State triggers. These triggers test the published data against the State defined in the configuration. There are three action options:

  1. Entering the state.
  2. Exiting the state.
  3. Remaining in the state.

The State is entered as a regular string, not as a JSON. If you want to enter ON, simply type ON.

Supported actions are:

Create a State Trigger

To create a State Trigger for your Production Template, Thing or Controller:

  1. Open the target device from its management console.
  2. Select General (General) -> Triggers (Triggers).
  3. Click on the New Trigger button (New).
  4. Give the trigger a Name and set Event as Data Published.
  5. Enter an existing or new channel name under Channel, and enter or select a Data field if the State is published in a structured JSON data field.
  6. Set the Rule Type as State.
  7. Enter the State(s) that the Trigger will test against and select and customize the actions for the changes of state. You can set multiple actions for the same trigger and use the Special Symbols available to program the actions.
  8. Save the trigger.
  9. Save the device.
State trigger

Full Example

Here is a full example on how to create and test a State Trigger for a device called AGT_002 on a channel called device_state.

Follow the steps above to create a State trigger called State alert on channel device_state. We will publish single values; therefore, no Data field exists for this test.

1. Set the State name to ON.
2. Create and save an email notification action called Turning ON email when the device is Entering state. Entering ON action
3. Create and save an email notification action called Exiting ON email when the device is Exiting state. Exiting ON action
4. Create and save an email notification action called State Unchanged email when the device is in Same state. Unchanged state action
5. The resulting rule looks as follows: Rule ON
6. Add a new rule and set the State name to OFF. Add the Entering, Exiting and Unchanged state emails and Save. Rule OFF
7. Save the trigger, then Save the device. Save trigger Save thing
8. Publish the JSON “ON” on device_state. Publish ON
9. Verify that the email Device turned ON was received. Email ON 1
10. Publish the JSON “OFF” on device_state. Publish OFF
11. Verify that the emails i) Device exited ON state and ii) Device turned OFF are received. Email Exit ON 1Email Turn OFF 1
12. Publish JSON “OFF” on device_state again. Publish OFF 2
13. Verify that the Device remained OFF email is received. Same OFF 2
14. Publish JSON “ON” on device_state. Publish ON 2
15. Verify that the emails i) Device turned ON and ii) Device no longer OFF are received. Enter ON 2Email Turn OFF 1
16. The Data view panel displays the following published data: Data Published
Still need help? Get in touch!
Last updated on 6th May 2021