|
1 | | -# Using Trigger and Action |
| 1 | +# Trigger & Action |
2 | 2 |
|
3 | | -## How to add trigger and action |
| 3 | +The Trigger & Action feature is used when you would like to get a notification while the value of a data channel meets certain criteria. |
4 | 4 |
|
5 | | -You can set the trigger and action value for a data channel. When the value passes the limit of the defined range, you will get an email or a Mobile Push notification based on the trigger and action settings. In addition, MCS supports webhook trigger, you can input the URL that you would like to recieve this trigger. |
| 5 | +You can set trigger rules on the following data channels |
6 | 6 |
|
7 | | -Please note that MCS only supports trigger and action for integer and float data channel types at the time of writing. Also, only data points uploaded by the device (data points uploaded with deviceKey) will trigger the action. The data points uploaded by user (via web using authentication) will not be triggered. |
| 7 | +1. ON/OFF |
| 8 | +2. Category |
| 9 | +3. String |
| 10 | +4. Hex |
| 11 | +5. Integer |
| 12 | +6. Float |
8 | 13 |
|
| 14 | +and choose one of the following conditions to apply on that data channel |
9 | 15 |
|
10 | | -In the **Prototype** detail page, click the **Trigger & action** tab. |
| 16 | +1. Greater than |
| 17 | +2. Lower than |
| 18 | +3. Equal to |
| 19 | +4. Between |
| 20 | +5. OnChange |
11 | 21 |
|
12 | | - |
| 22 | +The conditions which must be met before the trigger action executes and there are 4 trigger actions provided. |
13 | 23 |
|
14 | | -Click **Add trigger & action** to enter the trigger name and description. |
| 24 | +1. Email |
15 | 25 |
|
16 | | - |
| 26 | + Users with access privilege to this device can receive the Email notification, including device owner, administrator and viewer. |
| 27 | + |
| 28 | +2. Mobile Push |
17 | 29 |
|
18 | | -Then click **Next** to set the trigger criteria by selecting the data channel you would like to set alert for and enter the value. The rules include greater than, lower then, equal to, and between. |
| 30 | + Users with MediaTek Cloud Sandbox App installed on his mobile can receive the push notification. |
| 31 | + |
| 32 | +3. Webhook |
19 | 33 |
|
20 | | -If there are more than one data channel rules in the trigger criteria, all data channel rules need to be satisfied in order to trigger the action('AND' logic). You can create separate trigger and action rules to use the 'OR' logic. |
| 34 | + MCS makes an HTTP request to the callback URL that user provided. |
| 35 | + |
| 36 | +4. Console Alert |
| 37 | + |
| 38 | + When that trigger occurs, there is an alert message on web console directly. |
21 | 39 |
|
22 | | - |
23 | 40 |
|
24 | | -Click **Next** to select the trigger action. You can select to get email or Mobile Push notification when the trigger criteria are met. The email and Mobile Push notification will be sent to anyone with the access to the test device. |
| 41 | +## Defining a trigger & action |
25 | 42 |
|
26 | | -Furthermore, you are allowed to use MCS pre-defined variables in **Title** and **Content** fileds to capture the real value when the action was triggered. You can find more detail under this page. |
| 43 | +You can set **Trigger & Action rules** for a **prototype** and the rules will be applied to each device under this prototype. In addition, you can edit the **value in condition** at **device** level afterward. |
27 | 44 |
|
| 45 | +Here are the steps: |
28 | 46 |
|
29 | | - |
| 47 | +1. In the **Prototype** detail page, click the **Trigger & Action** tab -> **Add trigger & action**. |
30 | 48 |
|
31 | | -The test device will inherit all the trigger and action from its parent prototype. In a test device, you can only change the value of the trigger criteria or select to switch on or off a specific trigger and action. |
| 49 | +  |
| 50 | + |
| 51 | +2. Provide the necessary information in the **Add trigger & action** dialog. |
| 52 | + |
| 53 | + Step 1: The **trigger name** will display in the **console alert** when it is triggered. |
| 54 | +  |
| 55 | + |
| 56 | + Step 2: The match condition is **AND** if there are multiple criteria set. That means you have to upload these data points **in one payload** and all of them match the conditions. |
| 57 | +  |
| 58 | + |
| 59 | + Step 3: At least one action need to be selected. We will explain more about each action later. |
| 60 | +  |
| 61 | + |
| 62 | + |
| 63 | +The device inherits all the trigger & action rules from its prototype. However, you can still change the value of the trigger criteria and enable or disable trigger & action rules for a device. |
32 | 64 |
|
33 | 65 |  |
34 | 66 |
|
35 | | -## Setting trigger and action for different mobile devices |
36 | 67 |
|
37 | | -If you have multiple mobile devices, MCS allows you to set which mobile devices will receive the mobile push notification. You can find the setting in two places: |
| 68 | +Please note, only data points uploaded by the device (with **deviceKey in HTTP header** or via **MQTT**) can trigger the action. The action will NOT be triggered by the UI operation on the web console. |
| 69 | + |
38 | 70 |
|
39 | | -1. In the **User Profile** page, you can switch on or off all the notification from MCS to a specific mobile device. |
40 | | -2. In the **Test device** page, you can switch on or off all notification from a specific test device to a specific mobile device. |
| 71 | +## More about Trigger Actions |
| 72 | +### Configuring the Mobile Push |
41 | 73 |
|
42 | | -In the **User Profile** page, you can see a mobile list that includes all user's mobile devices with MCS app installed. You can use the **Swith** to control which mobile device will receive notifications from MCS. |
| 74 | +If you have multiple mobile devices, you can choose which mobile devices can receive the mobile push notification. You can find the setting in two places: |
| 75 | + |
| 76 | +1. In the **User Profile** page, you can switch on or off **all the mobile push** to a mobile device. |
| 77 | +2. In the **Test Device** page, you can switch on or off all **mobile push for a test device** to a mobile device. |
| 78 | + |
| 79 | +In your **User Profile** page, there is a mobile list that includes all your mobile devices with MCS App installed. You can use the **Switch** to control which mobile device can receive mobile push from MCS. |
43 | 80 |
|
44 | 81 |  |
45 | 82 |
|
46 | | -In the **Trigger & action** tab in the test device page, expand the **Manage your action** section and you will see a list of all user's mobile devices with MCS app installed. You can use the **switch** here to control which specific mobile device will receive the notification from this test device. |
| 83 | +In the **Trigger & Action** tab in the test device page, expand the **Manage your action** section and there is a mobile list that includes all your mobile devices with MCS App installed. You can use the **Switch** here to control which mobile devices can receive the mobile push for this test device. |
47 | 84 |
|
48 | 85 |  |
49 | 86 |
|
50 | 87 |
|
| 88 | +### Configuring the Webhook |
51 | 89 |
|
52 | | -# Set up a webhook trigger |
53 | | - |
54 | | -To set up a webhook trigger, you have to select the **webhook** as the action in the Trigger & action tab in the prototype. And input the url that you would like to get the webhook trigger. |
| 90 | +There is no extra setting for webhook. To use webhook trigger, you only have to select the **webhook** as the action in the trigger & action setting and provide the callback URL that MCS makes an HTTP request to. |
55 | 91 |
|
56 | 92 |  |
57 | 93 |
|
58 | | -There is a Test button for you to test if the trigger has been sent to the url. The device name, deviceId and the triggered value will be sent to the triggered url. |
| 94 | +There is a Test button for you to test if the trigger has been sent to the URL. The device name, deviceId and the triggered value will be sent to the triggered URL. |
| 95 | + |
| 96 | + |
| 97 | +### Configuring the Console Alert |
| 98 | + |
| 99 | +You have to specify the severity level while configuring console alert in Trigger & Action. |
| 100 | + |
| 101 | + |
| 102 | + |
| 103 | +When that trigger occurs, the console alert with severity information will show on the web console immediately. It is displayed on the following page. |
| 104 | + |
| 105 | +1. Data Channel Card |
| 106 | + |
| 107 | + You can expand the alert message bar to see more information, including **trigger name** and **alert time**. In this case, a data was uploaded on "2018-07-19 11:36" and triggered a rule named "Water is too hot". |
| 108 | + |
| 109 | + After you click **Dismiss**, this alert will be cleared. You won't see this alert until the new data is uploaded and the trigger rule is matched. |
| 110 | + |
| 111 | +  |
| 112 | + |
| 113 | +2. Test Device List |
| 114 | + |
| 115 | + It always displays the alert with **highest severity** right this moment. |
| 116 | + |
| 117 | + Take the previous case for example. You will see "High" alert on the card, if "High" alert is dismissed, and then it shows "Medium" alert instead. |
| 118 | + |
| 119 | +  |
| 120 | + |
| 121 | +3. Scene |
| 122 | + |
| 123 | + The presentation logic is the same as Device List. |
| 124 | + |
| 125 | +  |
| 126 | + |
59 | 127 |
|
60 | 128 |
|
61 | | -MCS supports customized webhook body message. You can also use the pre-defined variables. For the customized variables, please refer to the following paragraph. |
62 | 129 |
|
63 | | -# Use variables in notification message |
| 130 | +## Use variables in notification message |
64 | 131 |
|
65 | 132 | MCS provides pre-defined variables which can be used in both Title and Content fileds. These variables will be replaced with real values when the action is triggered. The pre-defined variables include: |
66 | 133 |
|
|
0 commit comments