English
English
简体中文
Contact Us
Register
Log In
layoutIndex

IPC Control

Last Updated on : 2022-03-03 08:20:13download

Data points (DPs) are configured to implement smart device control between the app and cloud. Standard DPs apply to interactions between devices and the app.

Import the module

The component com.tuya.smart:tuyasmart-ipc-devicecontrol has been deprecated. You can use your own logic to implement capabilities as mentioned in Device Control and Device Management.

implementation 'com.tuya.smart:tuyasmart-ipc-devicecontrol:3.17.0r139'

Get an object

ITuyaCameraDevice provides the capabilities to transmit device information. For example, send control commands and query DP data of the current device.

API description

Initializes the device control class by device ID.

ITuyaCameraDevice getCameraDeviceInstance(String devId)

Example

ITuyaCameraDevice tuyaCameraDevice = TuyaCameraDeviceControlSDK.getCameraDeviceInstance(devId);

Query supported features

API description

Checks whether a specific DP is supported by a device. If the DP is not supported, the API requests to send and query DP data will fail. The request parameter is the DP ID of the device.

boolean isSupportCameraDps(String dpCodeID);

Example

boolean isSupportDpBasicFlip = mTuyaCameraDevice.isSupportCameraDps(DpBasicFlip.ID);

Query Value type of data

API description

Returns device DPs from cached data. This API method applies to the Value type of data.

int queryIntegerCurrentCameraDps(String dpCodeID);

Example

int dpvalue = mTuyaCameraDevice.queryIntegerCurrentCameraDps(DpSDStatus.ID);

Query Object type of data

API description

Returns device DPs from cached data. This API method applies to the Enum, Value, Boolean, String types of data.

Object queryObjectCameraDps(String dpCodeID);

Example

Object dpValue = mTuyaCameraDevice.queryObjectCameraDps(DpBasicFlip.ID);

If queryObjectCameraDps is used for the query, data types must be distinguished.

Query String and Enum types of data

API description

Returns device DPs from cached data. This API method applies to the String and Enum types of data.

 String queryStringCurrentCameraDps(String dpCodeID);

Example

String mode = mTuyaCameraDevice.queryStringCurrentCameraDps(DpMotionSensitivity.ID);

Query Boolean type of data

API description

Returns device DPs from cached data. This API method applies to the Boolean type of data.

boolean queryBooleanCameraDps(String dpCodeID);

Example

boolean dpValue = mTuyaCameraDevice.queryBooleanCameraDps(DpBasicFlip.ID);

Send DPs

API description

Sends DPs over a local area network (LAN) or from the cloud.

void publishCameraDps(String dpCode, Object value);

Example

// If the return value is `Boolean`, the callback can be executed to set the Boolean type of data. If the return value is `Enum/String`, the callback can be executed to set the String type of data. If the return value is `Value`, the callback can be executed to set the Integer type of data.
mTuyaCameraDevice.registorTuyaCameraDeviceControlCallback(DpBasicFlip.ID, new ITuyaCameraDeviceControlCallback<Boolean>() {
  @Override
  public void onSuccess(String s, DpNotifyModel.ACTION action, DpNotifyModel.SUB_ACTION sub_action, Boolean o) {
    showPublishTxt.setText("LAN/Cloud query result: " + o);
  }

  @Override
  public void onFailure(String s, DpNotifyModel.ACTION action, DpNotifyModel.SUB_ACTION sub_action, String s1, String s2) {

  }
});
mTuyaCameraDevice.publishCameraDps(DpBasicFlip.ID, true);

Trigger a data callback

The class ITuyaCameraDeviceControlCallback provides the callback for device information and for device responses after commands are sent from the app.

  • If the return value is Boolean, the callback can be executed to set the Boolean type of data.
  • If the return value is Enum, the callback can be executed to set the String type of data.
  • If the return value is Value, the callback can be executed to set the Integer type of data.
public interface ITuyaCameraDeviceControlCallback<E> {
    // The success callback.
    void onSuccess(String devId, ACTION action, SUB_ACTION subAction, E o);

    // The failure callback.
    void onFailure(String devId, ACTION action, SUB_ACTION subAction, String errorCode, String errorString);
}

Supported data types

Data type Description
Boolean Boolean
String String and Enum
Value Value

DP constants

Basic features

DP DP ID Data type Value Description Function definition
DpBasicIndicator.ID 101 Boolean
  • true: turns an indicator on in the normal state.
  • false: turns an indicator off in the normal state.
Status indicator Turns an indicator on or off in the normal state to avoid light pollution at night. In the case of pairing, troubleshooting, or other conditions, the indicator must show the device status as expected.
DpBasicFlip.ID 103 Boolean
  • true: flip
  • false: normal
Video flipping Enables or disables vertical flipping of video images. It is used to adjust video orientations when the device is inversely installed.
DpBasicOSD.ID 104 Boolean
  • true: enables on-screen display.
  • false: disables on-screen display.
Time watermark Specifies whether to enable or disable time watermarks on live video screens.
DpBasicPrivate.ID 105 Boolean
  • true: enables the private mode.
  • false: disables the private mode.
Private mode Enables or disables the private mode. Audio and videos are not collected in sleep mode. In this case, live video streaming and video recording and storage cannot be performed on the device.
DpBasicNightvision.ID 108 Enum
  • 0: automatic
  • 1: off
  • 2: on
Infrared night vision Sets infrared night vision to the on, off, or automatic state.

Motion detection alerts

DP DP ID Data type Value Description Function definition
DpPIRSwitch.ID 152 Enum
  • 0: disabled
  • 1: low sensitivity
  • 2: medium sensitivity
  • 3: high sensitivity
Passive infrared (PIR) switch and sensitivity Sets infrared night vision to the off, low sensitivity, medium sensitivity, or high sensitivity state.
DpMotionSwitch.ID 134 Boolean
  • true: enables motion detection alerts.
  • false: disables motion detection alerts.
Switch of motion detection alerts Enables or disables motion detection alerts. In the enabled state, the device will report all motion events detected to the server.
DpMotionSensitivity.ID 106 Enum
  • 0: low-level sensitivity
  • 1: medium-level sensitivity
  • 2: high-level sensitivity
Sensitivity of motion detection Sets the sensitivity of motion detection.

Sound detection alerts

DP DP ID Data type Value Description Function definition
DpDecibelSwitch.ID 139 Boolean
  • true: enables sound detection alerts.
  • false: disables sound detection alerts.
Switch of sound detection alerts Enables or disables sound detection alerts. In the enabled state, the device will report all sound events detected to the server.
DpDecibelSensitivity.ID 140 Enum
  • 0: low-level sensitivity
  • 1: high-level sensitivity
Sensitivity of sound detection Sets the sensitivity of sound detection.

SD card management

DP DP ID Data type Value Description Function definition
DpSDStatus.ID 110 Value
  • 1: normal
  • 2: exceptional, for example, such as damaged SD card or incorrect format
  • 3: insufficient space
  • 4: being formatted
  • 5: no SD card found
SD card status Reports the current SD card status to the cloud, for example, normal, exceptional, and insufficient space.
DpSDStorage.ID 109 String String Status of SD card capacity Reports the current capacity status of the memory card, including total capacity, used capacity, and remaining capacity.
DpSDFormat.ID 111 Boolean Boolean Storage card formatting Sends a command to format an SD card and reports the progress and other status details of the ongoing formatting task.
DpSDFormatStatus.ID 117 Value A positive value from 0 to 100 indicates the progress of formatting. Progress and other status details of SD card formatting A positive value from 0 to 100 indicates the progress of formatting. Formatting is finished when the value is 100. Error codes:
  • -2000: SD card being formatted
  • -2001: error in formatting an SD card
DpSDRecordSwitch.ID 150 Boolean
  • true: enables local recording.
  • false: disables local recording.
Switch of local recording Enables or disables SD card-stored video recording on a mobile phone. If this feature is disabled, video records will not be saved to the SD card.
DpRecordMode.ID 151 Enum
  • 1: triggers SD card-stored video recording after motion is detected.
  • 2: continuous recording.
Local recording mode selection After the local recording feature is enabled, users can choose between the recording modes event-triggered and continuous recording.

PTZ control

DP DP ID Data type Value Description Function definition
DpPTZControl.ID 119 Enum
  • 0: upward
  • 2: rightward
  • 4: downward
  • 6: leftward
PTZ direction control Starts PTZ control and determines the rotation direction.
DpPTZStop.ID 116 Boolean Boolean, used to stop PTZ control without a request parameter Stop PTZ control Stops PTZ control without a request parameter.

Low power devices

DP DP ID Data type Value Description Function definition
DpWirelessElectricity.ID 145 Value Device battery level, an integer from 0 to 100 Battery and device status Reports the current battery level of a device regularly or when the battery level is changed, and meanwhile, reports the current sleep or wake-up state to the cloud.
DpWirelessLowpower.ID 147 Value Value Low battery alert threshold Users can set a threshold on the app. An alert is reported in the case of dp145≤dp147.
DpWirelessBatterylock.ID 153 Boolean
  • true: lock
  • false: unlock
battery lock Locks a battery or releases the battery lock.
DpWirelessPowermode.ID 146 Enum
  • 0: powered by batteries
  • 1: connected to mains power
Power supply mode Reports the current power supply mode regularly or when the power supply status is changed.

Enum types of DPs

The value range of String and Enum types of DPs. The IPC SDK defines String and Enum types of DP constants, as listed in the following table.

DP Enum value
DpMotionSensitivity MotionSensitivityMode
DpBasicNightvision NightStatusMode
DpPIRSwitch PIRMode
DpRecordMode RecordMode
DpDecibelSensitivity SoundSensitivityMode