Last Updated on : 2023-06-01 06:20:18download
This topic describes the related APIs of timing management.
Request method |
API | Description |
|---|---|---|
| POST | /v1.0/devices/{device_id}/timers | Add a timing task to the device |
| GET | /v1.0/devices/{device_id}/timers | Query the list of timing tasks of the device |
| GET | /v1.0/devices/{device_id}/timers /categories/{category} |
Get the information of timing tasks in a specified category |
| PUT | /v1.0/devices/{device_id}/timers /groups/{group_id} |
Update the information of a specified timing task group of the device |
| PUT | /v1.0/devices/{device_id}/timers /categories/{category}/groups/{group_id}/status |
Update the status of a specified timing task group of the device |
| DELETE | /v1.0/devices/{device_id}/timers | Delete all timing tasks of the device |
| DELETE | /v1.0/devices/{device_id}/timers /categories/{category} |
Delete the timing tasks in a specified category |
| DELETE | /v1.0/devices/{device_id}/timers /categories/{category}/groups/{group_id} |
Delete the timing tasks of a specified task group in a specified category |
This interface is used to add timing tasks for a device. Use loops to determine a cyclic timing task or non-cyclic timing task.
POST /v1.0/devices/{device_id}/timers
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID. |
| category | String | BODY | Yes | Timing category. |
| loops | String | BODY | Yes | Return a 7-digit number consisting of 0 and 1 if the request failed. 0 represents closed, and 1 represents open. For example, 0000010 indicates that the task on Saturday is open and other days are closed. |
| time_zone | String | BODY | Yes | Time zone. For example, use +08:00 for China. |
| timezone_id | String | BODY | Yes | Time zone ID, such as Asia/shanghai. |
| instruct | Array<instruct> | BODY | Yes | The specific time and device instructions of a timing task. Multiple tasks are allowed to be set simultaneously. |
| alias_name | String | BODY | No | Alias name. |
Description of instruct
| Parameter name | Data type | Required | Description |
|---|---|---|---|
| time | String | Yes | Executing time of a timing task |
| functions | Array<functions> | Yes | Instructions to be executed at a scheduled time |
| date | String | NoNote: When |
Executing date of a timing task |
Description of functions
| Parameter name | Data type | Required | Description |
|---|---|---|---|
| code | String | Yes | The code of the instruction that is to be executed |
| value | Object | Yes | The value of the instruction that is to be executed |
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Object<result> | The returned result. |
Description of result
| Parameter name | Data type | Description |
|---|---|---|
| group_id | String | Timing task ID |
POST /v1.0/devices/vdevo153490924111111/timers
{
"instruct":[
{
"functions":[
{
"code":"switch_led",
"value":true
},
{
"code":"bright_value_v2",
"value":500
}
],
"date":"20200210",
"time":"17:41"
}
],
"loops":"0000000",
"category":"test",
"timezone_id":"Asia/Shanghai",
"time_zone":"+8:00"
}
N/A
{ "success": true, "result": { "group_id": "000000****" } }
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
| 1109 | Illegal parameter |
This interface is used to query the list of timing task details of a specified device ID.
GET /v1.0/devices/{device_id}/timers
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID |
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Object<result> | The returned result. |
Description of result
| Parameter name | Data type | Description |
|---|---|---|
| groups | Array<groups> | The list of timing task information |
| category | Object<category> | Information of timing task category |
Description of groups
| Parameter name | Data type | Description |
|---|---|---|
| timers | Object<timers> | Timing task information |
| id | String | Timing task number |
Description of category
| Parameter name | Data type | Description |
|---|---|---|
| category | String | Timing task category |
| status | Integer | The status of a timing task category |
Description of timers
| Parameter name | Data type | Description |
|---|---|---|
| date | String | Date of the set timing task |
| timezone_id | String | Time zone ID |
| loops | String | Cyclic timing information |
| time | String | The set time |
| status | Integer | Status of the timing task
|
| functions | Array<functions> | Instruction of timing |
| group_order | Integer | Specified order |
| timer_id | Integer | The unique identifier of timing information |
| alias_name | String | Remarks |
Description of functions
| Parameter name | Data type | Required | Description |
|---|---|---|---|
| code | String | Yes | The code of the instruction that is to be executed |
| value | Object | Yes | The value of the instruction that is to be executed |
GET /v1.0/devices/vdevo154458004640011/timers
N/A
{
"result": [
{
"category": {
"category": "test",
"status": 1
},
"groups": [
{
"id": "000000mwf3",
"timers": [
{
"alias_name": "",
"date": "20200210",
"functions": [
{
"code": "bright_value_v2",
"value": 5000
},
{
"code": "switch_led",
"value": true
}
],
"group_order": 0,
"is_app_push": false,
"loops": "0000000",
"status": 0,
"time": "17:30",
"timer_id": 4906528,
"timezone_id": "Asia/Shanghai"
}
]
}
]
}
],
"success": true,
"t": 1581336613789
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
This interface is used to get the timing task information of a specified category under a specified device.
GET /v1.0/devices/{device_id}/timers/categories/{category}
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID |
| category | String | URI | Yes | Timing category |
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Object<result> | The returned result. |
Description of result
| Parameter name | Data type | Description |
|---|---|---|
| groups | Array<groups> | The list of timing task information |
| category | Object<category> | The update time of device status |
Description of groups
| Parameter name | Data type | Description |
|---|---|---|
| timers | Object<timers> | Timing task information |
| id | String | Timing task number |
Description of category
| Parameter name | Data type | Description |
|---|---|---|
| category | String | Timing task category |
| status | Integer | The status of a timing task category |
Description of timers
| Parameter name | Data type | Description |
|---|---|---|
| date | String | Date of the set timing task |
| timezone_id | String | Time zone ID |
| loops | String | Cyclic timing information |
| time | String | The set time |
| status | Integer | Status of the timing task
|
| functions | Array<functions> | Instruction of timing |
| group_order | Integer | Specified order |
| timer_id | Integer | The unique identifier of timing information |
| alias_name | String | Remarks |
Description of functions
| Parameter name | Data type | Required | Description |
|---|---|---|---|
| code | String | Yes | The code of the instruction that is to be executed |
| value | Object | Yes | The value of the instruction that is to be executed |
GET /v1.0/devices/vdevo154458004640011/timers/categories/10
N/A
{
"result": [
{
"category": {
"category": "test",
"status": 1
},
"groups": [
{
"id": "000000mwf3",
"timers": [
{
"alias_name": "",
"date": "20200202",
"functions": [
{
"code": "bright_value_v2",
"value": 5000
},
{
"code": "switch_led",
"value": true
}
],
"group_order": 0,
"is_app_push": false,
"loops": "0000000",
"status": 0,
"time": "17:30",
"timer_id": 4906528,
"timezone_id": "Asia/Shanghai"
}
]
}
]
}
],
"success": true,
"t": 1581336613789
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
This interface is used to update the information of a specified timing task group of the device.
PUT /v1.0/devices/{device_id}/timers/groups/{group_id}
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID. |
| group_id | String | URI | Yes | Timing task group ID |
| loops | String | BODY | Yes | A 7-digit number consisting of 0 and 1. 0 means closed, and 1 means open. For example, 0000010 indicates that the task on Saturday is open and other days are closed. |
| category | String | BODY | Yes | Timing task category |
| time_zone | String | BODY | Yes | Time zone. For example, use +08:00 for China. |
| timezone_id | String | BODY | Yes | Time zone ID, such as Asia/shanghai. |
| instruct | Array<instruct> | BODY | Yes | The specified time and device instructions of a timing task. Multiple tasks are allowed to be set simultaneously. |
| alias_name | String | BODY | No | Alias name. |
Description of instruct
| Parameter name | Data type | Required | Description |
|---|---|---|---|
| time | String | Yes | Executing time of a timing task |
| functions | Array<functions> | Yes | Instructions to be executed at a scheduled time |
| date | String | NoNote: When |
Executing date of a timing task |
Description of functions
| Parameter name | Data type | Required | Description |
|---|---|---|---|
| code | String | Yes | The code of the instruction that is to be executed |
| value | Object | Yes | The value of the instruction that is to be executed |
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Boolean | Determine whether the request succeeded or not. It will return null if it failed. |
PUT /v1.0/devices/vdevo154458004640011/timers/groups/100
{
"loops":"0001000",
"time_zone":"+08:00",
"timezone_id":"Asia/ShangHai",
"category":"test",
"instruct":[
{
"time":"12:00",
"date":"20181212",
"functions":[
{
"code":"switch",
"value":true
},
{
"code":"bright",
"value":100
}
]
},
{
"time":"12:10",
"date":"20181212",
"functions":[
{
"code":"switch",
"value":false
}
]
}
]
}
N/A
{ "success": true, "result": true }
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
This interface is used to update the status of the device timing task group.
PUT /v1.0/devices/{device_id}/timers/categories/{category}/groups/{group_id}/status
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID |
| group_id | String | URI | Yes | Timing task group ID |
| category | String | URI | Yes | Timing task group category |
| value | String | BODY | Yes | Timing task status
|
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Boolean | Determine whether the request succeeded or not. It will return null if it failed. |
PUT /v1.0/devices/vdevo154458004640011/timers/categories/100/groups/0000002ftg/status
{
"value": "0"
}
TuyaClient client = new TuyaClient(clientId, secret, RegionEnum.CN);
List<DeviceVo> deviceFunctions = client.getUserDevices(UID);
System.out.println("Get the device list of the user: ");
System.out.println(JSONObject.toJSONString(deviceFunctions));
{
"success": true,
"result": true
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
This interface is used to delete all timing tasks of the device.
DELETE /v1.0/devices/{device_id}/timers
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID |
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Boolean | Determine whether the request succeeded or not. It will return null if it failed. |
DELETE /v1.0/devices/vdevo154458004640011/timers
N/A
{
"success": true,
"result": true
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
This interface is used to delete the timing task in a specified category.
DELETE /v1.0/devices/{device_id}/timers/categories/{category}
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID |
| category | String | URI | Yes | Timing task group category |
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Boolean | Determine whether the request succeeded or not. It will return null if it failed. |
DELETE /v1.0/devices/vdevo154458004640011/timers/categories/100
N/A
{
"success": true,
"result": true
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
Delete the timing task of a specified timing group in a specified category.
DELETE /v1.0/devices/{device_id}/timers/categories/{category}/groups/{group_id}
| Parameter name | Data type | Parameter type | Required | Description |
|---|---|---|---|---|
| device_id | String | URI | Yes | Device ID |
| category | String | URI | Yes | Timing task category |
| group_id | String | URI | Yes | Timing task group ID |
| Parameter name | Data type | Description |
|---|---|---|
| code | Integer | Response code. See Error code. |
| success | Boolean | Determine whether the request succeeded or not.
|
| msg | String | The message returned if the request fails. It will return null if the request succeeds. |
| result | Boolean | Determine whether the request succeeded or not. It will return null if it failed. |
DELETE /v1.0/devices/vdevo154458004640011/timers/categories/100/groups/0000002ftg
N/A
{
"success": true,
"result": true
}
The following are common service exceptions for this interface. For more exception errors, see Error Code.
| Error code | Description |
|---|---|
| 500 | System error |
| 1106 | Illegal permission |
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback