Shortcut Parser for Android

Last Updated on : 2023-09-19 02:33:11download

ShortcutParser serves as an extension SDK of Tuya IoT App SDK. It can be used to parse shortcut features of the device data model (DeviceBean) and the group data model (GroupBean). This accelerates the process to develop device or group shortcut features for your business.

Background information

Data points (DPs) are used to describe the features of Powered by Tuya devices. DP data is parsed, rendered, and operated on the clients to manage device status. You can develop device panels that support specified DPs based on Reactive Native. Then, users can control smart devices with the device panels.

To implement shortcut features, Tuya provides flags to display and control DPs without entering device panels. In common cases, the most important DPs are flagged and displayed on the list of devices. This way, users can touch the shortcut flags to easily get device status or control devices without the need to enter device panels.


The SDK depends on TuyaHomeKitSDK 3.11.0 or later. Add the following dependency to the module file build.gradle:

implementation ''

Add the following maven source to repositories of the file build.gradle in the root directory:

maven {
  url ""

API operations

The core of the SDK provides the capabilities to parse shortcut DPs for devices and groups. The following table describes the API operations that are encapsulated in the SDK.

Class Description
IShortcutParserManager Manages the shortcut parsers.
IClientParser Parses DP data on clients.
IDpControl Provides basic control with DPs.
IBoolDpControl Provides shortcut control with Boolean DPs.
IEnumDpControl Provides shortcut control with enumeration DPs.
INumDpControl Provides shortcut control with value DPs.
IDpStatus Provides shortcut control with status DPs.

The following figure shows the architecture of these API operations.

Shortcut Parser for Android


API description

public interface IShortcutParserManager {
	* Returns device parsing data.
	* @param deviceBean
	* @return
	IClientParser getDeviceParseData(DeviceBean deviceBean);

	* Returns group parsing data.
	* @param groupBean
	* @return
	IClientParser getGroupParseData(GroupBean groupBean, ProductBean productBean);


// Initializes the SDK.
IShortcutParserManager mIShortcutParserManager = new ShortcutParserManager();

Shortcut control

Shortcut control can be used with readable and writable DPs to implement device functionality. You can configure the DPs for shortcut control on the Tuya IoT Platform. For more information, see Enable Toggle.

Based on these configurations, DeviceBean or GroupBean from the SDK contains the specified shortcut control DPs. This allows you to use the SDK to develop shortcut control features.

Shortcut control DPs are classified into device switch DPs and generic shortcut DPs.

Shortcut switches

Shortcut switches are the switch DPs for smart devices. A DP that is flagged as a device shortcut switch DP indicates the power switch of the device.

The API operation IClientParserBean of IShortcutParserManager includes the following shortcut switch data:

  • Shortcut switch status

    	// Shortcut switch not configured.
    	// Shortcut switch enabled.
    	// Shortcut switch disabled.
    	private int status;
    	SHORTCUT_SWITCH_STATUS(int status) {
    		this.status = status;
    	public int getStatus() {
    		return status;
  • Get the shortcut switch status

    API description

    * Returns the shortcut switch status.
    * @return An enumeration value of status.
    SHORTCUT_SWITCH_STATUS getSwitchStatus();


    IClientParser mClientParser = mShortcutParserManager.updateDeviceParseData(mDev);
  • Get shortcut switch operations

    * Returns parsing data of shortcut switch DPs.
    * @return Parses shortcut switch DPs.
    IBoolDpControl getSwitchDpParseBean();

Generic shortcut DPs

You can get a list of shortcut DPs by using IClientParserBean.

 * Returns a list of shortcut DPs.
 * @return
List<IDpControl> getDpShortcutControlList();

The returned shortcut DPs support enumeration, value, and Boolean types. Each API operation provides data that can be parsed. For more information, see the annotations of each API operation.

Data updates

In most cases, the data of dps is updated after device control. You can call the data update operation of IClientParserBean to get the latest status.

API description

 * Parses updates of device or group status.
 * @param dps The values of device or group DPs.
 * @param dpName The names of device or group DPs.
void update(Map<String, Object> dps, Map<String, String> dpName);


// Returns the latest cached data from the SDK.
mDev = TuyaHomeSdk.getDataInstance().getDeviceBean(devId);
// Updates the DPs and DP names.

Shortcut status

The DPs with the shortcut flags can be used for sensor devices to indicate read-only status of the devices. This feature is not supported on the Tuya IoT Platform when you configure a product. You can submit a ticket to request technical support.

IClientParserBean provides the API operation to return a list of device or group shortcut DP status.

API description

 * Returns a list of device or group shortcut DP status.
 * @return
List<IDpStatus> getDpShortcutStatusList();

For more information about the capabilities to parse the shortcut DP status, see the annotations of the API operation.