10 Trigger

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)

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.

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.

Pic.3 Sensors

Then there will be the Add A Sensor page.

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.

Pic.5 Add Temperature

After setting up, as picture 5 shows, note down the ID because it will be used in Api calling.

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.

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:

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)

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:

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.

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

Pic.14 Text Edit

The settings and test result are as follows.

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 is It is comfortable! After setting, you can click on Test to see whether the settings are correct.

Pic.16 Text List

6 Trigger Settings

Next, let's set the trigger. Go to IOT applications->Triggers->Add A Trigger

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,

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.

Pic.21 Temperature Test

Set up the humidity trigger in the same way.

Pic.22 Humidity Test

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

Pic.24 Home Page

and then go to API Directory-> Sensor ->Upload Sensor Data

Pic.25 API Directory

Website http://www.DeviceBit.com/dev/apiList?version=1&sk=69

http://www.DeviceBit.com/dev/apitest/3

Pic.26 Online test

Click on on-line test

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)

After entering the device ID, the APIURL is: http://www.DeviceBit.com/api/V1/gateway/UpdateSensors/01

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.

Click on Run, and then the result will be displayed .

Pic.30 Request Detail

At last, Go to My IOT -> Sensors&Controllers->Sensor List, you will see the following value.

Pic.31 The Value

You have already received Email!

Last updated