Is this page helpful?
YesNoLast Updated on : 2022-01-07 07:03:32
This topic describes the API methods to implement multiple device management features. For example, get device details, modify device details, remove devices, get the instruction set of the device, and send commands.
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
Description of TYDevice
Parameter | Data type | Description |
---|---|---|
id | String | The device ID. |
uuid | String | The universally unique identifier (UUID) of a device. |
category | String | The category of the product. |
name | String | The name of the device. |
productID | String | The product ID. |
productName | String | The name of the product. |
localKey | String | The key. |
isSubDevice | Bool | Indicates whether a sub-device is used. |
assetID | String | The asset ID. |
ipAddress | String | The IP address of the device. |
timeZone | String | The time zone. |
activeTime | Int | The time when the device was activated. |
updateTime | Int | The time when the device was last updated. |
createTime | Int | The time when the device was first paired. |
isOnline | Bool | Indicates whether the device is online. |
icon | String | The icon of the device (prefix: https://images.tuyacn.com/). |
longitude | String | The longitude of the device. |
latitude | String | The latitude of the device. |
model | String | The device model. |
Example |
TYDeviceManager().queryDeviceInfo(of: "") { deviceInfo, error in
guard error == nil else {
print(error?.localizedDescription)
return
}
let name = deviceInfo?.name
let productID = deviceInfo?.productID
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceIDs | Array<String> | true | The list of device IDs. Up to 20 device IDs are supported in the same request. |
Example
TYDeviceManager().queryDevicesInfo(of: idArray) { (deviceArray, error) in
guard error == nil else {
print(error?.localizedDescription)
return
}
self.deviceList = deviceArray!
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
name | String | true | The name of the device. |
Example
TYDeviceManager().modifyDeviceName(for: self.device!.id, to: self.newName) { (bool, error) in
if bool == true {
// Do something
} else {
// Do something
}
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
Example
TYDeviceManager().removeDevice("Your device ID") { (bool, error) in
if bool == true {
// Do something
return
}
print(error?.localizedDescription)
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceIDs | Array<String> | true | The list of device IDs. Up to 20 device IDs are supported in the same request. |
Example
TYDeviceManager().removeDevice("Your device id") { success, error in
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
Example
TYDeviceManager().resetDevice(for: "Your device id") { success, error in
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID of the gateway. |
Description of TYPairedSubDevice
Parameter | Data type | Description |
---|---|---|
id | String | The device ID. |
name | String | The name of the device. |
isOnline | Boolean | Indicates whether a device is online. |
activeTime | Int | The time when the device was activated. |
updateTime | Int | The time when the device status was last updated. |
productID | String | The product ID of the device. |
category | String | The category of the device. |
nodeID | String | The node ID of the sub-device. |
assetID | String | The asset ID. |
icon | String | The icon of the device. |
Example
TYDeviceManager().querySubDevices("Your device id") { (deviceArray, error) in
guard error == nil else {
print(error?.localizedDescription)
return
}
let devices = deviceArray
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
Description of TYDeviceCommand
Parameter | Data type | Description |
---|---|---|
code | String | The status code. |
value | Any | The status value. |
Example
TYDeviceManager().queryDeviceStatus(of: "Your device id") { commands, error in
guard error == nil else {
print(error?.localizedDescription)
return
}
let devices = commands
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
Example
TYDeviceManager().queryDeviceStatus(of: "Your device id") { commands, error in
guard error == nil else {
print(error?.localizedDescription)
return
}
let commands = commands
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
category | String | true | The category of the product. Example: dj . |
Description of TYCategoryStandardCommand
Parameter | Data type | Description |
---|---|---|
category | String | The category of the product. |
functions | Array<TYStandardCommand> | The instruction set. |
Description of TYStandardCommand
Parameter | Data type | Description |
---|---|---|
name | String | The name of the command. |
detail | String | Description |
code | String | The command. |
type | String | The type of command. |
values | String | The range of the command request parameter values. |
Example
TYDeviceManager().queryCommandSetFromCategory("") { command, error in
guard error == nil else {
print(error?.localizedDescription)
return
}
let category = command?.category
let commadns = command?.functions
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
Example
TYDeviceManager().queryCommandSetFromDeviceID("Your device id") { command, error in
guard error == nil else {
print(error?.localizedDescription)
return
}
let category = command?.category
let commadns = command?.functions
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
deviceID | String | true | The device ID. |
Description of TYDeviceSpecification
Parameter | Data type | Description |
---|---|---|
category | String | The category of the product. |
functions | Array<TYStandardCommand> | The instruction set. |
status | Array<TYStandardStatus> | The status set. |
Description of TYStandardStatus
Parameter | Data type | Description |
---|---|---|
name | String | The name of the command. |
code | String | The command. |
type | String | The type of data. |
values | String | The range of the command request parameter values. |
Example
TYDeviceManager().queryDeviceSpecification(of: "Your category id") { specification, error in
guard error == nil else {
print(error?.localizedDescription)
return
}
let category = specification?.category
let functions = specification?.functions
let status = specification?.status
}
Parameters
Parameter | Data type | Required | Description |
---|---|---|---|
commands | Array<TYDeviceCommand> | true | The control command. |
deviceID | String | true | The device ID. |
Description of TYDeviceCommand
Parameter | Data type | Required | Description |
---|---|---|---|
code | String | true | The DP code. |
value | Any | true | The DP value. |
Example
TYDeviceManager().sendCommands([dp1, dp2, dp3], to: "Your device ID") { (bool, error) in
guard error == nil else {
print("Faild")
return
}
print("Succeed")
}
Is this page helpful?
YesNoIs this page helpful?
YesNo