Room Device Management

Last Updated on : 2024-08-28 01:53:19download

Overview

Request the devices and scenes in a room and access methods related to scenes. Device and scene data uses RoomInfoBean, which contains the following properties.

Property Type Description
ruleList List The list of scenes in a room.
deviceSortList List The list of devices in a room.

Properties of SceneInRoom:

Property Type Description
ruleId String The scene ID.
ruleName int The scene name.
background String The background color, for example, #ffffff.
icon String The scene icon.

Properties of DeviceOrGroupInRoom:

Property Type Description
bizId String The ID of the device or group.
bizType int Type
  • Device: BizParentTypeEnum.DEVICE
  • Group: BizParentTypeEnum.GROUP
displayOrder int The display order.

Access the method in the Home SDK through PluginManager.service(IThingHomePlugin::class.java).newHomeInstance(homeId).

Get device scene in a room

API description

 void queryRoomDevSceneList(long roomId, IThingResultCallback<RoomInfoBean> callback);

Parameters

Parameter Description
roomId The room ID.
callback The success callback.

Example

    val homePlugin =  PluginManager.service(IThingHomePlugin::class.java)

    homePlugin.newHomeInstance(homeId).queryRoomDevSceneList(id,object :
            IThingResultCallback<RoomInfoBean>{
            override fun onSuccess(result: RoomInfoBean?) {

            }
            override fun onError(errorCode: String?, errorMessage: String?) {

            }
        })

Organize devices or groups by room

Sort the devices or groups in a room, and move a device or group to another room (add and delete a device or group). Pass in the room ID after sorting and the device or group to edit. Make a callback on success.

API description

void moveRoomDevGroupList(long roomId,List<DeviceInRoomBean> devicesInRoom,IFamilyDataCallback<Boolean> callback);

Parameters

Parameter Description
roomId The room ID.
devicesInRoom The list of devices or groups.
callback The callback.

Example

var rooId = 0L //0L...
        var room:TRoomBean? = null//   getRoomList()[0]...
        var devinRoomsList = room?.ids

        devinRoomsList?.sortedBy { it.id } //sort
        devinRoomsList?.removeAt(0)//remove
        //add
        devinRoomsList?.add(DeviceInRoomBean().apply {
            id = "devid"
            type = BizParentTypeEnum.DEVICE.getType()
        })
        devinRoomsList?.add(DeviceInRoomBean().apply {
            id = "groupid"
            type = BizParentTypeEnum.GROUP.getType()
        })
        FamilyManagerCoreKit.getRoomUseCase().moveRoomDevGroupList(rooId, devinRoomsList , object :IFamilyDataCallback<Boolean>{
            override fun onSuccess(result: Boolean?) {

            }

            override fun onError(errorCode: String?, errorMessage: String?) {

            }
        })

Add a device to a room

Add a paired device to a room. Make a callback on success.

API description

void addDeviceInRoom(long roomId,String devId,
IFamilyDataCallback<Boolean> callback) ;

Parameters

Parameter Description
deviceId The ID of the target device.
roomId The room ID.
callback The callback.

Example

FamilyManagerCoreKit.getRoomUseCase().addDeviceInRoom(homeId, devId , object :IFamilyDataCallback<Boolean>{
            override fun onSuccess(result: Boolean?) {

            }

            override fun onError(errorCode: String?, errorMessage: String?) {

            }
   })

Remove a device from a room

Remove a device from a room. This operation does not remove the device from the home. Make a callback on success.

API description

void removeDeviceFromRoom(long roomId,String devId,IFamilyDataCallback<Boolean> callback) ;

Parameters

Parameter Description
devId The ID of the target device.
roomId The room ID.
callback The callback.

Example

FamilyManagerCoreKit.getRoomUseCase().removeDeviceFromRoom(homeId, devId , object :IFamilyDataCallback<Boolean>{
        override fun onSuccess(result: Boolean?) {

        }

        override fun onError(errorCode: String?, errorMessage: String?) {

        }
   })

Add a group to a room

Add a group to a room. Make a callback on success.

API description

void addGroupInRoom(long roomId,long gId,IFamilyDataCallback<Boolean> callback) ;

Parameters

Parameter Description
gId The ID of the target group.
roomId The room ID.
callback The callback.

Example

FamilyManagerCoreKit.getRoomUseCase().addGroupInRoom(homeId, gid , object :IFamilyDataCallback<Boolean>{
        override fun onSuccess(result: Boolean?) {

        }

        override fun onError(errorCode: String?, errorMessage: String?) {

        }
   })

Remove a group from a room

Remove a group from a room. Make a callback on success. This operation does not remove the group from the home.

API description

void removeGroupFromRoom(long roomId, long gId, IFamilyDataCallback<Boolean> callback) ;

Parameters

Parameter Description
gId The ID of the target group.
roomId The room ID.
callback The success callback.

Example

FamilyManagerCoreKit.getRoomUseCase().removeGroupFromRoom(homeId, gId , object :IFamilyDataCallback<Boolean>{
        override fun onSuccess(result: Boolean?) {

        }

        override fun onError(errorCode: String?, errorMessage: String?) {

        }
   })