Last Updated on : 2023-03-12 16:48:13download
Lighting Scenario UI BizBundle supports the configurations of all smart lights in the same room. It provides abundant color picker styles and a bunch of scenario libraries. You can integrate the UI BizBundle to easily implement desired smart home lighting scenarios.
The Lighting Scenario UI BizBundle supports the following features:
Add the components of the Lighting Scenario UI BizBundle to the Podfile
and run the command pod update
.
source 'https://github.com/tuya/tuya-pod-specs.git'
source 'https://cdn.cocoapods.org/'
platform :ios, '11.0'
target 'your_target_name' do
# Adds the Lighting Scenario UI BizBundle.
pod 'TuyaSmartLightSceneBizBundle'
end
The Lighting Scenario UI BizBundle relies on the implementation of the protocol TYLightSceneProtocol
to provide services. You can view the TYLightSceneProtocol
file in the TYModuleServices
component.
#import <Foundation/Foundation.h>
NS_ASSUME_NONNULL_BEGIN
@protocol TYLightSceneProtocol <NSObject>
/// Adds a scenario.
- (void)createNewLightScene;
/// Modifies a scenario.
/// @param scene The lighting scenario model.
- (void)editLightScene:(TuyaLightSceneModel *)scene;
/// Runs the scenario.
- (void)executeLightScene;
/// Returns a list of lighting scenarios.
/// @param homeId The home ID.
/// @param success The success callback.
/// @param failure The failure callback.
- (void)getLightSceneListWithHomeId:(long long)homeId success:(void(^)(NSArray<TuyaLightSceneModel *> * _Nonnull scenes))success failure:(void(^)(NSError * _Nonnull error))failure;
@end
NS_ASSUME_NONNULL_END
Before the call of any API method, make sure that the user has logged in to the app.
Before the UI BizBundle is used, the getCurrentHome
method provided by the protocol TYSmartHomeDataProtocol
must be implemented first.
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYSmartHomeDataProtocol.h>
- (void)initCurrentHome {
// Registers the protocol to be implemented.
[[TuyaSmartBizCore sharedInstance] registerService:@protocol(TYSmartHomeDataProtocol) withInstance:self];
}
// Implements the protocol method.
- (TuyaSmartHome *)getCurrentHome {
TuyaSmartHome *home = [TuyaSmartHome homeWithHomeId:@"Current home ID"];
return home;
}
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYLightSceneProtocol.h>
- (void)createLightScene {
id<TYLightSceneProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYLightSceneProtocol)];
[impl createNewLightScene];
}
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYLightSceneProtocol.h>
- (void)editLightScene {
TuyaLightSceneModel *sceneModel = self.sceneList[indexPath.row];
id<TYLightSceneProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYLightSceneProtocol)];
[impl editLightScene:sceneModel];
}
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYLightSceneProtocol.h>
- (void)executeLightScene {
TuyaLightSceneModel *sceneModel = self.sceneList[indexPath.row];
id<TYLightSceneProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYLightSceneProtocol)];
[impl executeLightScene:sceneModel success:^(BOOL success) {
} failure:^(NSError * _Nonnull error) {
}];
}
#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYLightSceneProtocol.h>
- (void)getLightSceneList {
id<TYLightSceneProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYLightSceneProtocol)];
[impl getLightSceneListWithHomeId:'your homeId' success:^(NSArray<TuyaLightSceneModel *> * _Nonnull scenes) {
} failure:^(NSError * _Nonnull error) {
}];
}
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback