Room Information Management

Last Updated on : 2023-04-13 09:35:14download

Add a room

API description

void addRoom(String name, IThingRoomResultCallback callback)

Parameters

Parameter Description
name The name of a room.
callback The callback.

Example

ThingHomeSdk.newHomeInstance(10000).addRoom("Room name", new IThingRoomResultCallback() {
		@Override
		public void onSuccess(RoomBean bean) {
			// do something
		}
		@Override
		public void onError(String errorCode, String errorMsg) {
			// do something
		}
	});

Delete a room

API description

void removeRoom(long roomId, IResultCallback callback)

Parameters

Parameter Description
roomId The room ID.
callback The callback.

Example

ThingHomeSdk.newHomeInstance(10000).removeRoom(roomId, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Sort a list of rooms

API description

void sortRoom(List<Long> idList, IResultCallback callback)

Parameters

Parameter Description
idList The list of room IDs
callback The callback.

Example

ThingHomeSdk.newHomeInstance(10000).sortRoom(idList, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Query room information by device ID

API description

RoomBean getDeviceRoomBean(String devId)

Parameters

Parameter Description
devId The device ID.

Example

ThingHomeSdk.getDataInstance().getDeviceRoomBean("Device ID");

Rename a room

API description

void updateRoom(String name, IResultCallback callback)

Parameters

Parameter Description
name The new room name.

Example

ThingHomeSdk.newRoomInstance(10000).updateRoom(name, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Customize a room background image

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

ThingHomeSdk.newRoomInstance(10000).updateIcon(file, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Add a device to a room

API description

void addDevice(String devId, IResultCallback callback)

Parameters

Parameter Description
devId The device ID.

Example

ThingHomeSdk.newRoomInstance(10000).addDevice(devId, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Remove a device from a room

API description

void removeDevice(String devId, IResultCallback callback)

Parameters

Parameter Description
devId The device ID.

Example

ThingHomeSdk.newRoomInstance(10000).removeDevice(devId, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Add a group to a room

API description

void addGroup(long groupId, IResultCallback callback)

Parameters

Parameter Description
groupId The group ID.

Example

ThingHomeSdk.newRoomInstance(10000).addGroup(groupId, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Remove a group from a room

API description

void removeGroup(Long groupId, IResultCallback resultCallback)

Parameters

Parameter Description
groupId The group ID.

Example

ThingHomeSdk.newRoomInstance(10000).removeGroup(groupId, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});

Modify mappings between rooms and device groups in bulk

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:

  1. Set the target device set object DeviceAndGroupInRoomBean.
  2. Call the API method getHomeDetail in Home Information Management to get HomeBean that includes the list of all devices.
  3. Search the device list in HomeBean by device ID to get the list of devices that are returned by moveDevGroupListFromRoom.
  4. Sort the devices by the 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:
  • 6: device
  • 5: group

Example

ThingHomeSdk.newRoomInstance(10000).moveDevGroupListFromRoom(list, new IResultCallback() {
		@Override
		public void onSuccess() {
			// do something
		}
		@Override
		public void onError(String code, String error) {
			// do something
		}
	});