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
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
//
//  TuyaSmartSceneManager.h
//  TuyaSmartSceneKit
//
//  Copyright (c) 2014-2021 Tuya Inc. (https://developer.tuya.com)
 
#import <TuyaSmartDeviceKit/TuyaSmartDeviceKit.h>
#import "TuyaSmartCityModel.h"
#import "TuyaSmartSceneDPModel.h"
#import "TuyaSmartSceneModel.h"
#import "TuyaSmartSceneLogModel.h"
#import "TuyaSmartSceneLogDetailModel.h"
 
@class TuyaSmartSceneManager;
 
@protocol TuyaSmartSceneManagerDelegate<NSObject>
 
@optional
 
/// This method will be called when the state of the scene changed.
///
/// @param manager The  scene manager.
/// @param state The scene state, eg: "disable、"enable".
/// @param sceneId The scene ID.
- (void)sceneManager:(TuyaSmartSceneManager *)manager state:(NSString *)state sceneId:(NSString *)sceneId;
 
@end
 
 
/// @brief TuyaSmartSceneManager provides methods for developers to implement scene functionalities.
@interface TuyaSmartSceneManager : NSObject
 
/// Create a singleton object for TuyaSmartSceneManager
///
/// @return The TuyaSmartSceneManager instance
+ (instancetype)sharedInstance;
 
@property (nonatomic, weak) id<TuyaSmartSceneManagerDelegate> delegate;
 
 
/// Get a list of scenes, including tap-to-run and automation. We can judge tap-to-run and automation scene by the entityType of conditions property in TuyaSmartSceneModel, The scene is tap-to-run when the entityType equal AutoTypeManual, otherwise it's automation.
///
/// @see For more information about the entityType,you can see TuyaSmartSceneConditionModel class.
///
/// @param homeId The current home ID.
/// @param success When successfully get the scene list, this block will be called and return TuyaSmartSceneModel list.
/// @param failure When error occurred, this block will be called and return TYFailureError.
- (void)getSceneListWithHomeId:(long long)homeId
                       success:(void(^)(NSArray<TuyaSmartSceneModel *> *list))success
                       failure:(TYFailureError)failure;
 
/// Get a simple list of scenes, including tap-to-run and automation. We can judge tap-to-run and automation scene by the entityType of conditions property in TuyaSmartSceneModel, The scene is tap-to-run when the entityType equal AutoTypeManual, otherwise it's automation.
///
/// @note The different between the simple scene list and scene list is less json data returned by the server.
///
/// @param homeId The current home ID.
/// @param success When successfully get the scene list, this block will be called and return TuyaSmartSceneModel list.
/// @param failure When error occurred, this block will be called and return TYFailureError.
- (void)getSimpleSceneListWithHomeId:(long long)homeId
                       success:(void(^)(NSArray<TuyaSmartSceneModel *> *list))success
                       failure:(TYFailureError)failure;
 
 
/// Get scene detail information according to the specify homeId and sceneId.
///
/// @param homeId The home ID.
/// @param sceneId The scene ID.
/// @param success When successfully get scene detail, this block will be called and return TuyaSmartSceneModel object.
/// @param failure When error occurred, this block will be called and return TYFailureError.
- (void)getSceneDetailWithHomeId:(long long)homeId
                         sceneId:(NSString *)sceneId
                         success:(void(^)(TuyaSmartSceneModel *scene))success
                         failure:(TYFailureError)failure;
 
 
/// Get recommend scene list with the specify homeId.
///
/// @param homeId The home ID.
/// @param success When success, return TuyaSmartSceneModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getRecommendedSceneListWithHomeId:(long long)homeId
                       success:(void(^)(NSArray<TuyaSmartSceneModel *> *list))success
                       failure:(TYFailureError)failure;
 
/// Get collection scene list with the specify homeId.
///
/// @param homeId The home ID.
/// @param success When success, return TuyaSmartSceneModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getCollectionSceneListWithHomeId:(long long)homeId
                                 success:(TYSuccessList)success
                                 failure:(TYFailureError)failure;
 
/// Get all condition list for automation conditions with the specify temperature scale type、speed unit and homeId.
///
/// @param fahrenheit If YES, indicate the temperature unit is Fahrenheit, otherwise Celsius.
/// @param speedUnit The speed unit description.
/// @param homeId The current home ID.
/// @param success When success, return  map object, including envConditions and devConditions object.
/// @param failure When error occurred, return TYFailureError.
- (void)getAllConditionListWithFahrenheit:(BOOL)fahrenheit
                            windSpeedUnit:(NSString *)speedUnit
                                   homeId:(long long)homeId
                                  success:(void(^)(NSDictionary *dict))success
                                  failure:(TYFailureError)failure;
 
/// Get action device list in the scene with specify the current home id.
///
/// @param homeId The current home ID.
/// @param success When success, return TuyaSmartDeviceModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getActionDeviceListWithHomeId:(long long)homeId
                              success:(void(^)(NSArray<TuyaSmartDeviceModel *> *list))success
                              failure:(TYFailureError)failure;
 
/// Get action device list in the current room with the specify room id.
///
/// @param roomId The room ID.
///
/// @retrun The TuyaSmartDeviceModel list, the more information you can see TuyaSmartDeviceModel class.
- (NSArray<TuyaSmartDeviceModel *> *)getActionDeviceListWithRoomId:(long long)roomId;
 
 
/// Get condition device list in the scene with specify the current home id
///
/// @param homeId The home ID.
/// @param success When success, return TuyaSmartDeviceModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getConditionDeviceListWithHomeId:(long long)homeId
                                 success:(void(^)(NSArray<TuyaSmartDeviceModel *> *list))success
                                 failure:(TYFailureError)failure;
 
/// Get condition device list for the current room in the scene with specify room id.
///
/// @param roomId The room ID.
///
/// @return The TuyaSmartDeviceModel list, the more information you can see TuyaSmartDeviceModel class.
- (NSArray<TuyaSmartDeviceModel *> *)getConditionDeviceListWithRoomId:(long long)roomId;
 
/// Get device list for recognize face condition type with specify current home id.
///
/// @param homeId The home ID.
/// @param success When success, return TuyaSmartDeviceModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getFaceDeviceListWithHomeId:(long long)homeId success:(void(^)(NSArray<TuyaSmartDeviceModel *> *list))success failure:(TYFailureError)failure;
 
/// Get device list for the member lock condition type with specify current home id.
///
/// @param homeId The home ID.
/// @param success When success, return TuyaSmartDeviceModel list for member lock condition.
/// @param failure When error occurred, return TYFailureError.
- (void)getLockDeviceListWithHomeId:(long long)homeId success:(void(^)(NSArray<TuyaSmartDeviceModel *> *list))success failure:(TYFailureError)failure;
 
/// Get group list for action in the scene with specify the current room id.
///
/// @param roomId The room ID.
///
/// @return The TuyaSmartGroupModel list for action in the scene, more information you can see TuyaSmartGroupModel class.
- (NSArray<TuyaSmartGroupModel *> *)getActionGroupListWithRoomId:(long long)roomId;
 
/// Get all device list and group list for action in the scene with specify the current home id.
///
/// @param homeId The home ID.
/// @param success When success, return map object, including deviceList、groupList and extendsDictionary object.
/// @param failure When error occurred, return TYFailureError.
- (void)getActionGroupListAndDeviceListWithHomeId:(long long)homeId success:(void(^)(NSDictionary *dict))success failure:(TYFailureError)failure;
 
/// Get device data point list for action in the scene with specify the device id.
///
/// @param devId The device ID.
/// @param success When success, return TuyaSmartSceneDPModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getActionDeviceDPListWithDevId:(NSString *)devId
                               success:(void(^)(NSArray<TuyaSmartSceneDPModel *> *list))success
                               failure:(TYFailureError)failure;
 
/// Get device dp list for condition in the scene with specify the device id.
///
/// @param devId The device ID.
/// @param success When success, return TuyaSmartSceneDPModel list. The TuyaSmartSceneDPModel object describes the datapoint data of the device.
/// @param failure When error occurred, return TYFailureError.
- (void)getCondicationDeviceDPListWithDevId:(NSString *)devId
                                    success:(void(^)(NSArray<TuyaSmartSceneDPModel *> *list))success
                                    failure:(TYFailureError)failure;
 
 
/// Get group datapoint list for action in the scene with specify the current group id.
///
/// @param groupId The group ID.
/// @param success When success, return TuyaSmartSceneDPModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getActionGroupDPListWithGroupId:(NSString *)groupId
                                success:(void(^)(NSArray<TuyaSmartSceneDPModel *> *list))success
                                failure:(TYFailureError)failure;
 
/// Get city list with specify the current country code. If you are out of China, we suggest you use latitude and longitude to get the city information.
///
/// @param countryCode The country code.
/// @param success When success, return TuyaSmartCityModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getCityListWithCountryCode:(NSString *)countryCode
                           success:(void(^)(NSArray<TuyaSmartCityModel *> *list))success
                           failure:(TYFailureError)failure;
 
 
/// Get city detail information with specify the latitude and longitude.
///
/// @param latitude The latitude.
/// @param longitude The longitude.
/// @param success When success, return TuyaSmartCityModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getCityInfoWithLatitude:(NSString *)latitude
                      longitude:(NSString *)longitude
                        success:(void(^)(TuyaSmartCityModel *model))success
                        failure:(TYFailureError)failure;
 
/// Get city detail information with specify the city id.
///
/// @param cityId The city ID.
/// @param success When success, return TuyaSmartCityModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getCityInfoWithCityId:(NSString *)cityId
                      success:(void(^)(TuyaSmartCityModel *model))success
                      failure:(TYFailureError)failure;
 
/// Sort the scene list by the current home id.
///
/// @param homeId The home ID.
/// @param sceneIdList The scene list that to be sorted.
/// @param success When success, return TYSuccessHandler.
/// @param failure When error occurred, return TYFailureError.
- (void)sortSceneWithHomeId:(long long)homeId
                sceneIdList:(NSArray<NSString *> *)sceneIdList
                    success:(TYSuccessHandler)success
                    failure:(TYFailureError)failure;
 
/// Get scene background icons URL list.
///
/// @param success When success, return URL list.
/// @param failure When error occurred, return TYFailureError.
- (void)getSmartSceneBackgroundCoverWithsuccess:(TYSuccessList)success failure:(TYFailureError)failure;
 
/// Get scene custom style resource list, including color、icon and background. The return result map object, contain coverColors、coverIconList and coverPics.
///
/// @param success When success, return map object, including coverColors、coverIconList and coverPics object.
/// @param failure When error occurred, return TYFailureError.
- (void)getSmartSceneCustomStyleListWithSuccess:(TYSuccessDict)success failure:(TYFailureError)failure;
 
/// Get all scene linkage logs, including reminder of successful or failed scene execution、push information and so on.
///
/// @param homeId The home ID.
/// @param startTime The start date.
/// @param endTime The end date.
/// @param size The number of items to be queried.
/// @param lastId The id of the last query item.
/// @param lastRecordTime The record date of the last query item.
/// @param success When success, return TuyaSmartSceneLogModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getSmartSceneLogWithHomeId:(long long)homeId
                         startTime:(long long)startTime
                           endTime:(long long)endTime
                              size:(NSInteger)size
                            lastId:(NSString *)lastId
                    lastRecordTime:(long long)lastRecordTime
                           success:(void(^)(TuyaSmartSceneLogModel *logModel))success
                           failure:(TYFailureError)failure;
 
/// Get scene linkage log list of specified device.
///
/// @param devId The device ID.
/// @param homeId The home ID.
/// @param startTime The start date.
/// @param endTime The end date.
/// @param size The number of items to be queried.
/// @param lastId The id of the last query item.
/// @param lastRecordTime The record date of the last query item.
/// @param success When success, return TuyaSmartSceneLogModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getSmartSceneLogOfDeviceWithDevId:(NSString *)devId
                                   homeId:(long long)homeId
                                startTime:(long long)startTime
                                  endTime:(long long)endTime
                                     size:(NSInteger)size
                                   lastId:(NSString *)lastId
                           lastRecordTime:(long long)lastRecordTime
                                  success:(void(^)(TuyaSmartSceneLogModel *logModel))success
                                  failure:(TYFailureError)failure;
 
/// Get scene log detail information by the homeId, eventId, startTime, endTime, returnType.
///
/// @param homeId The home ID.
/// @param eventId The event ID.
/// @param startTime The start date.
/// @param endTime The end date.
/// @param returnType The return type.
/// @param success When success, return TuyaSmartSceneLogDetailModel list.
/// @param failure When error occurred, return TYFailureError.
- (void)getSmartSceneLogDetailWithHomeId:(long long)homeId
                                 eventId:(NSString *)eventId
                               startTime:(long long)startTime
                                 endTime:(long long)endTime
                              returnType:(long long)returnType
                                 success:(void(^)(NSArray <TuyaSmartSceneLogDetailModel *>*items))success
                                 failure:(TYFailureError)failure;
 
/// Remove all geofence registered in the apple system for automation scene when user logout.
- (void)removeAllGeoFence;
 
/// Cancel the request being executed.
- (void)cancelRequest;
 
#pragma mark - Deprecated
 
/// Get a weather condition list for automation conditions with the specify temperature scale type. If Fahrenheit is YES, indicates that the temperature unit you use is Fahrenheit, otherwise you use is Celsius.
///
/// @param fahrenheit If YES, indicate the temperature unit is Fahrenheit, otherwise Celsius.
/// @param success When success, return TuyaSmartSceneDPModel list.
/// @param failure When error occurred, return TYFailureError.
///
/// @deprecated This method is deprecated, Use getAllConditionListWithFahrenheit:windSpeedUnit:homeId:success:failure instead.
- (void)getConditionListWithFahrenheit:(BOOL)fahrenheit
                               success:(void(^)(NSArray<TuyaSmartSceneDPModel *> *list))success
                               failure:(TYFailureError)failure __deprecated_msg("use -getAllConditionListWithFahrenheit:windSpeedUnit:homeId:success:failure instead");
 
/// Get all condition list for automation conditions, including weather condition、device condition and so on.
///
/// @param fahrenheit If YES, indicate the temperature unit is Fahrenheit, otherwise Celsius.
/// @param homeId The current home ID.
/// @param success When success, return map object, including envConditions and devConditions object.
/// @param failure When error occurred, return TYFailureError.
///
/// @deprecated This method is deprecated, Use getAllConditionListWithFahrenheit:windSpeedUnit:homeId:success:failure instead.
- (void)getAllConditionListWithFahrenheit:(BOOL)fahrenheit
                                   homeId:(long long)homeId
                                  success:(void(^)(NSDictionary *dict))success
                                  failure:(TYFailureError)failure __deprecated_msg("use -getAllConditionListWithFahrenheit:windSpeedUnit:homeId:success:failure instead");
 
@end