Last Updated on : 2024-06-05 03:14:35download
This topic describes the API operations that you can call to manage scenes for a specific device.
Note: To use commonApi, you need to install dependencies first, click here to install dependencies.
Name
getAllBindScenes
Description
Returns all scenes that are bound to a specific device.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
devId | String | The device ID. | Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
actionExcutor | String | The actuator type. |
bindType | Number | The type of connection. Valid values:0 : Zigbee. 1 : Wi-Fi. |
btnId | Number | The key ID. |
condRuleId | String | The rule ID. |
devId | String | The device ID. |
dpId | Number | The DP triggered. |
dpValue | String | The trigger condition. |
gwId | String | The gateway to which the device belongs. |
localSid | String | The ID of a standard scene. |
ruleBackground | String | The background image of a rule. |
ruleId | String | The rule ID. |
ruleName | String | The rule name. |
Sample request
import { commonApi } from '@tuya/tuya-panel-api';
commonApi.sceneApi
.getAllBindScenes(TYSdk.devInfo.devId)
.then(response => {
console.log(response);
console.log(JSON.stringify(response));
})
.catch();
Sample response
{
"actionExcutor": "ruleTrigger"
"bindType": 1
"btnId": 1
"condRuleId": "ZWMEhApntHz7p4jR"
"devId": "vdevo159297901023732"
"dpId": 2
"dpValue": "scene"
"gwId": ""
"localSid": ""
"ruleBackground": "https://images.tuyacn.com/smart/rule/cover/game.png"
"ruleId": "pEsqbS4OOpDPKfTg"
"ruleName": "222"
}
Name
getAllCreatedScenes
Description
Returns all scenes that are created for a specific device.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
devId | String | The device ID. | Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
attribute | Number | The attribute ID. |
auditStatus | Number | The audit status. |
background | String | The background. |
boundForPanel | Boolean | Indicates whether a scene is bound to a scene panel. |
boundForWiFiPanel | Boolean | Indicates whether a scene is bound to a Wi-Fi scene panel. |
Code | String | The rule code. |
commonField | String | The common attributes. |
coverIcon | String | The icon. |
disableTime | Number | The expiration time. |
displayColor | String | The color displayed. |
enabled | Boolean | Indicates whether to enable a scene. |
gmtCreate | Number | The timestamp when the scene was created. |
gmtModified | Number | The timestamp when the scene was updated. |
id | String | The rule ID. |
localLinkage | Boolean | Indicates whether the local linkage feature is used. |
matchType | Number | The matching type. Valid values:1 : ANY 2 : ALL 3 : EXPR |
name | String | The rule name. |
newLocalScene | Boolean | Indicates whether the local linkage feature is managed with an app. |
ownerId | String | The home ID. |
ruleSource | Number | The rule source that is used to identify the external event source. |
ruleType | Number | The rule type. 3 : user-defined. |
scenarioRule | Boolean | The scene type. Valid values: 1 : standard scenes. 0 : custom scenes. |
stickyOnTop | Boolean | Indicates whether the scene is displayed on the homepage. |
uid | String | The user ID. |
Sample request
import { commonApi } from '@tuya/tuya-panel-api'
commonApi.sceneApi
.getAllCreatedScenes(TYSdk.devInfo.devId)
.then(response => {
console.log(response);
console.log(JSON.stringify(response));
})
.catch();
Sample response
{
"attribute": 68
"auditStatus": 0
"background": "https://images.tuyacn.com/smart/rule/cover/sport.png"
"boundForPanel": false
"boundForWiFiPanel": true
"code": ""
"commonField": ""
"coverIcon": "https://images.tuyacn.com/smart/rule/glyphicons/label.png"
"disableTime": 0
"displayColor": "E67578"
"enabled": true
"gmtCreate": 1587882013266
"gmtModified": 1587893193584
"id": "syQnbkArISqHlGvm"
"iotAutoAlarm": false
"localLinkage": false
"logicRule": false
"matchType": 1
"name": "Smart Disinfector""Disinfection: On"
"newLocalScene": false
"ownerId": "11740421"
"ruleSource": 0
"ruleType": 3
"scenarioRule": true
"stickyOnTop": true
"uid": "ay1539583689295nLjlV"
}
Name
bindSelectedScene
Description
Bind the selected scene.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
devId | String | The device ID. | Yes |
btnId | Double | The key ID. | Yes |
ruleId | String | The rule ID. | Yes |
dpId | Double | The bound DP ID. | Yes |
dpValue | String | The trigger condition. | Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
response | Boolean | Whether a scene is bound successfully. |
Sample request
import { commonApi } from '@tuya/tuya-panel-api'
commonApi.sceneApi
.bindSelectedScene({
devId: 'vdevo159297901023732',
btnId: '1',
dpId: 2,
dpValue: 'scene',
ruleId: 'ZRfxzOhXJAP2aI2a',
})
.then(response => {
console.log(response);
console.log(JSON.stringify(response));
})
.catch();
Sample response
true
Name
unBindScene
Description
Unbind a scene.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
devId | String | The device ID. | Yes |
btnId | Double | The key ID. | Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
response | Boolean | Whether a scene is unbound successfully. |
Sample request
import { commonApi } from '@tuya/tuya-panel-api'
commonApi.sceneApi
.unBindScene({
devId: 'vdevo159297901023732',
btnId: '1',
})
.then(response => {
console.log(response);
console.log(JSON.stringify(response));
})
.catch();
Sample response
true
Name
triggerScene
Description
Trigger a scene.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
ruleId | String | The rule ID of a scene. | Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
response | Boolean | Whether a scene is triggered successfully. |
Sample request
import { commonApi } from '@tuya/tuya-panel-api'
commonApi.sceneApi
.triggerScene('vdevo159297901023732')
.then(response => {
console.log(response);
console.log(JSON.stringify(response));
})
.catch();
Sample response
true
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback