该内容对您有帮助吗?
是否更新时间:2022-01-07 07:03:31下载pdf
本文介绍获取设备信息、修改设备信息、移除设备、获取设备支持的指令集、下发指令等接口的使用。
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
DeviceBean
说明
参数名 | 类型 | 说明 |
---|---|---|
id | String | 设备 ID |
uuid | String | 设备 uuid |
category | String | 产品品类 |
name | String | 设备名称 |
productId | String | 产品 ID |
productName | String | 产品名称 |
localKey | String | 密钥 |
sub | Boolean | 是否为子设备 |
assetId | String | 资产 ID |
ip | String | 设备 IP |
timeZone | String | 时区 |
activeTime | Long | 激活时间 |
updateTime | Long | 更新时间 |
createTime | Long | 初次配网时间 |
online | Boolean | 是否在线 |
icon | String | 设备图标(前缀:https://images.tuyacn.com/) |
代码示例
TYDeviceManager.getDeviceBusiness().queryDeviceInfo(deviceId, new ResultListener<DeviceBean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(DeviceBean deviceBean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceIds | Array<String> | true | 设备 ID 列表,限制最多20个 |
DeviceListBean
说明
参数名 | 类型 | 说明 |
---|---|---|
hasMore | Boolean | 是否有下一页 |
total | Long | 符合条件的数据总条数 |
list | List<DeviceBean> | 数据列表 |
代码示例
TYDeviceManager.getDeviceBusiness().queryDevicesInfo(deviceIds, new ResultListener<DeviceListBean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(DeviceListBean deviceListBean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
deviceName | String | true | 设备名称 |
返回示例
参数名 | 类型 | 说明 |
---|---|---|
result | Boolean | true:请求成功 |
代码示例
TYDeviceManager.getDeviceBusiness().modifyDeviceName(deviceId, "name", new ResultListener<Boolean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(Boolean result) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
返回示例
参数名 | 类型 | 说明 |
---|---|---|
result | Boolean | true:请求成功 |
代码示例
TYDeviceManager.getDeviceBusiness().removeDevice(deviceId, new ResultListener<Boolean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(Boolean aBoolean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceIds | Array<String> | true | 设备 ID 列表,限制最多20个 |
返回示例
参数名 | 类型 | 说明 |
---|---|---|
result | Boolean | true:请求成功 |
代码示例
String[] deviceIds = {deviceId};
TYDeviceManager.getDeviceBusiness().removeDevices(deviceIds, new ResultListener<Boolean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(Boolean aBoolean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
返回示例
参数名 | 类型 | 说明 |
---|---|---|
result | Boolean | true:请求成功 |
代码示例
TYDeviceManager.getDeviceBusiness().resetDevice(deviceId, new ResultListener<Boolean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(Boolean aBoolean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 网关设备 ID |
SubDeviceBean
说明
参数名 | 类型 | 说明 |
---|---|---|
id | String | 设备 ID |
name | String | 设备名称 |
online | Boolean | 设备在线状态 |
activeTime | String | 激活时间 |
updateTime | String | 设备状态更新时间 |
productId | String | 设备所属产品 ID |
category | String | 品类 |
nodeId | String | 子设备 nodeId |
assetId | String | 资产 ID |
icon | String | 设备图标 |
代码示例
TYDeviceManager.getDeviceBusiness().querySubDevices(deviceId, new ResultListener<List<SubDeviceBean>>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(List<SubDeviceBean> subDeviceBeans) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
DeviceStatusBean
说明
参数名 | 类型 | 说明 |
---|---|---|
code | String | 状态码 |
value | Object | 状态值 |
代码示例
TYDeviceManager.getDeviceBusiness().queryDeviceStatus(deviceId, new ResultListener<List<DeviceStatusBean>>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(List<DeviceStatusBean> deviceStatusBeans) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceIds | Array<String> | true | 设备 ID 列表,限制最多20个 |
DevicesStatusBean
说明
参数名 | 类型 | 说明 |
---|---|---|
id | String | 设备 ID |
status | List<DeviceStatusBean> | 设备状态列表 |
代码示例
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) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
category | String | true | 产品类别(如:dj ) |
DeviceStandardCommandBean
说明
参数名 | 类型 | 说明 |
---|---|---|
category | String | 产品品类 |
functions | StandardCommandBean[] | 指令集 |
StandardCommandBean
说明
参数名 | 类型 | 说明 |
---|---|---|
name | String | 指令名称 |
desc | String | 描述 |
code | String | 指令 |
type | String | 指令类型 |
values | String | 指令入参范围 |
代码示例
String category = "dj";
TYDeviceManager.getDeviceBusiness().queryCommandSetWithCategory(category, new ResultListener<DeviceStandardCommandBean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(DeviceStandardCommandBean deviceStandardCommandBean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
代码示例
TYDeviceManager.getDeviceBusiness().queryCommandSetWithDeviceId(deviceId, new ResultListener<DeviceStandardCommandBean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(DeviceStandardCommandBean deviceStandardCommandBean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
DeviceSpecificationBean
说明
参数名 | 类型 | 说明 |
---|---|---|
category | String | 产品品类 |
functions | List<StandardCommandBean> | 指令集 |
status | List<StandardCommandBean> | 状态集 |
代码示例
TYDeviceManager.getDeviceBusiness().queryDeviceSpecification(deviceId, new ResultListener<DeviceSpecificationBean>() {
@Override
public void onFailure(String errorCode, String errorMsg) {
}
@Override
public void onSuccess(DeviceSpecificationBean deviceSpecificationBean) {
}
});
参数说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
deviceId | String | true | 设备 ID |
commands | List<DeviceStatusBean> | true | 设备控制指令 |
DeviceStatusBean
说明
参数名 | 类型 | 是否必填 | 说明 |
---|---|---|---|
code | String | true | 指令码 |
value | Object | true | 指令值 |
返回示例
参数名 | 类型 | 说明 |
---|---|---|
result | Boolean | true:请求成功 |
代码示例
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) {
}
});
该内容对您有帮助吗?
是否该内容对您有帮助吗?
是否