Add Scheduled Task

Last Updated on : 2023-07-25 05:59:27download

Add a scheduled task under the specified device.

API address

POST: /v2.0/cloud/timer/device/{device_id}

Request parameter

Parameter nameTypeINRequiredDescription
device_idStringpathtrueThe device ID.

Description of body

Parameter nameTypeINRequiredDescription
alias_nameStringbodytrueThe alias of the specified scheduled task.
timeStringbodytrueThe time when the specified scheduled task is run.
timezone_idStringbodytrueThe ID of the specified time zone. Example: Asia/Shanghai.
dateStringbodyfalseThe date when the specified scheduled task is run.
loopsStringbodyfalseIf a request failed, the return value is a seven-digit number consisting of 0 and 1. 0 indicates that the scheduled task is disabled, and 1 indicates that the scheduled task is enabled. For example, 0000001 means that the scheduled task is disabled on Sunday, Monday, Tuesday, Wednesday, Thursday, and Friday, and enabled on Saturday.
functionsListbodytrueThe command to be executed at the specified time.
categoryStringbodyfalseThe category of the specified scheduled task.

Description of functions

Parameter nameTypeINRequiredDescription
codeStringbodytrueThe code of the specified command to be executed.
valueobjectbodytrueThe value of the specified command to be executed.

Return parameter

Parameter nameTypeDescription
resultResponseThe returned result.

Description of result

Parameter nameTypeDescription
time_idStringThe ID of the specified scheduled task.

Request example

POST: /v2.0/cloud/timer/device/6ccb7dc348****
{
  "alias_name": "Scheduled Task Test",
  "time": "14:52",
  "timezone_id": "Asia/Shanghai",
  "date": "20230330",
  "functions": [
    {
      "code": "switch_1",
      "value": true
    }
  ]
}

Return example

{
    "tid": "74e53698d1f611ed9aa2525400d49d82",
    "result": {
        "timer_id": "1****"
    },
    "t": 1680509198203,
    "success": true
}

Error code

For more information, see error code.

Limits on API Request Frequency

For more information, see Limits on API Request Frequency.