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
//
// TuyaSmartHomeManager.h
// TuyaSmartDeviceKit
//
// Copyright (c) 2014-2021 Tuya Inc. (https://developer.tuya.com)
 
#import <Foundation/Foundation.h>
 
#import "TuyaSmartHomeModel.h"
 
@class TuyaSmartHomeManager;
 
 
@protocol TuyaSmartHomeManagerDelegate <NSObject>
 
@optional
 
/// The delegate when a new home is added.
///
/// @param manager  instance
/// @param home     homeModel
- (void)homeManager:(TuyaSmartHomeManager *)manager didAddHome:(TuyaSmartHomeModel *)home;
 
/// The delegate when an existing home is removed.
///
/// @param manager  instance
/// @param homeId   homeId
- (void)homeManager:(TuyaSmartHomeManager *)manager didRemoveHome:(long long)homeId;
 
/// MQTT service connection success callback.
- (void)serviceConnectedSuccess;
 
 
@end
 
@interface TuyaSmartHomeManager : NSObject
 
@property (nonatomic, weak) id <TuyaSmartHomeManagerDelegate> delegate;
 
@property (nonatomic, copy, readonly) NSArray <TuyaSmartHomeModel *> *homes;
 
 
/// Get homes list. If you want to get home details, need to initialize a home, call getHomeDetailWithSuccess: failure:
///
/// @param success Called when the task finishes successfully. A list of TuyaSmartHomeModel will be returned.
/// @param failure If error occurred while adding the task, this block will be called.
- (void)getHomeListWithSuccess:(void(^)(NSArray <TuyaSmartHomeModel *> *homes))success
                       failure:(TYFailureError)failure;
 
 
/// Adds a new home
///
/// @param homeName    Home name
/// @param geoName     City name
/// @param rooms       Rooms list
/// @param latitude    Latitude
/// @param longitude   Longitude
/// @param success     Called when the task finishes successfully.
/// @param failure     If error occurred while adding the task, this block will be called.
- (void)addHomeWithName:(NSString *)homeName
                geoName:(NSString *)geoName
                  rooms:(NSArray <NSString *>*)rooms
               latitude:(double)latitude
              longitude:(double)longitude
                success:(TYSuccessLongLong)success
                failure:(TYFailureError)failure;
 
 
/// Home sort
///
/// @param homeList    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)sortHomeList:(NSArray <TuyaSmartHomeModel *> *)homeList
             success:(TYSuccessHandler)success
             failure:(TYFailureError)failure;
 
#pragma mark - deprecated
 
/// Accept or reject to shared home
///
/// @param homeId       Home Id
/// @param isAccept     Whether to accept the invitation
/// @param success      Success block
/// @param failure      Failure block
/// @deprecated This method is deprecated, Use TuyaSmartHome::joinFamilyWithAccept:success:failure: instead.
- (void)joinFamilyWithHomeId:(long long)homeId
                      action:(BOOL)isAccept
                     success:(TYSuccessBOOL)success
                     failure:(TYFailureError)failure __deprecated_msg("This method is deprecated, Use -[TuyaSmartHome - (void)joinFamilyWithAccept:success:failure:] instead");
 
@end