Add Timer Task

Last Updated on : 2023-12-07 03:33:55download

Add a timer task for a specified device. Based on the parameter loops, the tasks are divided into cycle timer tasks and non-cycle timer tasks.
Cycle timing: take one week as a cycle, and set the cycle timing from Monday to Sunday.
Non-cycle timing: Set the timer task of a specified time node. The API will limit the set time node. The time node must be later than the current time. Otherwise, the timer task cannot be created, and a message is displayed that the timer task has expired.

API address

POST: /v1.0/devices/{devId}/timers

Request parameter

Parameter nameTypeINRequiredDescription
devIdStringuritrueThe device ID.

Description of body

Parameter nameTypeINRequiredDescription
categoryStringbodytrueThe timer category.
loopsStringbodytrueThe running time of a timer task. A seven-digit number consisting of 0 and 1. 0 means disabled and 1 means enabled.
time_zoneStringbodytrueThe time zone.
timezone_idStringbodytrueThe ID of the time zone.
instructobjectbodytrueThe specific time and device instructions of the timer task. Support setting multiple timer tasks that run simultaneously.
alias_nameStringbodyfalseThe alias.

Return parameter

Parameter nameTypeDescription
resultObjectReturn the result of task creation.
successBooleanIndicates whether the API is called successfully. Valid values:
  • true: The API call succeeded.
  • false: The API call failed.
tLongThe timestamp.
tidStringThe link ID.

Description of result

Parameter nameTypeDescription
group_idLongID of a timer task.

Request example

POST: /v1.0/devices/vdevo15445800464****/timers
{
  "category": "timer",
  "timezone_id": "Europe/Berlin",
  "timezone": "+1:00",
  "alias_name": "Guten Morgen",
  "instruct": [
    {
      "functions": [
        {
          "code": "feed_num",
          "value": 3
        }
      ],
      "date": "",
      "time": "6:0"
    }
  ],
  "loops": "1111111"
}

Return example

{
    "tid": "c3d213a97df711eea3b2361f03176748",
    "result": {
        "group_id": "0001699421359116"
    },
    "t": 1699421359166,
    "success": true
}

Error code

For more information, see error code.