Alert

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

This topic describes the API operations that you can call to manage alerts for a specific device.

Note:
1.To use these API operations, you need to configure the push notification function for the specified product. For more information, see Configure Push Notification.
2.To use commonApi, you need to install dependencies first, click here to install dependencies.

Query a list of alerts

Name

getDevAlarmList

Description

Returns a list of alerts by device ID.

Request parameter

Parameter Data type Description Required
devId String The device ID. Yes

Return parameter

Parameter Data type Description
auditStatus Number The audit status.
boundForPanel Boolean Indicates whether an alert is bound to a scene panel.
boundForWiFiPanel Boolean Indicates whether an alert is bound to a Wi-Fi scene panel.
enabled Boolean Indicates whether an alert is enabled.
i18nData { name: { en: string; zh: string } Multilingual data.
id String The rule ID.
localLinkage Boolean Indicates whether the local linkage feature is used.
name String The rule name.
newLocalScene Boolean Indicates whether the local linkage feature is managed with an app.
stickyOnTop Boolean Indicates whether the scene is displayed on the homepage.

Sample request

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

commonApi.alarmApi
  .getDevAlarmList(TYSdk.devInfo.devId)
  .then(response => {
    console.log(response);
    console.log(JSON.stringify(response));
  })
  .catch();

Sample response

{
     "auditStatus": 1,
     "boundForPanel": false,
     "boundForWiFiPanel": false,
     "enabled": true,
     "i18nData": {"name": { "en": "", "zh": "" }, "content": { "en": "", "zh": "" }},
     "id": "35ix",
     "iotAutoAlarm": false,
     "isLogicRule": false,
     "localLinkage": false,
     "name": "Motion Alert",
     "newLocalScene": false,
     "stickyOnTop": false
  }

Enable or disable alerts from devices

Name

setAlarmSwitch

Description

Enable or disable alerts from devices.

Request parameter

Parameter Data type Description Required
devId String The device ID. Yes
disabled Boolean Whether to disable alerts. No
ruleIds String The string of rule IDs. Yes

Return parameter

Parameter Data type Description
response Boolean Whether alerts from devices are enabled or disabled successfully.

Sample request

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

commonApi.alarmApi
  .setAlarmSwitch({
    devId: 'vdevo159297901023732',
    disabled: true, // When all alerts are enabled, the value is false.
    ruleIds: '3TIXnerlNHeJAugm,8skS74SGlVkwSdbD', // When all alerts are enabled, the field is empty.
  })
  .then(response => {
    console.log(response);
    console.log(JSON.stringify(response));
  })
  .catch();

Sample response

true