合规国际互联网加速 OSASE为企业客户提供高速稳定SD-WAN国际加速解决方案。 广告
***The Trigger of Devicebit*** is the simple form of IFTTT(IF THIS THEN THAT). Different alerts (E-mail or twitter) can be triggered according to one value or value combination (edge trigger is supported). This tutorial mainly introduces the procedures to trigger E-mail or Twitter alert and send report periodically. # Hardware No hardware is required. Only simulate data-upload by API testing tool provided by DeviceBit platform to test trigger functions and send report periodically. # **Procedures** # 1 Register DeviceBit Account (www.devicebit.com) ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-1.jpg) Pic.1 Sign Up # 2 Add Sensors Add ***My Device, Sensors: Humidity and Temperature*** according to previous tutorials (Please refer Chapter 1&2 for details. Note: note down the sensor ID, for it will be used in Api calling.) ## 2.1 Add A Device After login, go to ***My Devices -> Devices->Add a Device*** First, click on ***Devices*** ***->*** ***Add A Device***, as the picture1 below. After entering the related information, click on ***Save***. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-2.jpg) Pic.2 Add A Device ## 2.2 Add Sensors The next step is to add the humitity & temperature sensor. Go to ***My Devices-> Sensors&Controllers->Sensor***, click on ***Add***. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-3.jpg) Pic.3 Sensors Then there will be the ***Add A Sensor*** page. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-7.jpg) Pic.4 Add Humidity As the above picture shows, enter Humidity for ID (Note down the ***ID*** for it will be used in Api calling). Select ***Humidity Monitoring*** for ***Type***. Seclet ***%*** for ***Unit***. Select ***My Device*** which is created previously. Enter ***Humidity*** for ***Name***. If you want others could view the humidity data, tick ***Yes*** for ***Public*** item. Add the ***Temperature*** sensor in the same way. Please see the following picture. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-8.jpg) Pic.5 Add Temperature After setting up, as picture 5 shows, note down the ***ID*** because it will be used in Api calling. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-9.jpg) Pic.6 Sensor ID # 3 Variable Settings Go to ***IOT applications ->Variables Settings ->Add A Variable*** (Please refer to Chapter9 for details.) to set the variables such as ***hour, date, humidity, temperature*** etc, and add expressions, as the following picture shows. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-37.jpg) Pic.9 Variable Settings First, set different Twitter content, ***Good morning, Good afternoon*** or ***Good evening*** according to the system variable ***Hour***. Click on ***Add Expressions***, and fill in the information as follows: ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-38.jpg) Pic.10 Hour Settings Note the ***Type ***select*** System Variables ***. The system variables including the*** hour , date*** and ***time***. Select ***Hour*** here.***Decimal Places*** leave blank, for decimal is not involved here. Tick ***Yes*** at ***Whether to output text?***Then, click on ***Test***, we can see that the current time is 22 o’clock, and the text is ***Good Night***! (For the time is at the range 8-12) ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-39.jpg) Pic.11 Test For Hour Next, set up ***Date*** in the same way. Settings for date are very simple. Ignore ***Enable text output*** for there is no need to set it. The settings and test results are as follows: ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-40.jpg) Pic.12 Settings &Test For Date Finally, set the Twitter text according to different measured humidity values. Here, select ***Sigle Sensor*** for ***Type,*** select ***My Device*** and ***Humidity*** for ***Reference Value***. Since all the values are integers, the decimal places do not need to be set. If the measured values are decimals, you can set the decimal places here. The format is .0, .00 and so on. The logical relationship between the output text and the value range is as follows, and you can define it by yourself. Then, click on ***Test*** to check the result. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-41.jpg) Pic.13 Settings & Test For Humidity # 4 Text Settings Go to ***IOT applications ->Text Edit ->Add Sending Content*** (Please refer Chapter9 for details. ) to edit the sending text. Please see the following picture. Edit text: Click on ***Text Edit -> New text*** ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-43.jpg) Pic.14 Text Edit The settings and test result are as follows. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-44.jpg) Pic.15 Settings & Test For Text The returned content for [[ ]] is the returned value of the system variable in [[ ]], the measured value of the sensor in [[ ]], or the more complex logic operation result of the measured values of the sensor in [[ ]]. For example, the returned content for [[date]] is the current date. While, the content for the two braces {{}} is the Twitter Text corresponding with the value range of the variable in {{}}. For example, in the following picture, the current humidity is 57%. According to the previous logic relationship set for the value range from 41 to 70, the returned text content for {{Humidity}} is ***It is comfortable!*** After setting, you can click on ***Test*** to see whether the settings are correct. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-46.jpg) Pic.16 Text List # 6 Trigger Settings Next, let's set the trigger. Go to ***IOT applications->Triggers->Add A Trigger*** ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-55.jpg) Pic.19 Trigger Settings Enter ***Temperature Test*** for ***Description***, select ***Temperature*** for ***Sensor***, enter ***30*** in the blank part after ***Greater than*** for ***Edit Condition***; untick ***Endge Trigger***. Next, ***Enable Text Sending***: tick ***Yes*** then, the following page will appear, ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-56.jpg) Pic.20 Text Settings Let's move on to ***Sending Content*** ***Sending content***: select ***Temperature*** ***Enable Control Unit***: select Open ***Minimal Trigger Interval*** : 10 (default value) ***Enable***: tick ***Yes***. Then, the trigger is on. Please refer to the following picture. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-57.jpg) Pic.21 Temperature Test Set up the humidity trigger in the same way. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-58.jpg) Pic.22 Humidity Test ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-59.jpg) Pic.23 Trigger List Thus, the triggers of temperature and humidity are set up, as the above picture shows . # 7 API Test The simplest way to test the triggers is to simulate data-upload by using API testing tool.** At the home page (the website is www.devicebit.com) click on ***Documentation*** ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-1.jpg) Pic.24 Home Page and then go to ***API Directory-> Sensor ->Upload Sensor Data*** ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-10.jpg) Pic.25 API Directory Website http://www.DeviceBit.com/dev/apiList?version=1&sk=69 http://www.DeviceBit.com/dev/apitest/3 ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-11.jpg) Pic.26 Online test Click on ***on-line test*** ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-12.jpg) Pic.27 API Testing Tool Enter your ***Userkey*** Enter ***Device ID*** at API URL http://www.DeviceBit.com/api/V1/gateway/UpdateSensors/{device ID} [(01 for exampe)](http://www.lewei50.com/api/V1/gateway/UpdateSensors/%E4%BD%A0%E7%9A%84%E7%BD%91%E5%85%B3%E5%8F%B7) [After entering the device ID, the APIURL is:](http://www.lewei50.com/api/V1/gateway/UpdateSensors/%E4%BD%A0%E7%9A%84%E7%BD%91%E5%85%B3%E5%8F%B7) http://www.DeviceBit.com/api/V1/gateway/UpdateSensors/01 ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-13.jpg) Pic.28 Userkey&Device ID Change ***T1*** to ***Temperature*** for ***Name***; change ***1*** to ***32*** for ***Value***; Change ***01H1*** to ***Humidity*** for ***Name***; change ***96.2*** to ***75*** for ***Value***. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-14.jpg) Click on ***Run***, and then the result will be displayed . ![](http://upload-images.jianshu.io/upload_images/5875248-9a90e212c9323d95.jpg?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240) ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-15.jpg) Pic.30 Request Detail At last, Go to ***My IOT -> Sensors&Controllers->Sensor List***, you will see the following value. ![](https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-16.jpg) Pic.31 The Value You have already received Email! [55]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-55.jpg [56]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-56.jpg [57]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-57.jpg [58]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-58.jpg [59]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-59.jpg [60]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-60.jpg [53]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-53.jpg [54]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-54.jpg [3]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-3.jpg [1]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-1.jpg [2]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-2.jpg [5]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-5.jpg [6]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-6.jpg [7]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-7.jpg [8]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-8.jpg [9]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-9.jpg [10]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-10.jpg [11]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-11.jpg [12]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-12.jpg [13]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-13.jpg [14]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-14.jpg [15]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-15.jpg [16]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-16.jpg [37]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-37.jpg [38]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-38.jpg [39]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-39.jpg [40]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-40.jpg [41]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-41.jpg [42]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-42.jpg [43]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-43.jpg [44]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-44.jpg [45]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-45.jpg [46]: https://leweidoc.oss-cn-hangzhou.aliyuncs.com/lewei50/img/devicebitmanual-xj-20180930-46.jpg