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

Device Management

Last Updated on : 2022-01-07 07:03:31download

This topic describes the API methods for get device information, modifying device information, removing devices, get the instruction set of the device and send commands to device.

Get the device information

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID

DeviceBean Description

Parameter name Type Description
id String Device ID
uuid String Device UUID
category String Product category
name String Device name
productId String Product ID
productName String Product name
localKey String Secret key
sub Boolean Check whether it is a sub-device
assetId String Asset ID
ip String The IP address of the device
timeZone String The time zone where the device is located
activeTime Long The time when the device is activated
updateTime Long The time when the device is updated
createTime Long The time when the device is paired for the first time
online Boolean Check whether the device is online
icon String Device icon

Code example

TYDeviceManager.getDeviceBusiness().queryDeviceInfo(deviceId, new ResultListener<DeviceBean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(DeviceBean deviceBean) {
                
            }
        });

Get the information about multiple devices

Parameter Description

Parameter name Type Required Description
deviceIds Array<String> true The device IDs. Multiple IDs are separated by a comma (,). Limit up to 20.

DeviceListBean Description

Parameter name Type Description
hasMore Boolean Specify whether there is another page.
total Long Total entries of data that meets the conditions
list List<DeviceBean> Data list

Code example

TYDeviceManager.getDeviceBusiness().queryDevicesInfo(deviceIds, new ResultListener<DeviceListBean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(DeviceListBean deviceListBean) {

            }
        });

Modify device name

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID
deviceName String true Device name

Return example

Parameter name Type Description
result Boolean true: Request successful

Code example

TYDeviceManager.getDeviceBusiness().modifyDeviceName(deviceId, "name", new ResultListener<Boolean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(Boolean result) {

            }
        });

Delete a device

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID

Return example

Parameter name Type Description
result Boolean true: Request successful

Code examplee

TYDeviceManager.getDeviceBusiness().removeDevice(deviceId, new ResultListener<Boolean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(Boolean aBoolean) {

            }
        });

Delete devices in batches

Parameter Description

Parameter name Type Required Description
deviceIds Array<String> true The IDs of the devices to be deleted. Multiple IDs are separated by a comma (,). Limit up to 20.

Return example

Parameter name Type Description
result Boolean true: Request successful

Code example

String[] deviceIds = {deviceId};
TYDeviceManager.getDeviceBusiness().removeDevices(deviceIds, new ResultListener<Boolean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(Boolean aBoolean) {

            }
        });

Restore defaults

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID

Return example

Parameter name Type Description
result Boolean true: Request successful

Code example

TYDeviceManager.getDeviceBusiness().resetDevice(deviceId, new ResultListener<Boolean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(Boolean aBoolean) {

            }
        });

Get the list of sub-devices

Parameter Description

Parameter name Type Required Description
deviceId String true Gateway device ID

SubDeviceBean Description

Parameter name Type Description
id String Device ID
name String Device name
online Boolean Online status of the device
activeTime String The time when the device is activated
updateTime String The time when the device status is updated
productId String Product ID of the device
category String Category
nodeId String The nodeId of the sub-device
assetId String Asset ID
icon String Device icon

Code example

TYDeviceManager.getDeviceBusiness().querySubDevices(deviceId, new ResultListener<List<SubDeviceBean>>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(List<SubDeviceBean> subDeviceBeans) {

            }
        });

Get the status of a single device

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID

DeviceStatusBean Description

Parameter name Type Description
code String Status code
value Object Status value

Code example

TYDeviceManager.getDeviceBusiness().queryDeviceStatus(deviceId, new ResultListener<List<DeviceStatusBean>>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(List<DeviceStatusBean> deviceStatusBeans) {

            }
        });

Get the latest status of multiple devices

Parameter Description

Parameter name Type Required Description
deviceIds Array<String> true The device IDs. Multiple IDs are separated by a comma (,). Limit up to 20.

DevicesStatusBean Description

Parameter name Type Description
id String Device ID
status List<DeviceStatusBean> The list of device status

Code example

String[] deviceIds = {deviceId};
TYDeviceManager.getDeviceBusiness().queryDevicesStatus(deviceIds, new ResultListener<List<DevicesStatusBean>>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(List<DevicesStatusBean> devicesStatusBeans) {

            }
        });

Get the instruction set of the category

Parameter Description

Parameter name Type Required Description
category String true Product category

DeviceStandardCommandBean Description

Parameter name Type Description
category String Product category
functions StandardCommandBean[] Instruction set

StandardCommandBean Description

Parameter name Type Description
name String Instruction name
desc String Description
code String Instruction
type String Instruction type
values String The input parameter range of the instruction

Code example

String category = "dj";
TYDeviceManager.getDeviceBusiness().queryCommandSetWithCategory(category, new ResultListener<DeviceStandardCommandBean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(DeviceStandardCommandBean deviceStandardCommandBean) {

            }
        });

Get the instruction set of the device

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID

Code example

TYDeviceManager.getDeviceBusiness().queryCommandSetWithDeviceId(deviceId, new ResultListener<DeviceStandardCommandBean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(DeviceStandardCommandBean deviceStandardCommandBean) {

            }
        });

Get the specifications and properties of the device

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID

DeviceSpecificationBean Description

Parameter name Type Description
category String Product category
functions List<StandardCommandBean> Instruction set
status List<StandardCommandBean> Status set

Code example

TYDeviceManager.getDeviceBusiness().queryDeviceSpecification(deviceId, new ResultListener<DeviceSpecificationBean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(DeviceSpecificationBean deviceSpecificationBean) {

            }
        });

Send commands

Parameter Description

Parameter name Type Required Description
deviceId String true Device ID
commands List<DeviceStatusBean> true The command to control a device

DeviceStatusBean Description

Parameter name Type Required Description
code String true Command code
value Object true Command value

Code example

Parameter name Type Description
result Boolean true : Request successful

Code example

List<DeviceStatusBean> commands = new ArrayList<>();
DeviceStatusBean deviceStatusBean = new DeviceStatusBean("switch_led", true);
commands.add(deviceStatusBean);

TYDeviceManager.getDeviceBusiness().sendCommands(deviceId, commands, new ResultListener<Boolean>() {
            @Override
            public void onFailure(String errorCode, String errorMsg) {

            }

            @Override
            public void onSuccess(Boolean aBoolean) {

            }
        });