Last Updated on : 2024-06-05 03:14:36download
This topic describes the methods that are used to manage devices.
Note: Version 4.0 and later are supported.
Name
TYSdk.device.putDeviceData()
Description
Send a data point (DP) state.
Request parameter
Parameter |
Data type |
Description | Required |
---|---|---|---|
dpState | { dpCode: number | string | boolean } |
The DP state to be sent. | Yes |
Sample request
TYSdk.device.putDeviceData(dpState);
// Example: Send `true` to the switch (`dpCode`: `switch`) of a product.
TYSdk.device.putDeviceData({ switch: true });
Sample response
{ success: true }
Name
TYSdk.device.putLocalDpData()
Description
Send a DP state over a LAN.
Request parameter
Parameter |
Data type |
Description | Required |
---|---|---|---|
dpState | { dpCode: number | string | boolean } |
The DP state to be sent over a LAN. | Yes |
Sample request
TYSdk.device.putLocalDpData(dpState);
Sample response
{ success: true }
Name
TYSdk.device.checkDpExist()
Description
Check whether a DP exists.
Request parameter
Parameter |
Data type |
Description | Required |
---|---|---|---|
idOrCode | string |
Set the value of dpId or dpCode . |
Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
isExit | boolean |
Indicate whether a DP exists. |
Sample request
TYSdk.device.checkDpExist(idOrCode);
Sample response
true
Name
TYSdk.device.getDeviceInfo()
Description
Get device information.
Request parameter
Parameter |
Data type |
Description | Required |
---|---|---|---|
idOrCode | string |
Set the value of dpId or dpCode . |
Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
DevInfo | DevInfo | The returned device information. |
Sample request
TYSdk.device.getDeviceInfo()
.then((data: DevInfo) => {
console.log('data :>> ', data);
})
.catch(error => {
console.log('error :>> ', error);
});
Name
TYSdk.device.getDeviceState()
Description
Get a device state.
Return parameter
Parameter | Data type | Description |
---|---|---|
DpState | { dpCode: number | string | boolean } |
The returned device state. |
Sample request
TYSdk.device.getDeviceState()
.then((data: DpState) => {
console.log('data :>> ', data);
})
.catch(error => {
console.log('error :>> ', error);
});
Sample response
{
"switch_1": true,
"countdown_1": 0,
"add_ele": 0,
"cur_current": 0,
"cur_power": 0,
"cur_voltage": 0,
"test_bit": 0,
"voltage_coe": 0,
"electric_coe": 0,
"power_coe": 0,
"electricity_coe": 0,
"fault": 0
}
dpCode
Name
TYSdk.device.getDpCodeById()
Description
Get the value of dpCode
based on dpId
.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
dpId | string | number |
dpId | Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
dpCode | string |
The returned value of dpCode based on dpId . |
Sample request
TYSdk.device.getDpCodeById('22');
Sample response
bright_value
dpCode
Name
TYSdk.device.getDpCodes()
Description
Get all values of dpCode
for a device.
Return parameter
Parameter | Data type | Description |
---|---|---|
dpCodes | string[] |
All values of dpCode returned for a device. |
Sample request
TYSdk.device.getDpCodes();
Sample response
[
"1",
"9",
"17",
"18",
"19",
"20",
"21",
"22",
"23",
"24",
"25",
"26"
]
Name
TYSdk.device.getDpDataFromDevice()
Description
Get a specific DP state from a device.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
idOrCode | string | number |
Set the value of dpId or dpCode . |
Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
DpState | { dpCode: number | string | boolean } |
The DP state returned from a device. |
Sample request
TYSdk.device.getDpDataFromDevice(idOrCode)
.then((data: DpState) => {
console.log('data :>> ', data);
})
.catch(error => {
console.log('error :>> ', error);
});
dpId
Name
TYSdk.device.getDpIdByCode()
Description
Get the value of dpId
based on dpCode
.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
dpCode | string |
dpCode | Yes |
Return parameter
Parameter | Data type | Description |
---|---|---|
dpId | string |
The returned value of dpId based on dpCode . |
Sample request
TYSdk.device.getDpIdByCode('bright_value');
Sample response
22
Name
TYSdk.device.getDpSchema()
Description
Get the DP schema of a device.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
dpCode | string |
dpCode | No |
Return parameter
Parameter | Data type | Description |
---|---|---|
DpSchema | DpSchema | The returned DP schema of a device. |
Sample request
TYSdk.device.getDpSchema(dpCode);
Name
TYSdk.device.getState()
Description
Get the value of a specific DP. If you do not set dpId
or dpCode
, all DP values are returned.
Request parameter
Parameter | Data type | Description | Required |
---|---|---|---|
idOrCode | string |
Set the value of dpId or dpCode . |
No |
Return parameter
Parameter | Data type | Description |
---|---|---|
dpState | { dpCode: number | string | boolean } |
Get the value of a specific DP. If you do not set dpId or dpCode , all DP values are returned. |
Sample request
TYSdk.device.getState(idOrCode);
Sample response
10
Name
TYSdk.device.isBleDevice()
Description
Check whether a device supports Bluetooth.
Return parameter
Parameter | Data type | Description |
---|---|---|
isBleDevice | boolean |
Indicate whether the specified device supports Bluetooth. |
Sample request
TYSdk.device.isBleDevice();
Sample response
true
Name
TYSdk.device.isLocalLAN()
Description
Check whether a device runs on a LAN.
Return parameter
Parameter | Data type | Description |
---|---|---|
isLocalLAN | boolean |
Indicate whether the specified device runs on a LAN |
Sample request
TYSdk.device.isLocalLAN();
Sample response
false
Name
TYSdk.device.isMeshDevice()
Description
Check whether a device is a network device.
Return parameter
Parameter | Data type | Description |
---|---|---|
isMeshDevice | boolean |
Indicate whether the specified device is a network device. |
Sample request
TYSdk.device.isMeshDevice();
Sample response
false
Name
TYSdk.device.isMeshWifiDevice()
Description
Check whether a device is a wireless network device.
Return parameter
Parameter | Data type | Description |
---|---|---|
isMeshWifiDevice | boolean |
Indicate whether the specified device is a wireless network device. |
Sample request
TYSdk.device.isMeshWifiDevice();
Sample response
false
Name
TYSdk.device.isShareDevice()
Description
Check whether a device supports sharing
Return parameter
Parameter | Data type | Description |
---|---|---|
isShareDevice | boolean |
Indicate whether the specified device supports sharing. |
Sample request
TYSdk.device.isShareDevice();
Sample response
false
Name
TYSdk.device.isSigMeshDevice()
Description
Check whether a device supports Bluetooth mesh.
Return parameter
Parameter | Data type | Description |
---|---|---|
isSigMeshDevice | boolean |
Indicate whether the specified device supports Bluetooth mesh |
Sample request
TYSdk.device.isSigMeshDevice();
Sample response
true
Name
TYSdk.device.isWifiDevice()
Description
Check whether a device supports Wi-Fi.
Return parameter
Parameter | Data type | Description |
---|---|---|
isWifiDevice | boolean |
Indicate whether the specified device supports Wi-Fi. |
Sample request
TYSdk.device.isWifiDevice();
Sample response
false
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback