Locker App Related SDK

Last Updated on : 2021-08-27 11:07:11download

Event method

Monitoring method

import {TYSdk} from "tuya-panel-kit"; const TYEvent = TYSdk.event; /** * @param {String} yourEventName-event name * @param {Function} yourHandler-monitor the callback triggered successfully */ TYEvent.on(yourEventName, yourHandler); // start listening for events TYEvent.off(yourEventName, yourHandler); // cancel listening event

Common event name

deviceDataChange: core event. This event is divided into three categories, distinguished by the type field in the return value:

-dpData: DP point status changes, that is, the device has reported the DP point status.
-devInfo: Notification of device information changes, such as device name changes.
-deviceOnline: Device online status changes.

Description: When componentWillUnmount is enabled, you need to cancel the monitoring event.

Device method

import {TYSdk} from "tuya-panel-kit"; const TYDevice = TYSdk.device;

TYDevice.putDeviceData()

/** * @desc issues the DP point (the core method of interacting with the hardware side) * @param {Object} data-DP point data */ TYDevice.putDeviceData(data);

Native method

import {TYSdk} from "tuya-panel-kit"; const TYNative = TYSdk.event;

TYNative.apiRequest()

/** * @desc request API interface * @param {Object}-request parameters * @param {Function}-success callback * @param {Function}-Failure callback */ TYDevice.apiRequest( { a: apiName, v: apiVersion postData: params, }, d => successHandle(d), e => errorHandle(e));

Add App monitoring members

TYNative.DeviceEventEmitter.addListener('addMember', yourHandler)

Remove App monitoring members

TYNative.DeviceEventEmitter.removeListener('addMember', yourHandler)