Adding a trigger

To create a new trigger, do the following:

  1. From the Developer main screen in the GENERAL group, click Triggers.

    The Triggers screen appears.
  2. Click on New Trigger button

    Adding Trigger screen appears.
  3. Enter the Name and Description(Optional)

  4. Right-click on the Start node to select a Trigger Event Type

    Add trigger event dialog appears.
  5. Click the Event type drop-down.
  6. Select the Event type, your trigger will be listening to.
    Event form appears.
  7. Enter the details in the Cloud trigger event form. For more information on entering the details in the Cloud trigger events, see Cloud Trigger Events.
  8. Click Add.
  9. Select an action you want to perform when the trigger event happens.  To select a trigger action:
    1. Click on the Trigger actions category name to expand and view the available Trigger actions.
    2. Click and hold while you drag the selected action to the canvas.
    3. Click on or to expand or collapse all trigger action categories.

      Add trigger action form appears.

      The Node info on the right side of the interface displays the configuration of the currently selected Trigger event or Trigger action.

  10. Enter the details in the Cloud trigger actions form. You can add one or more actions to a trigger. Each action is able to access the prior actions output in addition to variables made available by the trigger event. In the case of some actions (email.send, thing.log, and so on.) there are no output variables. For more information on entering the details in the Cloud trigger action form, see Cloud Trigger Actions.
  11. Click Add.
  12. Click and hold while you drag the arrows from the colored edge to connect the nodes.

    Pan Mode - Allows the canvas to be scrolled both horizontally and vertically. While in Pan mode, holding the CTRL (control) key and clicking node(s) will allow you to select/de-select multiple nodes.
    Select Mode  - Allows selecting one or more nodes for repositioning on the canvas. The Select mode works in two ways: when you drag from left to right, any node that intersects your lasso will be selected. When you drag from right to left, only nodes that are enclosed by your lasso will be selected.
    Fit trigger to screen - Fit the trigger to the screen
  13. Connect a Success node at the end of the route.

    You should have at least one success route to save it.

  14. Click on the Reporting mode drop-down to select the mode for the reports to get generated

    Report Modes

    Off - No trigger events will be reported

    On - All trigger events will be reported. When On is selected the trigger events are reported for the next 30 days and later it automatically switches to the default On failure mode.

    On failure(default) - Only events that failed will be reported.

    For more information on viewing trigger reports, see Viewing Trigger Report.

    When attempting to connect a route, drag it over the destination node until it turns grey. When the destination node turns grey it is aware of the route being connected to it. While the destination node is grey, release the mouse button to bind the route to it.

  15. Click Add.

    Trigger Scheduling

    By default, your triggers are active all days and hours. Use Active Window to specify certain hours or days of the week when you want your triggers to be active. For more information on scheduling a trigger, see Scheduling a Trigger.

A Trigger Sample

Building a trigger for a Generator with a thing key generator. This generator has a fuel tank with a property key of "fuel" that contains the amount of fuel in the tank (measured in gallons). The generator also has an attribute with a key of "capacity" that specifies the size of the fuel tank. Additionally, there is an alarm with a key of "status" that describes the fuel level, with 0 (zero) representing an acceptable amount of fuel, and 1 (one) meaning the fuel is low.

The trigger is build to execute when the "fuel" property changes the thing "generator". The "capacity" attribute is read to determine if the percentage remaining in the tank is less than or greater than 10%. If it is greater than 10%, the "status" alarm is set to 0 (zero) and end the trigger successfully. If the tank is 10% or less, the status is set to 1 and end the trigger successfully.

To build the Generator sample trigger, do the following:

  1. In the Trigger screen, click New Trigger button.
  2. Enter the Name of the trigger. For example, Generator fuel level

  3. Right-click on the Start node to display the trigger event window.  
  4. Set the Event type to property.change.  
  5. Set Thing key to be generator and Property key to be fuel.

  6. Click the Add button  
  7. Expand the Thing actions
  8. Click and hold while you drag thing.attr.find onto the canvas

  9. Set the Thing key to be "$(event.thing.key)" (alternatively, use "generator" as the preceding Event variable contains this string), and Attribute key to be "capacity".  
  10. Click the Add button.  
  11. Create the Route from the property.change event triangle to the 0.thing.attr.find action.

  12. Expand the Math actions
  13. Click and hold while you drag math.expr onto the canvas.

  14. Set the Expression to be "$(event.prop.value) / $(action.0.value) * 100".
    This will divide the current fuel value by the capacity of the tank and multiply that result by 100 thus giving us a percentage.
  15. Create the success Route from 0.thing.attr.find to 1.math.expr.  
  16. Click and hold while you drag math.expr onto the canvas.  
  17. Set the Expression to be "$(action.1.value) <= 10".
    This will compare the percentage of fuel remaining to 10%.  
  18. Create the success Route from 1.math.expr to 2.math.if.
       
  19. Open the Alarm heading and drag alarm.publish onto the canvas.  
  20. Set Thing key to be $(event.prop.value)  (alternatively, use generator as the preceding Event variable contains this string), Alarm key to be "status", and State to be "1".
     
  21. Click the Add button.  
  22. Create the true Route from 2.math.if to 3.alarm.publish.

    This is the Route the logic will follow when the fuel value is 10% or less.  
  23. Click and hold while you drag another alarm.publish onto the canvas.  
  24. Set Thing key to be "$(event.prop.value)"  (alternatively, use  "generator" as the preceding Event variable contains this string), Alarm key to be "status", and State to be "0".  
  25. Click the Add button.  
  26. Create the false  Route from 2.math.if to 4.alarm.publish.

    This is the Route the logic will follow when the fuel value is greater than 10%.  
  27. Expand the End action
  28. Click and hold while you drag Success onto the canvas.  
  29. Create the success Route from 3.alarm.publish and 4.alarm.publish to 0.Success.
       
  30. Click the Add button at the bottom of the screen.  
  31. Click the Start button to activate the trigger.
       

You would now have a working trigger for the generator.

Related Topics Link IconRelated Topics