更新时间:2022-02-17 06:45:25下载pdf
TuyaCommunityRoom
用于描述单个房间的信息,在一个房屋下会有多个房间。TuyaCommunityRoom
提供的功能包括房间信息、设备列表、群组列表、设备和群组顺序等API。
房间相关信息由TuyaCommunityRoomModel
提供。
通过房屋 ID 和房间 ID 可以创建一个TuyaCommunityRoom
实例。
接口说明
+ (instancetype)roomWithRoomId:(long long)roomId
houseId:(long long)houseId;
- (instancetype)initWithRoomId:(long long)roomId
houseId:(long long)houseId;
参数说明
参数 | 说明 |
---|---|
roomId | 房间 ID |
houseId | 房屋 ID |
示例代码
long long roomId;
long long houseId;
TuyaCommunityRoom *room = [TuyaCommunityRoom roomWithRoomId:roomId houseId:houseId];
接口说明
- (void)addHouseRoomWithName:(NSString *)name
success:(void(^)(TuyaCommunityRoomModel *result))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
name | 房间名 |
success | 成功回调 |
failure | 失败回调 |
示例代码
long long houseId;
TuyaCommunityHouse *house = [TuyaCommunityHouse houseWithHouseId:houseId];
[house addHouseRoomWithName:@"xxx" success:^(TuyaCommunityRoomModel * _Nonnull result) {
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
接口说明
- (void)removeHouseRoomWithRoomId:(long long)roomId
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
roomId | 房间 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
long long houseId;
TuyaCommunityHouse *house = [TuyaCommunityHouse houseWithHouseId:houseId];
[house removeHouseRoomWithRoomId:0 success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
接口说明
- (void)sortHouseRoomWithRoomList:(NSArray<TuyaCommunityRoomModel *>*)roomList
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
roomList | 房间列表 |
success | 成功回调 |
failure | 失败回调 |
示例代码
long long houseId;
TuyaCommunityHouse *house = [TuyaCommunityHouse houseWithHouseId:houseId];
[house sortHouseRoomWithRoomList:@[] success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
接口说明
- (void)updateRoomNameWithRoomName:(NSString *)roomName
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
roomName | 房间名称 |
success | 成功回调 |
failure | 失败回调 |
示例代码
TuyaCommunityRoom *room = [TuyaCommunityRoom roomWithRoomId:roomId houseId:houseId];
[room updateRoomNameWithRoomName:@"xxx" success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
通过设备对应的设备 ID 给单个房间添加设备,设备模型为 TuyaSmartDeviceModel
。
接口说明
- (void)addDeviceWithDeviceId:(NSString *)deviceId
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
deviceId | 设备 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
long long houseId;
TuyaCommunityRoomModel *roomModel;
TuyaSmartDeviceModel *deviceModel;
TuyaCommunityHouse *house = [TuyaCommunityHouse houseWithHouseId:houseId];
if (house.deviceList.count && house.houseModel.rooms.count) {
// 模拟获取设备模型
deviceModel = house.deviceList.firstObject;
// 模拟获取房间模型
roomModel = house.houseModel.rooms.firstObject;
}
TuyaCommunityRoom *room = [TuyaCommunityRoom roomWithRoomId:roomModel.roomId houseId:houseId];
[room addDeviceWithDeviceId:deviceModel.devId success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
移除某个房间下的某个设备。
- (void)removeDeviceWithDeviceId:(NSString *)deviceId
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
deviceId | 设备 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
long long houseId;
TuyaCommunityRoomModel *roomModel;
TuyaSmartDeviceModel *deviceModel;
TuyaCommunityHouse *house = [TuyaCommunityHouse houseWithHouseId:houseId];
if (house.roomList.count) roomModel = house.roomList.firstObject;
TuyaCommunityRoom *room = [TuyaCommunityRoom roomWithRoomId:roomModel.roomId houseId:houseId];
if (room.deviceList.count) deviceModel = room.deviceList.firstObject;
[room removeDeviceWithDeviceId:deviceModel.devId success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
通过群组对应的群组 ID 给单个房间添加群组,设备模型为TuyaSmartGroupModel
。
- (void)addGroupWithGroupId:(NSString *)groupId
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
groupId | 群组 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
long long houseId;
TuyaCommunityRoomModel *roomModel;
TuyaSmartGroupModel *groupModel;
TuyaCommunityHouse *house = [TuyaCommunityHouse houseWithHouseId:houseId];
// 模拟房间
if (house.roomList.count) roomModel = house.roomList.firstObject;
// 模拟群组
if (house.groupList.count) groupModel = house.groupList.firstObject;
TuyaCommunityRoom *room = [TuyaCommunityRoom roomWithRoomId:roomModel.roomId houseId:houseId];
// 添加群组
[room addGroupWithGroupId:groupModel.groupId success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
移除某个房间下的某个群组。
- (void)removeGroupWithGroupId:(NSString *)groupId
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
groupId | 群组 ID |
success | 成功回调 |
failure | 失败回调 |
示例代码
long long houseId;
TuyaCommunityRoomModel *roomModel;
TuyaSmartGroupModel *groupModel;
TuyaCommunityHouse *house = [TuyaCommunityHouse houseWithHouseId:houseId];
// 模拟房间
if (house.roomList.count) roomModel = house.roomList.firstObject;
TuyaCommunityRoom *room = [TuyaCommunityRoom roomWithRoomId:roomModel.roomId houseId:houseId];
// 模拟群组
if (room.groupList.count) groupModel = room.groupList.firstObject;
// 移除群组
[room removeGroupWithGroupId:groupModel.groupId success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
此方法可以用来批量地将设备和群组移入或者移出房间。
- (void)batchModifyRoomRelationWithDeviceGroupList:(NSArray<NSString *>*)deviceGroupList
success:(void(^)(void))success
failure:(void(^)(NSError *error))failure;
参数说明
参数 | 说明 |
---|---|
deviceGroupList | 设备和群组 ID 数组 |
success | 成功回调 |
failure | 失败回调 |
示例代码
TuyaCommunityRoom *room;
[room batchModifyRoomRelationWithDeviceGroupList:@[@"xxx", @"xxx"] success:^{
// success handler
} failure:^(NSError * _Nonnull error) {
// failure handler
}];
TuyaCommunityRoom
用于描述单个房间的信息,在一个房屋下会有多个房间。
属性 | 类型 | 说明 |
---|---|---|
roomModel | TuyaCommunityRoomModel | 房间信息 |
deviceList | NSArray<TuyaSmartDeviceModel> | 设备列表 |
groupList | NSArray<TuyaSmartGroupModel> | 群组列表 |
TuyaCommunityRoom
提供的功能包括房间信息、设备列表、群组列表、设备和群组顺序等API。
属性 | 类型 | 说明 |
---|---|---|
roomId | NSString | 房间 ID |
name | NSString | 房间名 |
displayOrder | NSInteger | 排列顺序,用于排序 |
该内容对您有帮助吗?
是意见反馈该内容对您有帮助吗?
是意见反馈