1
wei
2021-01-21 62d098cb78296feaa6f786a20748921338db838c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
//
// TuyaSmartHome.h
// TuyaSmartDeviceKit
//
// Copyright (c) 2014-2021 Tuya Inc. (https://developer.tuya.com)
 
#import <Foundation/Foundation.h>
#import "TuyaSmartHomeModel.h"
#import <TuyaSmartDeviceCoreKit/TuyaSmartDeviceCoreKit.h>
#import "TuyaSmartRoomModel.h"
#import "TuyaSmartHomeMemberModel.h"
#import "TuyaSmartHomeAddMemberRequestModel.h"
 
@class TuyaSmartHome;
 
@protocol TuyaSmartHomeDelegate <NSObject>
 
@optional
 
 
/// The delegate of home update information, such as the name, online
///
/// @param home instance
- (void)homeDidUpdateInfo:(TuyaSmartHome *)home;
 
/// The delegate of shared device list update.
///
/// @param home instance
- (void)homeDidUpdateSharedInfo:(TuyaSmartHome *)home;
 
 
/// The delegate when a new room is added.
///
/// @param home instance
/// @param room roomModel
- (void)home:(TuyaSmartHome *)home didAddRoom:(TuyaSmartRoomModel *)room;
 
 
/// The delegate when an existing room is removed.
///
/// @param home     instance
/// @param roomId   roomId
- (void)home:(TuyaSmartHome *)home didRemoveRoom:(long long)roomId;
 
 
/// The delegate of room update information, such as the name.
///
/// @param home     instance
/// @param room     roomModel
- (void)home:(TuyaSmartHome *)home roomInfoUpdate:(TuyaSmartRoomModel *)room;
 
 
/// The delegate of relation update of room, group and device.
///
/// @param home instance
/// @param room roomModel
- (void)home:(TuyaSmartHome *)home roomRelationUpdate:(TuyaSmartRoomModel *)room;
 
 
/// The delegate when a new device is added.
///
/// @param home     instance
/// @param device   deviceModel
- (void)home:(TuyaSmartHome *)home didAddDeivice:(TuyaSmartDeviceModel *)device;
 
 
/// The delegate when an existing device is removed.
///
/// @param home     instance
/// @param devId    devId
- (void)home:(TuyaSmartHome *)home didRemoveDeivice:(NSString *)devId;
 
 
/// The delegate of device update information, such as the name.
///
/// @param home     instance
/// @param device   deviceModel
- (void)home:(TuyaSmartHome *)home deviceInfoUpdate:(TuyaSmartDeviceModel *)device;
 
 
/// The delegate of device dps update.
///
/// @param home     instance
/// @param device   deviceModel
/// @param dps      dps
- (void)home:(TuyaSmartHome *)home device:(TuyaSmartDeviceModel *)device dpsUpdate:(NSDictionary *)dps;
 
 
/// The delegate of warning information update.
///
/// @param home         instance
/// @param device       deviceModel
/// @param warningInfo  warning Info
- (void)home:(TuyaSmartHome *)home device:(TuyaSmartDeviceModel *)device warningInfoUpdate:(NSDictionary *)warningInfo;
 
 
/// The delegate of device firmware upgrade status update.
///
/// @param home                home instance
/// @param device              deviceModel
/// @param upgradeStatusModel  upgradeStatusModel
- (void)home:(TuyaSmartHome *)home device:(TuyaSmartDeviceModel *)device firmwareUpgradeStatusModel:(TuyaSmartFirmwareUpgradeStatusModel *)upgradeStatusModel;
 
 
/// The delegate when a new group is added.
///
/// @param home     instance
///  @param group    groupModel
- (void)home:(TuyaSmartHome *)home didAddGroup:(TuyaSmartGroupModel *)group;
 
 
/// The delegate of group dps update.
///
/// @param home     instance
/// @param group    groupModel
/// @param dps      dps
- (void)home:(TuyaSmartHome *)home group:(TuyaSmartGroupModel *)group dpsUpdate:(NSDictionary *)dps;
 
 
/// The delegate when an existing group is removed.
///
/// @param home     instance
/// @param groupId  groupId
- (void)home:(TuyaSmartHome *)home didRemoveGroup:(NSString *)groupId;
 
 
/// The delegate of group update information, such as the name.
///
/// @param home     instance
/// @param group    groupModel
- (void)home:(TuyaSmartHome *)home groupInfoUpdate:(TuyaSmartGroupModel *)group;
 
#pragma mark - deprecated
 
/// The delegate of relation update of home and room.(deprecated)
///
/// @param home instance
/// @deprecated This method is deprecated, Use TuyaSmartHomeDelegate::home:didAddRoom: or  TuyaSmartHomeDelegate::home:didRemoveRoom: instead.
- (void)homeDidUpdateRoomInfo:(TuyaSmartHome *)home __deprecated_msg("Use -[TuyaSmartHomeDelegate home:didAddRoom:] or [TuyaSmartHomeDelegate home:didRemoveRoom:] instead.");
 
/// The delegate of device firmware upgrade status update.
///
/// @param home           instance
/// @param device         deviceModel
/// @param upgradeStatus  upgrade status
/// @deprecated This method is deprecated, Use TuyaSmartHomeDelegate::home:device:firmwareUpgradeStatusModel: instead.
- (void)home:(TuyaSmartHome *)home device:(TuyaSmartDeviceModel *)device upgradeStatus:(TuyaSmartDeviceUpgradeStatus)upgradeStatus __deprecated_msg("This method is deprecated, Use home:device:firmwareUpgradeStatusModel: instead");
 
@end
 
@interface TuyaSmartHome : NSObject
 
@property (nonatomic, weak) id <TuyaSmartHomeDelegate> delegate;
 
@property (nonatomic, strong, readonly) TuyaSmartHomeModel *homeModel;
 
@property (nonatomic, copy, readonly) NSArray <TuyaSmartRoomModel *> *roomList;
 
@property (nonatomic, copy, readonly) NSArray <TuyaSmartDeviceModel *> *deviceList;
 
@property (nonatomic, copy, readonly) NSArray <TuyaSmartGroupModel *> *groupList;
 
@property (nonatomic, copy, readonly) NSArray <TuyaSmartDeviceModel *> *sharedDeviceList;
 
@property (nonatomic, copy, readonly) NSArray <TuyaSmartGroupModel *>  *sharedGroupList;
 
 
/// Init home.
///
/// @param homeId Home Id
/// @return instance
+ (instancetype)homeWithHomeId:(long long)homeId;
 
- (instancetype)init NS_UNAVAILABLE;
 
#pragma mark - Home
 
/// After initializing the home object, you need to get the details of the family, homeModel, roomList, deviceList, groupList to have the data。
/// @param success Called when the task finishes successfully. TuyaSmartHomeModel will be returned.
/// @param failure If error occurred while adding the task, this block will be called.
- (void)getHomeDetailWithSuccess:(void (^)(TuyaSmartHomeModel *homeModel))success
                         failure:(TYFailureError)failure;
 
 
/// Update home info, API version 2.0.
///
/// @param homeName    Home name
/// @param geoName     City name
/// @param latitude    Lat
/// @param longitude   Lon
/// @param success     Called when the task finishes successfully.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)updateHomeInfoWithName:(NSString *)homeName
                       geoName:(NSString *)geoName
                      latitude:(double)latitude
                     longitude:(double)longitude
                       success:(TYSuccessHandler)success
                       failure:(TYFailureError)failure;
 
 
 
/// Update home info,API version 3.0
///
/// @param homeName    Home name
/// @param geoName     City name
/// @param latitude    Lat
/// @param longitude   Lon
/// @param rooms       Room name array
/// @param overWriteRoom     NSDictionary now only support "overWriteRoom":boolean
/// @param success     Called when the task finishes successfully.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)updateHomeInfoWithName:(NSString *)homeName
                       geoName:(NSString *)geoName
                      latitude:(double)latitude
                     longitude:(double)longitude
                         rooms:(NSArray *)rooms
                 overWriteRoom:(BOOL)overWriteRoom
                       success:(TYSuccessHandler)success
                       failure:(TYFailureError)failure;
 
 
/// Remove a home.
///
/// @param success     Called when the task finishes successfully.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)dismissHomeWithSuccess:(TYSuccessHandler)success
                       failure:(TYFailureError)failure;
 
 
/// Sorting of devices and groups under the entire family.
/// @param orderList order list [@{@"bizId": @"XXX", @"bizType": @"XXX"},@{@"bizId": @"XXX",@"bizType": @"XXX"}], where bizId is the device's devId or group's groupId, device's bizType = @"6" group's bizType = @"5".
/// @param success Called when the task finishes successfully.
/// @param failure If error occurred while adding the task, this block will be called.
- (void)sortDeviceOrGroupWithOrderList:(NSArray<NSDictionary *> *)orderList
                               success:(TYSuccessHandler)success
                               failure:(TYFailureError)failure;
 
 
#pragma mark - Room
 
 
/// Add a new room
///
/// @param name        Room name.
/// @param success     Called when the task finishes successfully.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)addHomeRoomWithName:(NSString *)name
                    success:(TYSuccessHandler)success
                    failure:(TYFailureError)failure;
 
 
/// Remove a room
///
/// @param roomId      Home Id
/// @param success     Called when the task finishes successfully.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)removeHomeRoomWithRoomId:(long long)roomId
                         success:(TYSuccessHandler)success
                         failure:(TYFailureError)failure;
 
 
/// Homes sort
///
/// @param roomList    Homes list
/// @param success     Called when the task finishes successfully.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)sortRoomList:(NSArray <TuyaSmartRoomModel *> *)roomList
             success:(TYSuccessHandler)success
             failure:(TYFailureError)failure;
 
 
#pragma mark - home member
 
/// Get home member list
///
/// @param success     Called when the task finishes successfully. A list of TuyaSmartHomeMemberModel will be returned.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)getHomeMemberListWithSuccess:(void(^)(NSArray <TuyaSmartHomeMemberModel *> *memberList))success
                             failure:(TYFailureError)failure;
 
 
/// Add a home member
///
/// @param requestModel member model
/// @param success      Called when the task finishes successfully.
/// @param failure      If error occurred while adding the task, this block will be called.
- (void)addHomeMemberWithAddMemeberRequestModel:(TuyaSmartHomeAddMemberRequestModel *)requestModel
                                        success:(TYSuccessDict)success
                                        failure:(TYFailureError)failure;
 
/// Accept or reject to shared home
///
/// @param accept       A boolean value indicates whether to accept the invitation.
/// @param success      Called when the task finishes successfully.
/// @param failure      If error occurred while adding the task, this block will be called.
- (void)joinFamilyWithAccept:(BOOL)accept
                     success:(TYSuccessBOOL)success
                     failure:(TYFailureError)failure;
 
 
/// Sync home device list
///
/// @param success Called when the task finishes successfully.
/// @param failure If error occurred while adding the task, this block will be called.
- (void)syncHomeDeviceListWithSuccess:(TYSuccessHandler)success
                              failure:(TYFailureError)failure;
 
@end