Cloud Timer

Last Updated on : 2023-10-12 08:00:24download

This topic describes APIs related to scheduling timer tasks.

Note: To use commonApi, you need to install dependencies first, click here to install dependencies.

One-timer task

Use one timer to schedule a specified task for execution at the specified time. For example, enable a Wi-Fi socket to be turned off at a specified time.

Note: Up to 30 timer tasks can be scheduled. A task cannot be queried repeatedly within two seconds. Otherwise, the API will return the error code Repeat Operation.

Schedule a one-timer task

Name

addSingleTimer

Description

Schedule a one-timer task.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType String The device type.
0: individual device.
1: group of devices.
Yes
loops String Specify that a task is executed on specific days of the week.
0 indicates a task is scheduled for one-time execution. For 0000000, each 0 from the left to the right denotes Sunday through Saturday respectively. Change 0 to 1 to enable repeated execution periodically.
No
category String The timer category. No
status Integer Initialization status.
0: The timer is off.
1: The timer is on.
No
actions String The action to be performed by a timer task. Yes
isAppPush Boolean Whether to send an execution notification. No
aliasName String The alias of a timer task. No

Return parameter

Parameter Data type Description
response Number The timer ID.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.addSingleTimer({
  bizId: 'vdevo158944348402685', // Determine whether a groupId exists according to getDevInfo. If groupId exists, it is a group of devices. Otherwise, it is an individual device.
  bizType: '0',
  loops: '0000000',
  category: 'category', // You can define a category, which must be consistent with the one defined for the task query.
  status: 1, // Whether the timer is on.
  actions: '{"dps":{"1":true,"2":false},"time":"17:40"}', // The action to be performed by a timer task. 
  isAppPush: true,
  aliasName: 'xxxxxx',
})
  .then(response => {
    console.log(response);
    console.log(JSON.stringify(response));
  }).catch();
}

Sample response

10029007

Query a timer task

Name

queryTimerTasks

Description

Query a timer task.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
category String The timer category. Yes

Return parameter

Parameter
Data type
Description
categoryStatus Number The category status.
id String The ID of a timer task.
category String The timer category.
timers Timers[] See the table Timers below.

Timers

Parameter
Data type
Description
status Number Initialization status.
0: The timer is off.
1: The timer is on.
loops String Specify that a task is executed on specific days of the week.
0 indicates a task is scheduled for one-time execution. For 0000000, each 0 from the left to the right denotes Sunday through Saturday respectively. Change 0 to 1 to enable repeated execution periodically.
time String The specified execution time.
id Number The primary key of a timer task.
isAppPush Boolean Whether to send an execution notification.
dps String The value of a data point (DP).
groupOrder Number The order of a timer group.
groupId String The ID of a timer group.
aliasName String The alias of a timer group.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.queryTimerTasks({
  bizId: 'vdevo158944348402685',
  bizType: '0',
  category: 'category',
})
  .then(response => {
    console.log(response);
  }).catch();

Sample response

{
  "categoryStatus": 1,
  "id": "000000d5c3",
  "category": "category",
  "timers": [
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 6281604,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 9442186,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6280599,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000147x1",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6281557,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148nu",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 9441872,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029jin",
      "aliasName": "xxxxxx"
    },
    {
      "status": 1,
      "loops": "0000000",
      "time": "17:40",
      "id": 10123021,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "000002hp0i",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 6281603,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 9442187,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    }
  ]
}

Modify a timer

Name

modifySingleTimer

Description

Modify a timer.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
id Long The primary key of a timer task. Yes
loops String Specify that a task is executed on specific days of the week.
0 indicates a task is scheduled for one-time execution. For 0000000, each 0 from the left to the right denotes Sunday through Saturday respectively. Change 0 to 1 to enable repeated execution periodically.
No
status Integer Initialization status.
0: The timer is off.
1: The timer is on.
No
actions String The action to be performed by a timer task. Yes
isAppPush Boolean Whether to send an execution notification. No
aliasName String The alias of a timer group. No

Return parameter

Parameter Data type Description
response Boolean Whether a timer is modified successfully.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.modifySingleTimer({
  bizId: '',
  bizType: '1',
  id: 1,
  loops: '',
  status: 1,
  actions: '',
  isAppPush: true,
  aliasName: '',
})
  .then(response => {
  console.log(response);
}).catch();

Sample response

true

Timer group

Use multiple timers to schedule a specified task for execution. For example, you can specify a start time and end time for a task.

Create a timer group

Name

addGroupTimer

Description

Create a timer group.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
loops String Specify that a task is executed on specific days of the week.
0 indicates a task is scheduled for one-time execution. For 0000000, each 0 from the left to the right denotes Sunday through Saturday respectively. Change 0 to 1 to enable repeated execution periodically.
No
category String The timer category. No
status Integer Initialization status.
0: The timer is off.
1: The timer is on.
No
actionsArray String The action to be performed by a timer task. Yes
isAppPush Boolean Whether to send an execution notification. No
aliasName String The alias of a timer task. No

Return parameter

Parameter Data type Description
response Number The ID of a timer group.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.addGroupTimer({
  bizId: 'vdevo158944348402685', // Determine whether a groupId exists according to getDevInfo. If groupId exists, it is a group of devices. Otherwise, it is an individual device.
  bizType: '0',
  loops: '0000000',
  category: 'category', // You can define a category, which must be consistent with the one defined for the task query.
  status: 1, // Whether the timer is on.
  // The actions to be performed by a timer task. 
  actionsArray:
  '[{"dps":{"1":true,"2":false},"time":"09:40"},{"dps":{"1":true,"2":false},"time":"21:00"}]',
  isAppPush: true,
  aliasName: 'xxxxxx',
})
  .then(response => {
  console.log(response);
}).catch();

Sample response

10029014
10029015

Query a timer group

Name

queryGroupTimerTasks

Description

Query a timer group.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
category String The timer category. Yes

Return parameter

Parameter Data type Description
categoryStatus Number The category status.
id String The ID of a timer task.
category String The timer category.
timers Timers[] See the table Timers below.

Timers

Parameter
Data type
Description
status Number Initialization status.
0: The timer is off.
1: The timer is on.
loops String Specify that a task is executed on specific days of the week.
0 indicates a task is scheduled for one-time execution. For 0000000, each 0 from the left to the right denotes Sunday through Saturday respectively. Change 0 to 1 to enable repeated execution periodically.
time String The specified execution time.
id Number The primary key of a timer task.
isAppPush Boolean Whether to send an execution notification.
dps String The DP value.
groupOrder Number The order of a timer group.
groupId String The ID of a timer group.
aliasName String The alias of a timer group.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.queryGroupTimerTasks({
  bizId: 'vdevo158944348402685',
  bizType: '0',
  category: 'category',
})
  .then(response => {
  console.log(response);
}).catch();

Sample response

{
  "categoryStatus": 1,
  "id": "000000d5c3",
  "category": "category",
  "timers": [
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 6281604,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 9442186,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6280599,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000147x1",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6281557,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148nu",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 9441872,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029jin",
      "aliasName": "xxxxxx"
    },
    {
      "status": 1,
      "loops": "0000000",
      "time": "17:40",
      "id": 10123021,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "000002hp0i",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 6281603,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 9442187,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    }
  ]
}

Modify a timer group

Name

modifyGroupTimer

Description

Modify a timer group.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
loops String Specify that a task is executed on specific days of the week.
0 indicates a task is scheduled for one-time execution. For 0000000, each 0 from the left to the right denotes Sunday through Saturday respectively. Change 0 to 1 to enable repeated execution periodically.
No
status Integer Initialization status.
0: The timer is off.
1: The timer is on.
No
actionsArray String The action to be performed by a timer task. Yes
isAppPush Boolean Whether to send an execution notification. No
aliasName String The alias of a timer task. No

Return parameter

Parameter Data type Description
response Boolean Whether a timer is modified successfully.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.modifyGroupTimer({
  bizId: 'vdevo158944348402685',
  bizType: '0',
  loops: '1111111',
  actionsArray:
  '[{"dps":{"1":true,"2":false},"time":"09:40","timerId":"$VAR:timerIdArray[0]"},{"dps":{"1":true,"2":false},"time":"21:00"},"timerId":"$VAR:timerIdArray[1]"]',
  isAppPush: false,
  aliasName: 'xxxxxx',
}).then((response) => {
    console.log(response);
}).catch();

Sample response

true

Open APIs

Note: Use the open APIs to individually modify a timer.

Modify or delete a timer by timer ID

Name

modDeleteTaskByIds

Description

Modify or delete a timer by timer ID.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
ids String The timer ID. Separate multiple timer IDs with a comma (,), such as "1,2,3,4". Up to 168 timers are allowed one time. Yes
status Integer Initialization status.
0: The timer is off.
1: The timer is on.
2: The timer is deleted.
Yes

Return parameter

Parameter Data type Description
response Boolean Whether a timer is modified or deleted successfully.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.modDeleteTaskByIds({
  bizId: 'vdevo158944348402685', 
  // Determine whether a groupId exists according to getDevInfo. If groupId exists, it is a group of devices. Otherwise, it is an individual device.
  bizType: '0',
  ids: '1', // The timer ID.
  status: 0, // The timer status.
}).then((response) => {
    console.log(response);
}).catch();

Sample response

true

Modify or delete a timer by category

Name

modDeleteTaskByCategory

Description

Modify or delete a timer by category.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
category String The timer category. Yes
status Integer Initialization status.
0: The timer is off.
1: The timer is on.
2: The timer is deleted.
Yes

Return parameter

Parameter Data type Description
response Boolean Whether a timer is modified or deleted successfully.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.modDeleteTaskByCategory({
  bizId: "vdevo158944348402685",
  bizType: 0,
  category: "category",
  status: 2
}).then((response) => {
    console.log(response);
}).catch();

Sample response

true

Get the latest timer of a specified DP

Name

getDpLastTimer

Description

Get the latest timer of a specified DP.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
type String It can be a group of devices or an individual device. Yes
instruct String The command to be executed. No

Return parameter

Parameter Data type Description
time string The specified execution time.
status number Timer status.
0: The timer is off.
1: The timer is on.
2: The timer has expired or is deleted.
project number The identification of a custom project.
actionStr string The action to be performed by a timer task.
groupOrder number The order of a timer group.
gmtModified number The time when a timer is modified.
gmtCreate number The time when a timer is created.
uuid string Device UUID.
runMode number The type of a timer task.
0: cloud timer task.
1: local timer task.
devId string The device ID.
id number The ID of a timer task.
date string The execution data.
timeZone string The time zone.
uid string UID.
timezoneId string The time zone ID.
bizType bizType[] The device type.
0: individual device.
1: group of devices.
value value[] The value of an action.
groupId string The ID of a timer group.
loops string Weekly schedule.
timerType number The timer type. 0: common timer. 5: sunrise/sunset timer.
categoryId string The service categories of timers, distinguished by categoryId.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.getDpLastTimer({
  bizId: '',
  type: '',
  instruct: '',
}).then((response) => {
    console.log(response);
}).catch();

Sample response

{
   "time": "12:58",
   "status": 1,
   "project": 0,
   "actionStr": "[{\"instruct\":{\"devId\":\"vdevo155056934890734\",\"dps\":{\"1\":true}},\"type\":\"device\"}]",
   "groupOrder": 0,
   "gmtModified": 1553226629,
   "gmtCreate": 1553226629,
   "uuid": "vdevo155056934890734",
   "runMode": 1,
   "devId": "vdevo155056934890734",
   "id": 2669530,
   "date": "20190322",
   "timeZone": "+08:00",
   "uid": "ay1500284851319yH7ZY",
   "timezoneId": "Asia/Shanghai",
   "bizType": {
     "name": "DEVICE"
   },
   "value": {
     "1": true
   },
   "groupId": "0000006s02",
   "loops": "0000000",
   "timerType": 0,
   "categoryId": "00000027d5"
 }

Get the latest timer of multiple DPs

Name

getDpsLastTimer

Description

Get the latest timer of multiple DPs.

Request parameter

Parameter
Data type
Description
Required
bizId String The device ID.
devId indicates the ID of an individual device.
groupId indicates the ID of a device group.
Yes
type String It can be a group of devices or an individual device. Yes
instruct String The command to be executed. No

Return parameter

Parameter Data type Description
time string The specified execution time.
status number Timer status.
0: The timer is off.
1: The timer is on.
2: The timer has expired or is deleted.
project number The identification of a custom project.
actionStr string The action to be performed by a timer task.
groupOrder number The order of a timer group.
gmtModified number The time when a timer is modified.
gmtCreate number The time when a timer is created.
uuid string Device UUID.
runMode number The type of a timer task.
0: cloud timer task.
1: local timer task.
devId string The device ID.
id number The ID of a timer task.
date string The execution data.
timeZone string The time zone.
uid string UID.
timezoneId string The time zone ID.
bizType bizType[] The device type.
0: individual device.
1: group of devices.
value value[] The value of an action.
groupId string The ID of a timer group.
loops string Weekly schedule.
timerType number The timer type. 0: common timer. 5: sunrise/sunset timer.
categoryId string The service categories of timers, distinguished by categoryId.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.getDpsLastTimer({
  bizId: '',
  type: '',
  instruct: '',
}).then((response) => {
    console.log(response);
}).catch();

Sample response

{
      "time": "12:58",
      "status": 1,
      "project": 0,
      "actionStr": "[{\"instruct\":{\"devId\":\"vdevo155056934890734\",\"dps\":{\"1\":true}},\"type\":\"device\"}]",
      "groupOrder": 0,
      "gmtModified": 1553226629,
      "gmtCreate": 1553226629,
      "uuid": "vdevo155056934890734",
      "runMode": 1,
      "devId": "vdevo155056934890734",
      "id": 2669530,
      "date": "20190322",
      "timeZone": "+08:00",
      "uid": "ay1500284851319yH7ZY",
      "timezoneId": "Asia/Shanghai",
      "bizType": {
        "name": "DEVICE"
      },
      "value": {
        "1": true
      },
      "groupId": "0000006s02",
      "loops": "0000000",
      "timerType": 0,
      "categoryId": "00000027d5"
}

Get the latest timer

Name

getLastTimerPeriod

Description

Get the latest timer, including determining the time period.

Request parameter

Parameter Data type Description Required
devId String The device ID. Yes
instruct String The command to be executed. No

Return parameter

Parameter Data type Description
categoryStatus Number The category status.
id String The ID of a timer task.
category String The timer category.
timers Timers[] See the table Timers below.

Timers

Parameter
Data type
Description
status Number Initialization status.
0: The timer is off.
1: The timer is on.
loops String Specify that a task is executed on specific days of the week.
0 indicates a task is scheduled for one-time execution. For 0000000, each 0 from the left to the right denotes Sunday through Saturday respectively. Change 0 to 1 to enable repeated execution periodically.
time String The specified execution time.
id Number The primary key of a timer task.
isAppPush Boolean Whether to send an execution notification.
dps String The DP value.
groupOrder Number The order of a timer group.
groupId String The ID of a timer group.
aliasName String The alias of a timer group.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.getLastTimerPeriod({
  devId: TYSdk.devInfo.devId,
  instruct: '',
})
  .then(response => {
    console.log(response);
  }).catch();

Sample response

{
  "categoryStatus": 1,
  "id": "000000d5c3",
  "category": "category",
  "timers": [
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 6281604,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 9442186,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6280599,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000147x1",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6281557,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148nu",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 9441872,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029jin",
      "aliasName": "xxxxxx"
    },
    {
      "status": 1,
      "loops": "0000000",
      "time": "17:40",
      "id": 10123021,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "000002hp0i",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 6281603,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 9442187,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    }
  ]
}

Sunrise/sunset timer

Get sunrise/sunset timer

Name

getAstronomicalList

Description

Get the list of sunrise/sunset timers.

Request parameter

Parameter Data type Description Required
bizId String The device ID (devId) or the ID of a device group (groupId). Yes

Return parameter

Parameter Data type Description
astronomicalType Number Sunrise or sunset.
bizId String The device ID (devId) or the ID of a device group (groupId).
bizType Number The device type.
0: individual device.
1: group of devices.
dps Dps[] The DP value.
id Number The ID of a timer task.
lat Number Latitude
lon Number Longitude.
loops String Weekly schedule.
nextSunRise String The next sunrise time.
offsetType Number The type of timer offset.
status Number Timer status.
0: The timer is off.
1: The timer is on.
2: The timer has expired or is deleted.
time String The specified execution time.
timezone String The time zone.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.getAstronomicalList({
  bizId: 'vdevo160456552237748',
})
  .then(response => {
  console.log(response);
  console.log(JSON.stringify(response));
}).catch();

Sample response

{
  "categoryStatus": 1,
  "id": "000000d5c3",
  "category": "category",
  "timers": [
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 6281604,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "09:40",
      "id": 9442186,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6280599,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000147x1",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 6281557,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "00000148nu",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "17:40",
      "id": 9441872,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "0000029jin",
      "aliasName": "xxxxxx"
    },
    {
      "status": 1,
      "loops": "0000000",
      "time": "17:40",
      "id": 10123021,
      "isAppPush": true,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 0,
      "groupId": "000002hp0i",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 6281603,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "00000148os",
      "aliasName": "xxxxxx"
    },
    {
      "status": 0,
      "loops": "0000000",
      "time": "21:00",
      "id": 9442187,
      "isAppPush": false,
      "dps": "{\"1\":true,\"2\":false}",
      "groupOrder": 1,
      "groupId": "0000029kfp",
      "aliasName": "xxxxxx"
    }
  ]
}

Schedule a sunrise/sunset timer task

Name

addAstronomical

Description

Schedule a sunrise/sunset timer task.

Request parameter

Parameter Data type Description Required
bizId String The device ID (devId) or the ID of a device group (groupId). Yes
bizType Integer 0: individual device.
1: group of devices.
Yes
loops String Weekly schedule: 1111111.
Yes
dps String The DP in JSON. Yes
astronomicalType Integer 0: sunrise.
1: sunset.
Yes
timezone String The time zone. Yes
date String yyyyMMdd No
time String The offset time in the format HH:mm (24-hour clock) Yes
offsetType Integer The offset type.
-1: move forward.
0: no offset.
1: move back.
Yes
lon Double Longitude. Yes
lat Double Latitude Yes

Return parameter

Parameter Data type Description
response Number The ID of a sunrise/sunset timer.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.addAstronomical({
  astronomicalType: 1,
  bizId: 'vdevo160456552237748',
  bizType: 0,
  dps: {
    '1': true,
  },
  lat: 30.300694,
  lon: 120.068634,
  loops: '1111111',
  offsetType: -1,
  time: '00:04',
  timezone: '+08:00',
}).then((response) => {
    console.log(response)
}).catch()

Sample response

10125352

Modify a sunrise/sunset timer task

Name

updateAstronomical

Description

Modify a sunrise/sunset timer task.

Request parameter

Parameter Data type Description Required
id Long The ID of a timer task. Yes
bizId String The device ID (devId) or the ID of a device group (groupId). Yes
bizType Integer The device type.
0: individual device.
1: group of devices.
Yes
loops String Weekly schedule: 1111111.
Yes
dps String The DP in JSON. Yes
astronomicalType Integer 0: sunrise.
1: sunset.
Yes
timezone String The time zone. Yes
date String yyyyMMdd No
time String The offset time in the format HH:mm (24-hour clock) Yes
offsetType Integer The offset type.
-1: move forward.
0: no offset.
1: move back.
Yes
lon Double Longitude. Yes
lat Double Latitude Yes

Return parameter

Parameter Data type Description
response Boolean Whether a sunrise/sunset timer is modified successfully.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi.updateAstronomical({
  id: 8642566,
  astronomicalType: 1,
  bizId: 'vdevo160456552237748',
  bizType: 0,
  dps: {
    '1': true,
  },
  lat: 30.300694,
  lon: 120.068634,
  loops: '1111111',
  offsetType: -1,
  time: '00:04',
  timezone: '+08:00',
})
  .then(response => {
    console.log(response);
  }).catch();

Sample response

 true

Whether to enable a sunrise/sunset timer

Name

updateAstronomicalStatus

Description

Whether to enable a sunrise/sunset timer.

Request parameter

Parameter Data type Description Required
id Long The ID of a timer task. Yes
status Integer 0: The timer is off.
1: The timer is on.
Yes

Return parameter

Parameter Data type Description
response Boolean Whether to enable a sunrise/sunset timer

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi
  .updateAstronomicalStatus({
    id: '8642566',
    status: 0,
  })
  .then(response => {
    console.log(response);
    console.log(JSON.stringify(response));
  })
  .catch();

Sample response

 true

Delete a sunrise/sunset timer

Name

removeAstronomical

Description

Delete a sunrise/sunset timer.

Request parameter

Parameter Data type Description Required
id String The ID of a timer task. Yes

Return parameter

Parameter Data type Description
response Boolean Whether a sunrise/sunset timer is deleted successfully.

Sample request

import { commonApi } from '@tuya/tuya-panel-api';

commonApi.timerApi
  .removeAstronomical({ id: '8642566' })
  .then(response => {
    console.log(response);
    console.log(JSON.stringify(response));
  })
  .catch();

Sample response

 true