Last Updated on : 2024-12-24 02:48:26download
This topic describes how to implement device control linkage.
source 'https://github.com/tuya/tuya-pod-specs.git'
platform :ios, '11.0'
target 'Your_Project_Name' do
pod "ThingSmartBusinessExtensionKit"
end
Device linkage management class
open class ThingDeviceAssociationControlManager : NSObject {
...
}
Data point (DP) information of a device
open class ThingMultiControlDpInfo : NSObject {
open var dpCode: String
open var dpName: String
open var dpId: Int64
}
DP information of a multi-control group
open class ThingMultiControlGroupDeviceDp : NSObject {
open var dpId: Int64
open var code: String
open var name: String
}
Devices of the multi-control group
open class ThingMultiControlGroupDevice : NSObject {
open var multiControlId: Int64
open var datapoints: [ThingMultiControlGroupDeviceDp]
open var devId: String
open var devName: String
open var dpId: Int64
open var dpName: String
open var status: Int
open var enabled: Bool
}
Information of the multi-control group
open class ThingMultiControlGroup : NSObject {
open var multiControlGroupId: Int64
open var multiControlId: Int64
open var groupName: String
open var enabled: Bool
open var groupDetail: [ThingMultiControlGroupDevice]
open var groupType: Int
}
DP information of a scene rule
open class ThingMultiControlGroupParentRuleDpInfo : NSObject {
open var dpId: Int64
open var dpName: String
}
Scene rule
open class ThingMultiControlGroupParentRule : NSObject {
open var ruleId: String
open var name: String
open var dpList: [ThingMultiControlGroupParentRuleDpInfo]
}
Information of the device multi-control group
open class ThingMultiControlGroupInfo : NSObject {
open var bindMaxValue: Int
open var multiGroup: ThingMultiControlGroup
open var parentRules: [ThingMultiControlGroupParentRule]
}
Multi-control device
open class ThingMultiControlDevice : NSObject {
open var datapoints: [ThingMultiControlGroupDeviceDp]
open var devId: String
open var iconUrl: String
open var inRule: Bool
open var multiControlIds: NSMutableArray
open var name: String
open var productId: String
open var roomName: String
}
Device DP multi-control information
open class ThingMultiControlDeviceDpsInfo : NSObject {
open var bindMaxValue: Int
open var datapoints: [ThingMultiControlGroupDeviceDp]
open var mcGroups: [ThingMultiControlGroup]
open var parentRules: [ThingMultiControlGroupParentRule]
}
The information of the specified dual-control group.
open class ThingDoubleControlGroup : NSObject {
open var mainDeviceId: String
open var slaveDeviceIds: [String]
}
The list of dual-control peripheral devices
open class ThingDoubleControlDevice : NSObject {
open var devId: String
open var isRelate: Bool
open var parentId: String
}
Dual-control DP relationship
open class ThingDoubleControlDPRelation : NSObject {
open var dpIds: [String]
open var subDpIds: [String]
open var dpIdMap: [String : String]
}
Dual-control DP information
open class ThingDoubleControlDPInfo : NSObject {
open var code: String
open var dpId: Int64
open var name: String
open var schemaId: String
}
Check support for multi-control linkage.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
Return values: true
: Support. false
: Not support.
class func checkSupportMultiControl(_ deviceId: String) -> Bool
Get multi-control DPs of a device.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
success | [ThingMultiControlDpInfo] | The list of multi-control DPs of the specified device. |
failure | error | The error message. |
class func getMultiControlDp(
withDeviceId deviceId: String,
success: (([ThingMultiControlDpInfo]?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Get the multi-control group under the multi-control DP of the specified device.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
dpId | Int64 | The ID of the specified multi-control DP. |
success | ThingMultiControlGroupInfo | The list of multi-control DPs of the specified device. |
failure | error | The error message. |
class func getMultiControlGroup(
withDeviceId deviceId: String,
dpId: Int64,
success: ((ThingMultiControlGroupInfo?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Update the enabling status of the multi-control group.
Request parameter | Type | Description |
---|---|---|
multiControlGroupId | Int64 | The ID of the specified multi-control group. |
enable | Bool | Specifies whether to enable the multi-control group. |
success | Bool | Indicates whether the operation is successful. |
failure | error | The error message. |
class func updateMultiControlGroupStatus(
_ multiControlGroupId: Int64,
enable: Bool,
success: ((Bool) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Get devices that support multi-control in the specified home.
Request parameter | Type | Description |
---|---|---|
spaceId | Int64 | The home ID. |
success | [ThingMultiControlDevice] | The list of multi-control devices. |
failure | error | The error message. |
class func getMultiControlDevices(
withSpaceId spaceId: Int64,
success: (([ThingMultiControlDevice]?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Get the list of devices in the home that can form multi-control with the specified device.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
spaceId | Int64 | The home ID. |
success | [ThingMultiControlDevice] | The list of multi-control devices. |
failure | error | The error message. |
class func getMultiControlDevices(
withDeviceId deviceId: String,
spaceId: Int64,
success: (([ThingMultiControlDevice]?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Get the device DPs that can form a multi-control group with the specified DP of the target device.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
targetDeviceId | String | The ID of the target device. |
targetDpId | Int64 | The DP of the target device. |
spaceId | Int64 | The home ID. |
success | ThingMultiControlDeviceDpsInfo | The multi-control DP information of the specified device. |
failure | error | The error message. |
class func getAvailableMultiControlDp(
withDeviceId deviceId: String,
targetDevice targetDeviceId: String,
targetDpId: Int64,
spaceId: Int64,
success: ((ThingMultiControlDeviceDpsInfo?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Update the specified multi-control group.
Request parameter | Type | Description |
---|---|---|
multiControlGroupId | Int64 | The ID of the specified multi-control group. |
name | String | The name of the specified multi-control group. |
spaceId | Int64 | The home ID. |
deviceDps | [[AnyHashable : Any]] |
The device DP data. For example, [{devId:xxx, dpId:xxx}, {devId:xxx, dpId:xxx}] . |
success | ThingMultiControlGroup | The information of the multi-control group. |
failure | error | The error message. |
class func updateMultiControlGroup(
_ multiControlGroupId: Int64,
name: String,
spaceId: Int64,
deviceDps: [[AnyHashable : Any]],
success: ((ThingMultiControlGroup) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Check whether the device supports dual-control linkage.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
Return values: true
: Support. false
: Not support.
class func checkSupportDoubleControl(_ deviceId: String) -> Bool
Get the dual-control group information about the specified device.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
spaceId | Int64 | The home ID. |
success | ThingDoubleControlGroup | The information of the specified dual-control group. |
failure | error | The error message. |
class func getDoubleControlGroup(
withDeviceId deviceId: String,
spaceId: Int64,
success: ((ThingDoubleControlGroup?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Remove the specified peripheral device from the dual-control linkage.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The ID of the device to be removed. |
spaceId | Int64 | The home ID. |
success | void | - |
failure | error | The error message. |
class func removeDoubleControlSlaveDevice(
withDeviceId deviceId: String,
spaceId: Int64,
success: (() -> Void)?,
failure: ((Error) -> Void)? = nil
)
Get the list of peripheral devices that can form dual-control linkage with the specified central device.
Request parameter | Type | Description |
---|---|---|
mainDeviceId | String | The ID of the specified central device. |
spaceId | Int64 | The home ID. |
success | [ThingDoubleControlDevice] | The list of dual-control peripheral devices. |
failure | error | The error message. |
class func getDoubleControlAvailableSlaveDevices(
withMainDeviceId mainDeviceId: String,
spaceId: Int64,
success: (([ThingDoubleControlDevice]?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Update the specified peripheral device of the dual-control linkage.
Request parameter | Type | Description |
---|---|---|
mainDeviceId | String | The ID of the specified central device. |
slaveDeviceIds | [String] | The IDs of peripheral devices. |
spaceId | Int64 | The home ID. |
success | Void | - |
failure | error | The error message. |
class func updateDoubleControl(
withMainDeviceId mainDeviceId: String,
slaveDeviceIds: [String],
spaceId: Int64,
success: (() -> Void)?,
failure: ((Error) -> Void)? = nil
)
Get DP relationships between dual-control central and peripheral devices.
Request parameter | Type | Description |
---|---|---|
mainDeviceId | String | The ID of the specified central device. |
slaveDeviceId | [String] | The ID of the specified peripheral device. |
spaceId | Int64 | The home ID. |
success | ThingDoubleControlDPRelation | The dual-control DP relationship. |
failure | error | The error message. |
class func getDoubleControlDPRelation(
withMainDeviceId mainDeviceId: String,
slaveDeviceId: String,
spaceId: Int64,
success: ((ThingDoubleControlDPRelation?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Get localized DP information of the specified device.
Request parameter | Type | Description |
---|---|---|
deviceId | String | The device ID. |
spaceId | Int64 | The home ID. |
success | [ThingDoubleControlDPInfo] | The list of dual-control DP information. |
failure | error | The error message. |
class func getLocalizedDpInfo(
withDeviceId deviceId: String,
spaceId: Int64,
success: (([ThingDoubleControlDPInfo]?) -> Void)?,
failure: ((Error) -> Void)? = nil
)
Update the DP relationships of the dual-control linkage.
Request parameter | Type | Description |
---|---|---|
mainDeviceId | String | The ID of the specified central device. |
slaveDeviceId | String | The ID of the specified peripheral device. |
relations | [String: String] | The DP relationships of the central and peripheral devices.
|
spaceId | Int64 | The home ID. |
success | Void | - |
failure | error | The error message. |
class func updateDoubleControlDpRelation(
withMainDeviceId mainDeviceId: String,
slaveDeviceId: String,
relations: [String : String],
spaceId: Int64,
success: (() -> Void)?,
failure: ((Error) -> Void)? = nil
)
For more information, see Demo.
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback