Room Tag Management

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

Overview

Room tags are a new feature that enables users to tag rooms. FamilyManagerCoreKit.getRoomTagUseCase() is used for room tag management to implement operations on a home.

The room tag information is described through RoomGroupBean, which has the following properties.

Property Type Description
roomGroupId Long The ID of the room tag.
roomGroupName String The name of the room tag.
rooms List The room associated with the tag.
index Int The order of the room tags.

The properties used by RoomBean are described below:

Property Type Description
roomId Long The room ID.
roomName String The name of the room.
devSize Int The number of devices in a room, including groups and individual devices. If the Home SDK has no cache, the count is 0.
index Int The order of rooms.

Get the list of room tags

Get the list of room tag information, including only the ID, name, and order of the room groups, without the room list.

API description

fun getRoomTagList(
   familyId: Long,
   callback: IResponse<ArrayList<RoomGroupBean>>
 )

Parameters

Parameter Description
familyId The home ID.
callback The result callback.

Example

FamilyManagerCoreKit.getRoomTagUseCase().getRoomTagList(familyId, object :IResponse<ArrayList<RoomGroupBean>>{
            override fun onSuccess(result: ArrayList<RoomGroupBean>?) {
               //successful
            }

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

            }
        })

Get tags for room groups

Get the list of tags for room groups, including the room list. Untagged rooms are automatically assigned to the default group with a group ID of 0.

API description

fun getAllRoomLists(
        familyId: Long,
        callback: IResponse<ArrayList<RoomGroupBean>>
    )

Parameters

Parameter Description
familyId The home ID.
callback The result callback. Untagged rooms are automatically assigned to the default group with a group ID of 0.

Example

FamilyManagerCoreKit.getRoomTagUseCase().getAllRoomLists(familyId, object :IResponse<ArrayList<RoomGroupBean>>{
            override fun onSuccess(result:ArrayList<RoomGroupBean>?) {
               //successful
            }

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

            }
        })

Create a room tag

Create a room tag, which is sorted last by default.

API description

fun addRoomTag(
        familyId: Long,
        name: String,
        callback: IResponse<String>
    )

Parameters

Parameter Description
familyId The home ID.
name The name of the room tag.
callback The result callback.

Example

FamilyManagerCoreKit.getRoomTagUseCase().addRoomTag(familyId,"1st floor" object :IResponse<String>{
            override fun onSuccess(result:String?) {
               //successful
            }

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

            }
        })

Dismiss a room group by tag

Dismiss a room group by tag, without deleting the rooms.

API description

 fun removeRoomTag(
        roomTagId: Long,
        callback: IResponse<Boolean>
    )

Parameters

Parameter Description
roomTagId The tag ID for the room group.
callback The result callback.

Example

FamilyManagerCoreKit.getRoomTagUseCase().removeRoomTag(rtagId,object :IResponse<Boolean>{
            override fun onSuccess(result:Boolean?) {
               //successful
            }

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

            }
        })

Rename a room tag

API description

 fun updateRoomTagName(
        roomTagId: Long,
        name: String,
        callback: IResponse<String>
    )

Parameters

Parameter Description
roomTagId The tag ID for the room group.
name The new tag name.
callback The result callback.

Example

FamilyManagerCoreKit.getRoomTagUseCase().updateRoomTagName(rtagId,"1st floor corridor", object :IResponse<Boolean>{
            override fun onSuccess(result:Boolean?) {
               //successful
            }

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

            }
        })

Sort room tags

API description

fun updateRoomTagSortInList(
        gid: Long,
        roomTagIds: List<String>,
        callback: IResponse<String>
    )

Parameters

Parameter Description
gid The home ID.
roomTagIds The collection of room tag IDs.
callback The result callback.

Example

val list = listof("tagid1","tagid2","tagid3")
FamilyManagerCoreKit.getRoomTagUseCase().updateRoomTagSortInList(gid,rtagId,list,object :IResponse<String>{
            override fun onSuccess(result:String?) {
               //successful
            }

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

            }
        })

Modify tags for room groups

Modify the tag information for a room group. You can sort tags, add or remove rooms from a group, and sort the room list.

API description

fun managerAndSortRoomInTagsList(
        gid: Long,
        roomTagIds: List<String>,
        roomGroupIds: Map<String, List<String>>,
        callback: IResponse<String>
    )

Parameters

Parameter Description
gid The home ID.
roomTagIds The collection of room tag IDs.
roomGroupIds The list of rooms in the room group, with 0 for the default group.
callback The result callback.

Example

val list = listof("tagid1","tagid2","tagid3")
val roomGroupIds = hashMapOf(Pair("0", listOf("roomid1","roomid2","roomid3")),Pair("tagid1", listOf("roomid12","roomid13","roomid14")))

FamilyManagerCoreKit.getRoomTagUseCase().managerAndSortRoomInTagsList(gid,list,roomGroupIds,object :IResponse<String>{
            override fun onSuccess(result:String?) {
               //successful
            }

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

            }
        })

Add room and inherit tag from associated room group

Add a room and assign it the tag from the associated room group. The method allows for multiple tags for one room.

API description

 fun addRoomWithTag(
        gid: Long,
        name: String,
        roomTagIds: List<String>,
        callback: IResponse<String>
    )

Parameters

Parameter Description
gid The home ID.
name The name of the room.
roomTagIds The collection of room tag IDs.
callback The result callback.

Example

FamilyManagerCoreKit.getRoomTagUseCase().addRoomWithTag(gid,"Balcony",listof("tagid"),object :IResponse<String>{
            override fun onSuccess(result:String?) {
               //successful
            }

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

            }
        })