Tuya iOS Smart Life App SDK 5.15.0
ThingSmartDpParser.h
Go to the documentation of this file.
1//
2// ThingSmartDpParser.h
3// ThingSmartDeviceCoreKit
4//
5// Copyright (c) 2014-2024.
6//
7
8#import <Foundation/Foundation.h>
9
10NS_ASSUME_NONNULL_BEGIN
11
12@class ThingSmartDp;
14
15@protocol ThingSmartDpDataSourceProtocol <NSObject>
16@property (nonatomic, strong, readonly) NSDictionary<NSString *, id> *dps; // Mapping of dpId to current dpValue
17@property (nonatomic, strong, readonly) NSArray<ThingSmartSchemaModel *> *schemaArray; //All DP schema
18@property (nonatomic, assign, readonly) BOOL switchDpsValue; // Current value of switch DP
19@property (nonatomic, strong, readonly) NSArray<NSNumber *> * switchDps; // A dpId list of switch DP
20@property (nonatomic, strong, readonly) NSArray<NSNumber *> * displayDps;// A dpId list of display DP
21@property (nonatomic, strong, readonly) NSArray<NSNumber *> * quickOpDps;// A dpId list of quick operate DP
22@property (nonatomic, strong, readonly) NSDictionary<NSString *, NSString *> *dpName; // Mapping of dpId to title
23@property (nonatomic, strong, readonly) NSDictionary<NSString *, NSString *> * displayMsgs;// Mapping of dp code to show content
24@property (nonatomic, strong, readonly) NSString * schemaExt; // A json string of shcema additional information
25@property (nonatomic, strong, readonly) ThingSmartStandSchemaModel *standSchemaModel;
26@end
27
29@interface ThingSmartDpParser : NSObject
32+ (instancetype)createWithTargetInfo:(id)targetInfo;
34@property (nonatomic, strong, readonly) id<ThingSmartDpDataSourceProtocol> dpDataSource;
35
37@property (nonatomic, strong, readonly) NSArray<__kindof ThingSmartDp *> * displayDp;
39@property (nonatomic, strong, readonly) NSArray<__kindof ThingSmartDp *> * operableDp;
41@property (nonatomic, strong, readonly) NSArray<__kindof ThingSmartDp *> * allDp;
43@property (nonatomic, strong, nullable, readonly) ThingSmartSwitchDp * switchDp;
44@property (nonatomic, strong, nullable, readonly) NSArray<NSString *> * standardDpCodes;
45
46- (nullable __kindof ThingSmartDp *)smartDpWithDpId:(NSInteger)dpId quickOp:(BOOL)quickOp;
47+ (NSArray<__kindof ThingSmartDp *> *)smartDpListWithDpDataSource:(id<ThingSmartDpDataSourceProtocol>)dpDataSource
48 dps:(NSArray<NSNumber *> *)dps
49 quickOp:(BOOL)quickOp;
50@end
51
52typedef NS_ENUM(NSInteger, ThingSmartDpType) {
53 ThingSmartDpType_Bool,
54 ThingSmartDpType_Enum,
55 ThingSmartDpType_Num,
56 ThingSmartDpType_Light,
57 ThingSmartDpType_String,
58};
59
60@interface ThingSmartDpValueDisplay : NSObject
61@property (nonatomic, strong, readonly) ThingSmartDp * smartDp;
62@property (nonatomic, strong, readonly) id dpValue;
63
64@property (nonatomic, strong, nullable, readonly) NSString * displayValue;
65@property (nonatomic, strong, nullable, readonly) NSString * displayUnit;
66
67- (NSString *)dpValueDisplayStr;
68@end
69
70@interface ThingSmartDp : NSObject
76+ (nullable __kindof ThingSmartDp *)smartDpWithTargetInfo:(id)targetInfo
77 dpId:(NSInteger)dpId
78 quickOp:(BOOL)quickOp;
84+ (NSArray<__kindof ThingSmartDp *> *)smartDpListWithTargetInfo:(id)targetInfo
85 dps:(NSArray<NSNumber *> *)dps
86 quickOp:(BOOL)quickOp;
87
88
90@property (nonatomic, strong, readonly) id<ThingSmartDpDataSourceProtocol> dpDataSource;
91
93@property (nonatomic, strong, readonly) ThingSmartSchemaModel * schemaModel;
94@property (nonatomic, assign, readonly) ThingSmartDpType smartDpType;
95@property (nonatomic, strong, readonly) NSString * standardDpCode;//标准code
96@property (nonatomic, strong, readonly) NSString * strategyCode;
97
98@property (nonatomic, assign, readonly) NSInteger dpId;
99@property (nonatomic, strong, readonly) NSString * dpType;
100@property (nonatomic, strong, readonly) NSString * name;
101@property (nonatomic, strong, readonly) NSString * iconname;
102@property (nonatomic, strong, readonly) NSString * unit;
103
104@property (nonatomic, strong, readonly) id curDpValue;
105
107@property (nonatomic, strong, readonly) NSString * titleStatus;
108
110@property (nonatomic, strong, readonly) NSString * valueStatus;
111
112- (nullable NSDictionary *)publishCommands:(id)newDpValue;
113
116- (NSString *)valueStatusWithDpValue:(id)dpValue;
117
118
119- (ThingSmartDpValueDisplay *)valueDisplayWithDpValue:(id)dpValue;
120@end
121
123@property (nonatomic, assign, readonly) NSUInteger lightHueMin;
124@property (nonatomic, assign, readonly) NSUInteger lightHueMax;
125@property (nonatomic, assign, readonly) NSUInteger currentLightHue;
126- (NSString *)lightHueDsecLocalizedKey:(NSUInteger)lightHue;
127
128@property (nonatomic, assign, readonly) NSUInteger lightSaturationMin;
129@property (nonatomic, assign, readonly) NSUInteger lightSaturationMax;
130@property (nonatomic, assign, readonly) NSUInteger currentLightSaturatio;
131
132@property (nonatomic, assign, readonly) NSUInteger lightValueMin;
133@property (nonatomic, assign, readonly) NSUInteger lightValueMax;
134@property (nonatomic, assign, readonly) NSUInteger currentLightValue;
135
136@property (nonatomic, assign, readonly) BOOL v2Type;
137
138- (nullable NSDictionary *)publishCommandsWithLightHue:(NSUInteger)lightHue
139 lightSaturation:(NSUInteger)lightSaturation
140 lightValue:(NSUInteger)lightValue;
141@end
142
143
144@interface ThingSmartSwitchDp : NSObject
145@property (nonatomic, assign, readonly) BOOL switchStatus;
146
148@property (nonatomic, assign, readonly) BOOL writeOnlySwitch;
149
150- (nullable NSDictionary *)publishSwitchCommands:(BOOL)open;
151@end
152NS_ASSUME_NONNULL_END
NSString * valueStatus
Get 'curDpValue' display content under the current DP.
NSString * iconname
NSString * standardDpCode
NSString * titleStatus
Get title display content under the current DP.
ThingSmartSchemaModel * schemaModel
SchemaModel of current DP.
NSString * dpType
ThingSmartDpType smartDpType
id< ThingSmartDpDataSourceProtocol > dpDataSource
DataSource.
NSString * strategyCode
Device or Group DP Schema Parser Tool.
ThingSmartSwitchDp * switchDp
Switch DP of the current device (group)
NSArray< __kindof ThingSmartDp * > * allDp
Get all DP of the current device (group), quickOp property is 'NO'.
NSArray< __kindof ThingSmartDp * > * operableDp
Operate DP of the current device (group), quickOp property is 'YES'.
NSArray< __kindof ThingSmartDp * > * displayDp
Display DP of the current device (group) , quickOp property is 'NO'.
id< ThingSmartDpDataSourceProtocol > dpDataSource
DataSource.
NSArray< NSString * > * standardDpCodes
NSString * dpValueDisplayStr()
typedef NS_ENUM(NSInteger, ThingSmartDpType)
NSString * name
The name in the invitation remarks.
NSDictionary< NSString *, NSString * > * dpName
NSDictionary< NSString *, NSString * > * displayMsgs
NSDictionary< NSString *, id > * dps
NSArray< NSNumber * > * quickOpDps
ThingSmartStandSchemaModel * standSchemaModel
NSArray< ThingSmartSchemaModel * > * schemaArray
NSArray< NSNumber * > * displayDps
NSArray< NSNumber * > * switchDps