Last Updated on : 2022-02-17 06:55:39download
The room management SDK provides a bunch of capabilities. For example, add rooms to a house, sort rooms, add devices to rooms, remove devices from rooms, add groups to rooms, remove groups from rooms, and delete rooms. Users can also control devices or groups by room.
ITuyaCommunityRoom
is used to describe all information about a room. One or more rooms can be created in each house. You can call its API methods to get room details, query a list of devices or groups from a room, and sort the devices and groups displayed in a room.
You can call TuyaCommunitySDK.newRoomInstance()
to get information about a room.
API description
void addHouseRoom(String name, ITuyaCommunityResultCallback<TuyaCommunityRoomBean> callback);
Request parameter
Parameter | Description |
---|---|
name | The name of a room. |
callback | The callback. |
Data types of TuyaCommunityRoomBean
Property | Type | Description |
---|---|---|
roomId | String | The room ID. |
name | String | The name of the room. |
displayOrder | Integer | The sorting order. |
deviceList | List |
A list of devices. |
groupList | List |
A list of groups. |
Example
TuyaCommunitySDK.newHouseInstance(houseId).addHouseRoom("Room name", new ITuyaCommunityResultCallback<TuyaCommunityRoomBean>() {
@Override
public void onSuccess(TuyaCommunityRoomBean bean) {
// do something
}
@Override
public void onFailure(String errorCode, String errorMsg) {
// do something
}
});
API description
void removeHouseRoom(long roomId, ISuccessFailureCallback callback);
Request parameter
Parameter | Description |
---|---|
roomId | The room ID. |
callback | The callback. |
Example
TuyaCommunitySDK.newHouseInstance(houseId).removeHouseRoom(roomId, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
API description
void sortHouseRoom(List<Long> idList, ISuccessFailureCallback callback)
Request parameter
Parameter | Description |
---|---|
idList | The list of room IDs. |
callback | The callback. |
Example
TuyaCommunitySDK.newHouseInstance(houseId).sortHouseRoom(idList, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
API description
Returns room information by device ID.
TuyaCommunityRoomBean getDeviceRoomBean(String devId)
Request parameter
Parameter | Description |
---|---|
devId | The device ID. |
Example
TuyaCommunitySDK.getHouseDataInstance().getDeviceRoomBean("Device ID");
API description
void updateRoomName(String name, ISuccessFailureCallback callback)
Request parameter
Parameter | Description |
---|---|
name | The new room name. |
Example
TuyaCommunitySDK.newRoomInstance(roomId).updateRoomName(name, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
API description
void addDevice(String devId, ISuccessFailureCallback callback)
Request parameter
Parameter | Description |
---|---|
devId | The device ID. |
Example
TuyaCommunitySDK.newRoomInstance(roomId).addDevice(devId, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
API description
void removeDevice(String devId, ISuccessFailureCallback callback)
Request parameter
Parameter | Description |
---|---|
devId | The device ID. |
Example
TuyaCommunitySDK.newRoomInstance(roomId).removeDevice(devId, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
API description
void addGroup(long groupId, ISuccessFailureCallback callback)
Request parameter
Parameter | Description |
---|---|
groupId | The group ID. |
Example
TuyaCommunitySDK.newRoomInstance(roomId).addGroup(groupId, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
API description
void removeGroup(Long groupId, ISuccessFailureCallback resultCallback)
Request parameter
Parameter | Description |
---|---|
groupId | The group ID. |
Example
TuyaCommunitySDK.newRoomInstance(roomId).removeGroup(groupId, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
API description
Transfers device groups in to or out of a room in bulk.
This API method can be called to sort devices in a room. Perform the following steps:
CommunityDeviceAndGroupInRoomBean
.getHouseDetail()
in House Management to get TuyaCommunityHouseBean
that includes the list of all devices.batchModifyRoomRelation
.displayOrder
field in DeviceBean
.void batchModifyRoomRelation(List<CommunityDeviceAndGroupInRoomBean> list, ISuccessFailureCallback callback)
Request parameter
Parameter | Description |
---|---|
list | The group or device. |
Data format of CommunityDeviceAndGroupInRoomBean
Parameter | Parameter type | Description |
---|---|---|
id | String | The ID of the device or group. |
type | int | The type. Valid values:6 : device5 : group |
Example
TuyaCommunitySDK.newRoomInstance(roomId).batchModifyRoomRelation(list, new ISuccessFailureCallback() {
@Override
public void onSuccess() {
// do something
}
@Override
public void onFailure(String code, String error) {
// do something
}
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback