Multi-Control Linkage UI BizBundle

Last Updated on : 2024-07-16 06:28:45download

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

Multi-control linkage is a device control feature. 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 'ThingSmartDeviceSyncBizBundle'
end

Service protocol

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

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

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@protocol ThingDeviceSyncProtocol <NSObject>

/**
 Navigates to the center of multi-control linkage devices.
 @param devId The device ID of the device.
 */
- (void)gotoDeviceBindViewControllerWithDevId:(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

Objective-C:

#import <ThingSmartBizCore/ThingSmartBizCore.h>
#import <ThingModuleServices/ThingDeviceSyncProtocol.h>

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

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

Swift:

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

Access page of multi-control linkage

Objective-C:

#import <ThingSmartBizCore/ThingSmartBizCore.h>
#import <ThingModuleServices/ThingDeviceSyncProtocol.h>

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

  id<ThingDeviceSyncProtocol> impl = [[ThingSmartBizCore sharedInstance] serviceOfProtocol:@protocol(ThingDeviceSyncProtocol)];
  [impl gotoDeviceBindViewControllerWithDevId:deviceId];
}

Swift:

let impl = ThingSmartBizCore.sharedInstance().service(of:ThingDeviceSyncProtocol.self) as?ThingDeviceSyncProtocol
impl?.gotoDeviceBindViewControllerWithDevId(devId: @"deviceId")