Last Updated on : 2021-09-07 06:37:11download
Type: enum
Name | Capability bit | Description |
---|---|---|
WIFI | 0 | Wi-Fi |
CABLE | 1 | Cable (Ethernet) |
GPRS | 2 | General Packet Radio Service (2G, 3G, and 4G) |
NBIOT | 3 | Narrowband Internet of Things (NB-IoT) |
BLUETOOTH | 10 | Bluetooth Low Energy (Bluetooth LE) |
BLEMESH | 11 | Tuya mesh |
ZIGBEE | 12 | Zigbee |
INFRARED | 13 | Infrared |
SUBPIECES | 14 | subpieces (315 MHz, 433 MHz, and more) |
SIGMESH | 15 | Bluetooth mesh |
MCU | 16 | Microcontroller unit (MCU) |
TYMESH | 17 | Tuya Sub-G mesh |
ZWAVE | 18 | Z-Wave |
PLMESH | 19 | Bluetooth mesh |
CAT1 | 20 | LTE Cat.1 |
BEACON | 21 | Bluetooth beacon |
Checks whether required capabilities are available and whether unnecessary capabilities are not provided.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
capability | number | No | None | The value of the device’s capability to be checked. |
requiredCapabilityList | Array<DeviceCapability | number> | Yes | [] | The array of required capability bits. |
unneededCapabilityList | Array<DeviceCapability | number> | Yes | [] | The array of unnecessary capability bits. |
Example:
import { GatewayUtils, DeviceCapability } from '@tuya/tuya-panel-gateway-sdk';
const { checkCapability } = GatewayUtils;
checkCapability(1024, [DeviceCapability.BLUETOOTH], [DeviceCapability.WIFI]);
// Or
checkCapability(1024, [10], [1]);
Returns all the devices of the current home.
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
const { getAllDevice } = GatewayUtils;
getAllDevice().then(res => {
// The list of devices that belong to the home.
const deviceList = res;
});
Returns all sub-devices of a gateway.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
devId | string | Yes | TYSdk.devInfo.devId | The device ID of the gateway. |
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
import { TYSdk } from 'tuya-panel-kit';
const { getAllSubDevList } = GatewayUtils;
getAllSubDevList(TYSdk.devInfo.devId).then(res => {
// The list of sub-devices.
const deviceList = res;
});
Returns all sub-devices of a gateway based on specific rules.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
rules | function[] | Yes | [] | The array of rule functions. Input parameters include capability that specifies the value of device’s capability and devInfo that specifies device information. The return result is a Boolean value that indicates whether the specified rules are met. |
gatewayDevId | string | Yes | TYSdk.devInfo.devId | The device ID of the gateway. |
Example:
import { GatewayUtils, DeviceCapability } from '@tuya/tuya-panel-gateway-sdk';
import { TYSdk } from 'tuya-panel-kit';
const { checkCapability, getSpecificSubDevList } = GatewayUtils;
// Returns Bluetooth devices.
const getBluetoothDev = (capability, devInfo) => {
return checkCapability(capability, [DeviceCapability.BLUETOOTH]);
};
// Returns Zigbee devices.
const getZigbeeDev = (capability, devInfo) => {
return checkCapability(capability, [DeviceCapability.ZIGBEE]);
};
getSpecificSubDevList([getBluetoothDev, getZigbeeDev], TYSdk.devInfo.devId).then(res => {
// `bluetoothList`: the list of Bluetooth devices. `zigbeeList`: the list of Zigbee devices.
const [bluetoothList, zigbeeList] = res;
});
Checks whether a Bluetooth sub-device is used.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
capability | number | No | None | The value of the device’s capability to be checked. |
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
const { getAllSubDevList, isBlueSub } = GatewayUtils;
isBlueSub(1024); // Returns `true`.
isBlueSub(1025); // Returns `false`.
getAllSubDevList().then(res => {
// The list of Bluetooth sub-devices.
const deviceList = res.filter(({ capability }) => isBlueSub(capability));
});
Checks whether a Bluetooth mesh sub-device is used.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
capability | number | No | None | The value of the device’s capability to be checked. |
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
const { getAllSubDevList, isSigmeshSub } = GatewayUtils;
isSigmeshSub(32768); // Returns `true`.
isSigmeshSub(32769); // Returns `false`.
getAllSubDevList().then(res => {
// The list of Bluetooth mesh sub-devices.
const deviceList = res.filter(({ capability }) => isSigmeshSub(capability));
});
Checks whether a Zigbee sub-device is used.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
capability | number | No | None | The value of the device’s capability to be checked. |
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
const { getAllSubDevList, isZigbeeSub } = GatewayUtils;
isZigbeeSub(4096); // Returns `true`.
isZigbeeSub(4097); // Returns `false`.
getAllSubDevList().then(res => {
// The list of Zigbee sub-devices.
const deviceList = res.filter(({ capability }) => isZigbeeSub(capability));
});
Checks whether a beacon sub-device is used.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
capability | number | No | None | The value of the device’s capability to be checked. |
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
const { getAllSubDevList, isBeaconSub } = GatewayUtils;
isBeaconSub(2097152); // Returns `true`.
isBeaconSub(2097153); // Returns `false`.
getAllSubDevList().then(res => {
// The list of beacon sub-devices.
const deviceList = res.filter(({ capability }) => isBeaconSub(capability));
});
Checks whether a sub-device can be added to a gateway based on their mesh relationship.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
subDevInfo | object | No | None | The information about the sub-device. |
gatewayDevInfo | object | Yes | TYSdk.devInfo | The information about the gateway. |
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
const { getAllDevice, isAddableMesh } = GatewayUtils;
getAllDevice().then(res => {
// The list of devices that can be added to the gateway based on their mesh relationships.
const addableDeviceList = res.filter(device => isAddableMesh(device));
});
Checks whether a device can be added to a gateway.
Parameter | Type | Optional | Default value | Description |
---|---|---|---|---|
devInfo | object | No | None | The information about the device. |
gatewayDevInfo | object | Yes | TYSdk.devInfo | The information about the gateway. |
isMeshValid | function | Yes | isAddableMesh | Indicates whether the device can be added to the gateway based on their mesh relationship. |
bluetoothPidBlackList | []string | Yes | [‘ahkliczu’, ‘h4wa9i2m’, ‘itbz5kp3’, ‘rpabxhth’, ‘uhuqwuib’, ‘uk21by86’, ‘wvgwdbag’, ‘wvicf3bs’, ‘bvo6il58’, ‘hdoz0dny’, ‘ul3jjbna’, ‘ya75xxhl’] | The blocklist of Bluetooth devices. The listed devices cannot be added to the gateway. |
supportBeacon | bool | Yes | false | Indicates whether beacon devices can be added. |
Example:
import { GatewayUtils } from '@tuya/tuya-panel-gateway-sdk';
const { getAllDevice, isAddableMesh, isAddableDevice } = GatewayUtils;
getAllDevice().then(res => {
// The list of devices that can be added to the gateway, including beacon sub-devices.
const addableDeviceList = res.filter(device =>
isAddableDevice({
devInfo: device,
gatewayDevInfo: TYSdk.devInfo,
isMeshValid: isAddableMesh,
bluetoothPidBlackList: [],
supportBeacon: true,
})
);
});
Is this page helpful?
YesFeedbackIs this page helpful?
YesFeedback