Instruction & Status Set

Last Updated on : 2023-07-19 09:12:44download

For smart door locks, except raw type data points (DPs), you need to subscribe to the standard instruction set and status set DPs. This way, you can get the DP content and parameter values, such as DPs for device status reporting, unlocking history, and alert history.

Send instructions to control locks

Standard instructions are used to control the general capabilities of smart locks. For more information, see the standard instruction set and status set of smart locks and the API Get device details in the subsequent sections.

Push notifications of unlocking method enrollment results

For more information, see Enroll in unlocking methods.

Applicable lock types

  • Wi-Fi lock
  • Zigbee lock
  • Bluetooth lock
  • Wi-Fi access control devices
  • Smart video locks
  • Bluetooth accessories
  • Keepalive Wi-Fi locks

Parameters

Parameter name Type Description
bizCode String The code of the specified event type.
devId String The device ID.
uuid String The universally unique identifier (UUID) of the specified device.
bizData Object The status of the specified unlocking method.
ts Long The timestamp.

bizCode

bizCode Description
doorUnlockMethodStatus The status of the specified unlocking method.

bizData

code Data type Description
finish Boolean Indicates whether the unlocking method is enrolled.
operate Integer The operation type. Valid values:
  • 1: Initiate the operation.
  • 2: Cancel the operation.
raised Boolean Indicates whether an unlocking method enrollment is initiated.
totalPeriod Integer The total number of enrollments. The value is pushed separately and only once.
period Integer The number of remaining enrollments allowed for users.
event String The event. Valid values:
  • unlockMethodEntry: Enroll the specified unlocking method.
  • unlockMethodDelete: Delete the specified unlocking method.

Data format

{
    "bizCode":"doorUnlockMethodStatus",
    "bizData":{
        "finish":false,
        "operate":1,
        "raised":true,
        "totalPeriod":2,
        "period":2,
        "event":"unlockMethodEntry"
    },
    "uuid":"xxxx",
    "devId":"xxxx"
}

Get device details

For more information, see the Device Control API.

API description

Query the device details, including the instruction set and the latest status of the specified device.

API endpoint

GET /v1.0/devices/{device_id}

Request parameters

Parameter name Type Parameter type Required Description
device_id String URI Yes The device ID.

Response parameters

Parameter name Type Description
code Integer The response code. See Error codes.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: success.
  • false: failure.
msg String The error message returned if the API call fails. This parameter value is empty if the API call succeeds.
result Object<result> The returned result.

Description of result

Parameter name Type Description
id String The device ID.
name String The device name.
uid String The user ID.
local_key String The secret key.
category String The product category.
product_id String The product ID.
product_name String The product name.
sub Boolean Specifies whether it is a sub-device. Valid values:
  • true: yes
  • false: no
uuid String The UUID of the specified device.
owner_id String The home ID.
online Boolean Indicates whether the device is online.
status Object<status> The status of the specified device feature.
active_time Long The time when the specified device is activated, which is accurate to seconds.
biz_type Long The biztype of the specified application.
icon String The icon of the specified device.
ip String The IP address of the specified device.

Description of status

Parameter name Type Description
code String The code of the specified data point.
value String The value of the specified data point.
type String The type of the specified data point.

Sample request

GET /v1.0/devices/vdevo153490924188132

Sample SDK

TuyaClient client = new TuyaClient(clientId, secret, RegionEnum.CN);
DeviceVo deviceVo = client.getDeviceInfo(DEV_ID);
System.out.println("Get device details: ");
System.out.println(JSONObject.toJSONString(deviceVo));

Sample response

{
    "success": true,
    "result": {
        "active_time": 1589505938,
        "biz_type": 299009,
        "category": "qt",
        "create_time": 1560827137,
        "icon": "smart/icon/15402589135gknz23xajb_0.png",
        "id": "60613135b121cddc294****",
        "ip": "120.198.****.****",
        "local_key": "3a9b50126fe473****",
        "name": "Body fat scale",
        "online": true,
        "owner_id": "1070****",
        "product_id": "g0er6hSKgMqr****",
        "product_name": "Wifi scales_OEM",
        "status": [
            {
                "code": "weight",
                "value": "48900"
            },
            {
                "code": "left_hand_r",
                "value": "0"
            },
            {
                "code": "right_hand_r",
                "value": "0"
            },
            {
                "code": "left_leg_r",
                "value": "0"
            },
            {
                "code": "right_leg_r",
                "value": "0"
            },
            {
                "code": "body_r",
                "value": "653"
            },
            {
                "code": "battery_low",
                "value": "false"
            }
        ],
        "sub": false,
        "time_zone": "+08:00",
        "uid": "ay157896239864843g****",
        "update_time": 1589764585,
        "uuid": "60613135b23cddc294****"
    }
}

Error codes

The following table lists common error codes returned in the API calls. For more error codes, see Global Error Codes.

Error codes Description
500 A system error has occurred while processing your request.
1106 Invalid permission.