English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Multi-Control Linkage UI BizBundle

Last Updated on : 2022-09-16 09:24:37download

Multi-Control Linkage UI BizBundle provides the service logic and UI to implement linking multi-control devices in the multi-control linkage module.

Functional description

In this feature, a device data point (DP) is linked with a DP of another device to create a multi-control group. When a device of the multi-control group is controlled, the linked status of other devices in the group is synchronously changed.

For example, 3 two-gang Zigbee sub-device switches, the first DP of each switch is linked with the first DP of the other two switches to create a multi-control group. When the first DP for one of these switches is set to off, the first DP of the other two switches is synchronously set to off.

Currently, the following devices are supported by multi-control linkage:

  • Switches of Zigbee sub-devices
  • Switches of Wi-Fi devices

Integrate with the UI BizBundle

Add the components of the Multi-Control Linkage 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
  # Added the multi-control linkage BizBundle.
  pod 'TuyaSmartDeviceSyncBizBundle'
end

Service protocols

Before the integration with the UI BizBundle, you must query the target device IDs.

The UI BizBundle relies on the implementation of the protocol TYDeviceSyncProtocol.h to provide services. You can view the TYDeviceSyncProtocol.h file in the TYModuleServices component.

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol TYDeviceSyncProtocol <NSObject>

typedef NS_ENUM(NSInteger, TYDeviceSyncControlState) {
    TYDeviceSyncControlStateNone = 0,          // The device bean does not exist.
    TYDeviceSyncControlStateSupport,           // Multi-control linkage is supported.
    TYDeviceSyncControlStateNotSupport,        // Multi-control linkage is not supported.
};

/**
 Navigates to the multi-control linkage page.
 @param devId The device ID of the main device.
 @result TYDeviceSyncControlState The status of multi-control linkage for the main device.
 */
- (TYDeviceSyncControlState)gotoMultiControl:(NSString *)devId;

/**
 Checks whether the current main device supports multi-control linkage.
 @param devId The device ID of the main device.
 @result BOOL Indicates whether the main device supports multi-control linkage.
 */
- (BOOL)isSupportMultiControl:(NSString *)devId;

@end

NS_ASSUME_NONNULL_END

Check support for multi-control linkage

ObjC:

#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYDeviceSyncProtocol.h>

// Implements the protocol method.
- (void)isSupportMultiControl {
  NSString *deviceId = @"deviceId";

  id<TYDeviceSyncProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYDeviceSyncProtocol)];
  BOOL isSupport = [impl isSupportMultiControl:deviceId];
}

Swift:

let impl = TuyaSmartBizCore.sharedInstance().service(of:TYDeviceSyncProtocol.self) as?TYDeviceSyncProtocol
impl?.isSupportMultiControl(devId: @"deviceId")

Enter the page of multi-control linkage

ObjC:

#import <TuyaSmartBizCore/TuyaSmartBizCore.h>
#import <TYModuleServices/TYDeviceSyncProtocol.h>

// Implements the protocol method.
- (void)gotoMultiControl {
  NSString *deviceId = @"deviceId";

  id<TYDeviceSyncProtocol> impl = [[TuyaSmartBizCore sharedInstance] serviceOfProtocol:@protocol(TYDeviceSyncProtocol)];
  TYDeviceSyncControlState state = [impl gotoMultiControl:deviceId];
}

Swift:

let impl = TuyaSmartBizCore.sharedInstance().service(of:TYDeviceSyncProtocol.self) as?TYDeviceSyncProtocol
impl?.gotoMultiControl(devId: @"deviceId")