Among all the interfaces open on the platform, issuing commands to devices is the most essential and frequently used command.
When first accessing the device, it is also recommended to implement the "Issuing commands to devices" first, and then implement other functions through other interfaces.
Before sending commands to the device, please make sure that the device is connected to the network and is displayed online in the console.
When first accessing the device, it is also recommended to implement the "Issuing commands to devices" first, and then implement other functions through other interfaces.
Before sending commands to the device, please make sure that the device is connected to the network and is displayed online in the console.
Preparation
Before starting to write code, please do the following preparations:
1 Registered and logged in to the platform and installed the "IoT console" module
2 The device is powered on, online, and can be controlled in the console
3 Download / install a similar interface request tool (if not)
Start access
4.1 Send command interface
Interface address:
https://api.thingboot.com/{AppID}/device/control/?sign={sign}&ts={ts}
{AppID} is your application ID (generated by the platform)Please enter the console, in the development settings page to view.
{sign} and {ts} algorithm, please see the description in the previous section
{AppID} is your application ID (generated by the platform)Please enter the console, in the development settings page to view.
{sign} and {ts} algorithm, please see the description in the previous section
Request data:
This command issues the command of to with ID 820720
For more configuration parameters, please refer to section4.2 "Product Supported Commands"below
{
"device":820720,
"order":{"power1":"1"}
}
Request method: POST; Data format: JSONThis command issues the command of to with ID 820720
For more configuration parameters, please refer to section4.2 "Product Supported Commands"below
Request parameters
When the parameters are relatively long, it is recommended to use the POST method.
| Name | Required | Type | Description |
|---|---|---|---|
| gateway | No | string | When sending a order to a device that must be forwarded by its associated gateway, you must specify the gateway’s device ID—the unique ID found on the gateway housing and in the management console.
To include multiple gateways, separate their IDs with a comma (,) or vertical bar (|); up to five gateways can be specified at once. |
| device | No | string | Device ID, Unique Device ID (Found on the device housing and console)
When specifying multiple devices, connect them with a separator (, or |).When specifying multiple devices, these devices do not need to belong to the same product category, but they must support the same command. |
| order | No | string | Command: JSON String (Recommended) or Direct Parameter Transmission
Simple Commands: Can be sent via GET or POST directly in the format: Device Attribute Name=Attribute Value
Complex or Long Commands: Please send via POST in the format: {"order":{"Command Content"}}
In some business scenarios, it is necessary to carry specific information (e.g., order number) in the command.You can add an extra field to the order object. For example:{"power":1,"extra":"T25030700001"}
This specific information will be returned as-is in the asynchronous message push corresponding to this command.
Note: The extra field only supports uppercase/lowercase letters (a-zA-Z) and numbers (0-9), with a maximum length of 32 characters. |
Return results
It should be noted that a status code of 200 only indicates that the platform has received a valid device ID and parameter name, and has successfully sent a command to the device.
However, the device may be offline, or there may be errors in the
| Name | Type | Description |
|---|---|---|
| code | int | 200: Command issued successfully.
501: No Device ID specified. The Device ID must be a single integer, or multiple integers separated by "|" or ",". This ID is available in the Device List API and can also be viewed in the Device List section of this console.
502: Device does not exist or no available devices. All provided Device IDs are invalid. Please check if the Device IDs are correct and whether the devices have been deleted.
503: Excessive devices specified. A maximum of 100 Device IDs can be specified at one time.
504: Multiple Device IDs specified, but some are unavailable (non-existent, no permission, or deleted).
50xx: Please refer to "Global Error Codes". |
4.2 Product supports commands
4.2.1 产品命令
| Command | Name | Content | Description |
|---|---|---|---|
| power1 | 通 | {"power1":"1"} | |
| 断 | {"power1":"0"} | ||
| power2 | 通 | {"power2":"1"} | |
| 断 | {"power2":"0"} | ||
| power3 | 通 | {"power3":"1"} | |
| 断 | {"power3":"0"} | ||
| power4 | 通 | {"power4":"1"} | |
| 断 | {"power4":"0"} | ||
| volume | 0 | {"volume":"0"} | |
| 1 | {"volume":"1"} | ||
| 2 | {"volume":"2"} | ||
| 3 | {"volume":"3"} | ||
| 4 | {"volume":"4"} | ||
| 5 | {"volume":"5"} | ||
| 6 | {"volume":"6"} | ||
| 7 | {"volume":"7"} | ||
| 8 | {"volume":"8"} | ||
| 9 | {"volume":"9"} | ||
| voice | Female voice | {"voice":"0"} | |
| Male voice | {"voice":"1"} | ||
| speed | 0 | {"speed":"0"} | |
| 1 | {"speed":"1"} | ||
| 2 | {"speed":"2"} | ||
| 3 | {"speed":"3"} | ||
| 4 | {"speed":"4"} | ||
| 5 | {"speed":"5"} | ||
| 6 | {"speed":"6"} | ||
| 7 | {"speed":"7"} | ||
| 8 | {"speed":"8"} | ||
| 9 | {"speed":"9"} | ||
| tone | 0 | {"tone":"0"} | |
| 1 | {"tone":"1"} | ||
| 2 | {"tone":"2"} | ||
| 3 | {"tone":"3"} | ||
| 4 | {"tone":"4"} | ||
| 5 | {"tone":"5"} | ||
| 6 | {"tone":"6"} | ||
| 7 | {"tone":"7"} | ||
| 8 | {"tone":"8"} | ||
| 9 | {"tone":"9"} | ||
| batch | 全开 | {"batch":{"power":1}} | |
| 全关 | {"batch":{"power":0}} | ||
| 线路1|3开 | {"batch":{"relay":[1,3],"power":1}} | ||
| 线路1|3关 | {"batch":{"relay":[1,3],"power":0}} | ||
| 线路2|4|6开 | {"batch":{"relay":[2,4],"power":1}} | ||
| 线路2|4|6关 | {"batch":{"relay":[2,4],"power":0}} | ||
| point | 500毫秒,全部线路 | {"point":{"interval":500}} | |
| 1秒,线路1|3 | {"point":{"relay":[1,3],"interval":1000}} | ||
| 2秒,线路2 | {"point":{"relay":[2],"interval":2000}} | ||
| reset | 500毫秒,全部线路 | {"reset":{"interval":500}} | |
| 1秒,线路1|3 | {"reset":{"relay":[1,3],"interval":1000}} | ||
| 2秒,线路2 | {"reset":{"relay":[2],"interval":2000}} | ||
| 5秒,线路2|4 | {"reset":{"relay":[2,4],"interval":5000}} | ||
| play:gbk:16 | 到账提醒 | {"play:gbk:16":"支付宝到账200元"} | |
| 业务提醒 | {"play:gbk:16":"你好,小程序上有新的业务线索:河北的刘先生要定制一款小程序,请及时处理"} | ||
| 工作通知(男声) | {"play:gbk:16":"[m1]小王,请你到一下张总的办公室"} | ||
| 长文本 | {"play:gbk:16":"今天天气非常晴朗,暖暖的太阳照在人身上真舒服。我不禁的感叹:这真是美好的一天。最长不要超过50个字符,如果超过50个,可分多条连续下发命令。"} | ||
| 提示音+文字 | {"play:gbk:16":"[message_3]欢迎光临"} | ||
| 数字 | {"play:gbk:16":"ID为[n1]888,手机号码为[n3]18500860080的客户,共消费[n2]1888元,优惠100元。"} | ||
| 多音字 | {"play:gbk:16":"请把空调调[=diao4]转一下角度"} | ||
| 停顿 | {"play:gbk:16":"你[w0]好,你好"} | ||
| ring | 1 | {"ring":"1"} | |
| 2 | {"ring":"2"} | ||
| 3 | {"ring":"3"} | ||
| 4 | {"ring":"4"} | ||
| 5 | {"ring":"5"} | ||
| message | 1 | {"message":"1"} | |
| 2 | {"message":"2"} | ||
| 3 | {"message":"3"} | ||
| 4 | {"message":"4"} | ||
| 5 | {"message":"5"} | ||
| alert | 1 | {"alert":"1"} | |
| 2 | {"alert":"2"} | ||
| 3 | {"alert":"3"} | ||
| 4 | {"alert":"4"} | ||
| 5 | {"alert":"5"} | ||
| stop | 停止当前 | {"stop":"0"} | |
| 全部停止 | {"stop":"1"} |
4.2.2 System command
| Command | Name | Content | Description |
|---|---|---|---|
| system | GetNetworkInfo | network | |
| Get device status | state | ||
| Connect WiFi | wifi_connect | ||
| Connect to configured WiFi | wifi_connect_multi | ||
| Disconnect WiFi | wifi_disconnect | ||
| Enter private deployment mode (If configured) |
private | ||
| Reboot | restart |