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
//
//  TuyaSmartScene.h
//  TuyaSmartSceneKit
//
//  Copyright (c) 2014-2021 Tuya Inc. (https://developer.tuya.com)
 
#import <TuyaSmartUtil/TuyaSmartUtil.h>
#import "TuyaSmartSceneModel.h"
#import "TuyaSmartSceneActionModel.h"
#import "TuyaSmartSceneConditionModel.h"
 
/// @brief TuyaSmartScene is used to add, edit delete and execute scenes. 
@interface TuyaSmartScene : NSObject
 
/// Class method for initialize TuyaSmartScene by TuyaSmartSceneModel.
///
/// @param sceneModel scene model.
/// @return instance of TuyaSmartScene.
+ (instancetype)sceneWithSceneModel:(TuyaSmartSceneModel *)sceneModel;
 
/// Instance method for initialize TuyaSmartScene by TuyaSmartSceneModel.
///
/// @param sceneModel scene model.
/// @return instance of TuyaSmartScene.
- (instancetype)initWithSceneModel:(TuyaSmartSceneModel *)sceneModel;
 
/// Don't initialize an instance with init method.
///
/// @return    This method will return an unavailable instance.
- (instancetype)init NS_UNAVAILABLE;
 
/// Add a scene by all param
///
/// @param name               The scene name.
/// @param homeId            The home id.
/// @param background        The background image url.
/// @param showFirstPage      Show the scene in index page or not.
/// @param preConditionList       preconditions, like valid time period.
/// @param conditionList      Condition list.
/// @param actionList         Action list.
/// @param matchType          Match all conditions/any condition will execute the automation.
/// @param success            When success return TuyaSmartSceneModel.
/// @param failure            When failure return TYFailureError.
+ (void)addNewSceneWithName:(NSString *)name
                     homeId:(long long)homeId
                 background:(NSString *)background
              showFirstPage:(BOOL)showFirstPage
           preConditionList:(NSArray<TuyaSmartScenePreConditionModel*> *)preConditionList
              conditionList:(NSArray<TuyaSmartSceneConditionModel*> *)conditionList
                 actionList:(NSArray<TuyaSmartSceneActionModel*> *)actionList
                  matchType:(TuyaSmartConditionMatchType)matchType
                    success:(void (^)(TuyaSmartSceneModel *sceneModel))success
                    failure:(TYFailureError)failure;
 
/// Add a new scene.Use a sceneModel with complete information of a scene.
///
/// @param sceneModel     TuyaSmartSceneModel
/// @param homeId              The home id.
/// @param success            When success return TuyaSmartSceneModel.
/// @param failure            When failure return TYFailureError.
+ (void)addNewSceneWithSceneModel:(TuyaSmartSceneModel *)sceneModel
                           homeId:(long long)homeId
                          success:(void (^)(TuyaSmartSceneModel *sceneModel))success
                          failure:(TYFailureError)failure;
 
/// Edit a existed scene with all param
///
/// @param name               The scene name.
/// @param background        The background image url.
/// @param showFirstPage      Show the scene in index page or not.
/// @param preConditionList       preconditions, like valid time period.
/// @param conditionList      Condition list.
/// @param actionList         Action list.
/// @param matchType          Match all conditions/any condition will execute the automation.
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)modifySceneWithName:(NSString *)name
                 background:(NSString *)background
              showFirstPage:(BOOL)showFirstPage
           preConditionList:(NSArray<TuyaSmartScenePreConditionModel*> *)preConditionList
              conditionList:(NSArray<TuyaSmartSceneConditionModel*> *)conditionList
                 actionList:(NSArray<TuyaSmartSceneActionModel*> *)actionList
                  matchType:(TuyaSmartConditionMatchType)matchType
                    success:(TYSuccessHandler)success
                    failure:(TYFailureError)failure;
 
/// Edit a existed scene.Use a sceneModel with complete information of a scene.
///
/// @param sceneModel     TuyaSmartSceneModel
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)modifySceneWithSceneModel:(TuyaSmartSceneModel *)sceneModel
                          success:(TYSuccessHandler)success
                          failure:(TYFailureError)failure;
 
/// Delete a existed scene.
///
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)deleteSceneWithSuccess:(TYSuccessHandler)success
                       failure:(TYFailureError)failure;
 
/// Execute a scene.
///
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)executeSceneWithSuccess:(TYSuccessHandler)success
                        failure:(TYFailureError)failure;
 
/// Disable an automation, which will not executed automatically.
///
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)disableSceneWithSuccess:(TYSuccessHandler)success
                        failure:(TYFailureError)failure;
 
/// Enable an automation, which will be executed while the conditions are matched.
///
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)enableSceneWithSuccess:(TYSuccessHandler)success
                       failure:(TYFailureError)failure;
 
/// Cancel the request being executed.
- (void)cancelRequest;
 
#pragma mark - Recommend scene
 
/// Execute a recommended scene.
///
/// @param homeId              The home id.
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)triggerRecommendSceneWithHomeId:(long long)homeId success:(TYSuccessHandler)success failure:(TYFailureError)failure;
 
/// Delete a recommended scene.
///
/// @param homeId              The home id.
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)removeRecommendSceneWithHomeId:(long long)homeId success:(TYSuccessHandler)success failure:(TYFailureError)failure;
 
/// Save a recommended scene, this scene can be modified by user. this scene will become a normal scene after save successfully, and the recommended scene will not show anymore.
///
/// @param homeId              The home id.
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
- (void)saveRecommendSceneWithHomeId:(long long)homeId success:(void (^)(TuyaSmartSceneModel *sceneModel))success failure:(TYFailureError)failure;
 
#pragma mark - Deprecated
 
/// Add a scene by all param, (deprecated).
///
/// @param name               The scene name.
/// @param homeId            The home id.
/// @param background        The background image url.
/// @param showFirstPage      Show the scene in index page or not.
/// @param conditionList      Condition list.
/// @param actionList         Action list.
/// @param matchType          Match all conditions/any condition will execute the automation.
/// @param success            When success return TuyaSmartSceneModel.
/// @param failure            When failure return TYFailureError.
///
/// @deprecated This method is deprecated, Use -[TuyaSmartScene addNewSceneWithName:homeId:background:showFirstPage:preConditionList:conditionList:actionList:matchType:success:failure:] instead
+ (void)addNewSceneWithName:(NSString *)name
                     homeId:(long long)homeId
                 background:(NSString *)background
              showFirstPage:(BOOL)showFirstPage
              conditionList:(NSArray<TuyaSmartSceneConditionModel*> *)conditionList
                 actionList:(NSArray<TuyaSmartSceneActionModel*> *)actionList
                  matchType:(TuyaSmartConditionMatchType)matchType
                    success:(void (^)(TuyaSmartSceneModel *sceneModel))success
                    failure:(TYFailureError)failure __deprecated_msg("This method is deprecated, Use -[TuyaSmartScene addNewSceneWithName:homeId:background:showFirstPage:preConditionList:conditionList:actionList:matchType:success:failure:] instead");
 
/// Edit an existed scene with all param, (deprecated).
///
/// @param name               The scene name.
/// @param background        The background image url.
/// @param showFirstPage      Show the scene in index page or not.
/// @param conditionList      Condition list.
/// @param actionList         Action list.
/// @param matchType          Match all conditions/any condition will execute the automation.
/// @param success            When success return TYSuccessHandler.
/// @param failure            When failure return TYFailureError.
///
/// @deprecated This method is deprecated, Use -[TuyaSmartScene modifySceneWithName:background:showFirstPage:preConditionList:conditionList:actionList:matchType:success:failure:] instead.
- (void)modifySceneWithName:(NSString *)name
                 background:(NSString *)background
              showFirstPage:(BOOL)showFirstPage
              conditionList:(NSArray<TuyaSmartSceneConditionModel*> *)conditionList
                 actionList:(NSArray<TuyaSmartSceneActionModel*> *)actionList
                  matchType:(TuyaSmartConditionMatchType)matchType
                    success:(TYSuccessHandler)success
                    failure:(TYFailureError)failure __deprecated_msg("This method is deprecated, Use -[TuyaSmartScene modifySceneWithName:background:showFirstPage:preConditionList:conditionList:actionList:matchType:success:failure:] instead");
@end