Last Updated on : 2023-05-22 06:38:25download
API description
void addRoom(String name, ITuyaRoomResultCallback callback)
Parameters
Parameter | Description |
---|---|
name | The name of a room. |
callback | The callback. |
Example
TuyaHomeSdk.newHomeInstance(10000).addRoom("Room name", new ITuyaRoomResultCallback() {
@Override
public void onSuccess(RoomBean bean) {
// do something
}
@Override
public void onError(String errorCode, String errorMsg) {
// do something
}
});
API description
void removeRoom(long roomId, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
roomId | The room ID. |
callback | The callback. |
Example
TuyaHomeSdk.newHomeInstance(10000).removeRoom(roomId, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void sortRoom(List<Long> idList, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
idList | The list of room IDs |
callback | The callback. |
Example
TuyaHomeSdk.newHomeInstance(10000).sortRoom(idList, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
RoomBean getDeviceRoomBean(String devId)
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
Example
TuyaHomeSdk.getDataInstance().getDeviceRoomBean("Device ID");
API description
void updateRoom(String name, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
name | The new room name. |
Example
TuyaHomeSdk.newRoomInstance(10000).updateRoom(name, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
This API method is newly added to SDK v3.19.
Query image URL
Returns the URL of the background image of a room after this image is uploaded.
RoomBean roomBean = homeBean.rooms.get(index);
String roomBgImageurl = roomBean.iconUrl;
API description
void updateIcon(File file, IResultCallback callback);
Parameters
Parameter | Description |
---|---|
file | The image of the room. |
callback | The callback. |
Example
TuyaHomeSdk.newRoomInstance(10000).updateIcon(file, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void addDevice(String devId, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
Example
TuyaHomeSdk.newRoomInstance(10000).addDevice(devId, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void removeDevice(String devId, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
devId | The device ID. |
Example
TuyaHomeSdk.newRoomInstance(10000).removeDevice(devId, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void addGroup(long groupId, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
groupId | The group ID. |
Example
TuyaHomeSdk.newRoomInstance(10000).addGroup(groupId, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
API description
void removeGroup(Long groupId, IResultCallback resultCallback)
Parameters
Parameter | Description |
---|---|
groupId | The group ID. |
Example
TuyaHomeSdk.newRoomInstance(10000).removeGroup(groupId, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
Transfers device groups in to or out of a room in bulk.
This API method can be called to sort devices in a room. Recommended procedure:
DeviceAndGroupInRoomBean
.HomeBean
that includes the list of all devices.HomeBean
by device ID to get the list of devices that are returned by moveDevGroupListFromRoom
.displayOrder
field in DeviceBean
.API description
void moveDevGroupListFromRoom(List<DeviceAndGroupInRoomBean> list, IResultCallback callback)
Parameters
Parameter | Description |
---|---|
List | The list of groups or devices. |
Data format of DeviceAndGroupInRoomBean
Parameter | Type | Description |
---|---|---|
id | String | The ID of the device or group. |
type | int | The type of data. Valid values:
|
Example
TuyaHomeSdk.newRoomInstance(10000).moveDevGroupListFromRoom(list, new IResultCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onError(String code, String error) {
// do something
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback