import { DevInfo, DpSchema } from '../../../types/devInfo'; import { SmartDeviceAbility } from '../../types'; declare const WorkMode: { colour: string; white: string; scene: string; music: string; }; type DeviceId = string; type Options = DeviceId | { deviceId?: string; groupId?: string; }; type SmartSupportAbilityOptions = { initDevInfo?: (devInfo: DevInfo) => DevInfo; }; /** * 设备能力检测,判断设备支持的功能点与协议类型 * @public * @since @ray-js/panel-sdk 1.10.0 * @typeParam S - 功能点 DpSchema 定义 * @remarks * 通过 SmartDeviceModel 的 abilities 配置挂载后使用。 * 同时支持单设备和群组设备。 * @example * ```typescript * import { SmartDeviceModel, SmartSupportAbility } from '@ray-js/panel-sdk'; * * const sdm = new SmartDeviceModel({ abilities: [new SmartSupportAbility()] }); * ``` */ declare class SmartSupportAbility implements SmartDeviceAbility { private configOptions; private static globalInstance; /** * 全局初始化状态 */ private static globalInitialized; /** * @param options - 设备能力检测配置 */ constructor(options?: SmartSupportAbilityOptions); /** * 获取全局已初始化的实例 * @internal * @returns 已初始化的全局实例 * @throws Error 如果实例尚未初始化 */ static getInstance(): SmartSupportAbility; /** * 检查全局实例是否已初始化 * @internal * @returns true 表示已初始化 */ static isReady(): boolean; /** * 重置全局状态(主要用于测试) * @internal */ static reset(): void; /** * 初始化 Promise - 用于防重入,多次调用 init 会返回同一个 Promise */ private initPromise; /** * 初始化设备支持能力,由 SmartDeviceModel 内部调用 * @internal */ init: (options?: Options) => Promise; private doInit; private _deviceId; private _groupId; /** @internal */ readonly abilityOptions: { name: string; /** * 配置了此项说明该能力支持群组环境 */ isSupportGroup: boolean; /** * 配置了此项说明该能力在 SDM 或 SGM 初始化时会同时等待该能力 init 异步方法完成后才会认为 SDM 或 SGM 整体初始化完毕了, * 一般用于一些能力需要 init 完毕以后才能正常使用的场景,比如当前这个设备支持情况的能力,在设备数据没初始化好之前,是没办法使用的。 */ waitForInit: boolean; }; /** * 当前设备 ID */ private get deviceId(); private set deviceId(value); /** * 当前群组 ID */ private get groupId(); private set groupId(value); private devInfo; /** * 初始化存储 ID 并返回 */ private initId; private getDevInfo; private supportDp; /** * 检查给定的功能点编码是否受设备支持 * @public * @since @ray-js/panel-sdk 1.0.0 * @param dpCode 功能点编码 * @param isForce 是否跳过缓存强制检查,默认 false * @returns 该功能点是否支持 * @remarks * 同时支持单设备和群组设备。结果默认会缓存,传入 isForce=true 可强制重新检查。 * @example * ```typescript * const hasBright = sdm.support.isSupportDp('bright_value'); * const hasSwitch = sdm.support.isSupportDp('switch_led'); * console.log('支持亮度:', hasBright, '支持开关:', hasSwitch); * ``` */ isSupportDp: (dpCode: S[number]['code'], isForce?: boolean) => boolean; /** * 判断设备是否已添加到网关下 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否在网关环境下 * @remarks * 仅支持单设备,不支持群组环境。 * @example * ```typescript * const inGateway = sdm.support.isInGateway(); * if (inGateway) { * console.log('设备已接入网关'); * } * ``` */ isInGateway: () => boolean; /** * 判断当前是否是群组设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是群组设备 * @example * ```typescript * const isGroup = sdm.support.isGroupDevice(); * if (isGroup) { * console.log('当前为群组设备'); * } * ``` */ isGroupDevice: () => boolean; /** * 判断设备是否支持白光亮度功能点 * @public * @since @ray-js/panel-sdk 1.0.0 * @param isForce - 是否跳过缓存强制检查,默认 false * @returns 是否支持白光亮度 * @example * ```typescript * if (sdm.support.isSupportBright()) { * console.log('设备支持亮度调节'); * } * ``` */ isSupportBright: (isForce?: boolean) => boolean; /** * 判断设备是否支持色温功能点 * @public * @since @ray-js/panel-sdk 1.0.0 * @param isForce - 是否跳过缓存强制检查,默认 false * @returns 是否支持色温 * @example * ```typescript * if (sdm.support.isSupportTemp()) { * console.log('设备支持色温调节'); * } * ``` */ isSupportTemp: (isForce?: boolean) => boolean; /** * 判断设备是否支持彩光功能点 * @public * @since @ray-js/panel-sdk 1.0.0 * @param isForce - 是否跳过缓存强制检查,默认 false * @returns 是否支持彩光 * @example * ```typescript * if (sdm.support.isSupportColour()) { * console.log('设备支持彩光模式'); * } * ``` */ isSupportColour(isForce?: boolean): boolean; /** * 判断设备是否支持云端定时功能 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否支持云端定时 * @remarks * 群组设备需要设备列表中所有设备均支持定时才返回 true。 * 单设备通过 panelConfig.bic 中 timer 配置项判断。 * @example * ```typescript * if (sdm.support.isSupportCloudTimer()) { * console.log('支持云端定时,可展示定时入口'); * } * ``` */ isSupportCloudTimer: () => boolean; /** * 获取校正后的 workMode * @internal * @since @ray-js/panel-sdk 1.0.0 * @param workMode - 设备上报的工作模式 * @returns 校正后的工作模式 * @remarks * 当设备上报的 workMode 不受支持时(如三路灯上报了白光模式但不支持白光), * 会自动回退到设备实际支持的模式。 * @example * ```typescript * const correctedMode = sdm.support.getWorkMode('white'); * // 如果设备不支持白光,会自动回退为 'colour' * console.log('校正后模式:', correctedMode); * ``` */ getWorkMode(workMode: keyof typeof WorkMode): string; /** * 判断设备是否具有指定的协议能力 * @internal * @since @ray-js/panel-sdk 1.0.0 * @param id - 协议能力 ID(wifi=0, gprs=2, bluetooth=10, blemesh=11, zigbee=12, sigmesh=15, cat1=20, beacon=21, lteCat4=22, lteCat10=23, lteCatM=24, thread=25) * @returns 是否具有该协议能力 * @example * ```typescript * import { DeviceCapability } from '@ray-js/panel-sdk'; * * const isWifi = sdm.support.hasCapability(DeviceCapability.WiFi); * const isBle = sdm.support.hasCapability(DeviceCapability.Bluetooth); * console.log('WiFi:', isWifi, 'BLE:', isBle); * ``` */ hasCapability: (id: number) => boolean; /** * 判断是否是 WiFi 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 WiFi 设备 * @example * ```typescript * if (sdm.support.isWifiDevice()) { * console.log('当前为 WiFi 设备'); * } * ``` */ isWifiDevice: () => boolean; /** * 判断是否是 GPRS 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 GPRS 设备 * @example * ```typescript * if (sdm.support.isGprsDevice()) { * console.log('当前为 GPRS 设备'); * } * ``` */ isGprsDevice: () => boolean; /** * 判断是否是蓝牙 Bluetooth 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 Bluetooth 设备 * @example * ```typescript * if (sdm.support.isBluetoothDevice()) { * console.log('当前为蓝牙设备'); * } * ``` */ isBluetoothDevice: () => boolean; /** * 判断是否是 BLE Mesh 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 BLE Mesh 设备 * @example * ```typescript * if (sdm.support.isBleMeshDevice()) { * console.log('当前为 BLE Mesh 设备'); * } * ``` */ isBleMeshDevice: () => boolean; /** * 判断是否是 Zigbee 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 Zigbee 设备 * @example * ```typescript * if (sdm.support.isZigbeeDevice()) { * console.log('当前为 Zigbee 设备'); * } * ``` */ isZigbeeDevice: () => boolean; /** * 判断是否是 SIG Mesh 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 SIG Mesh 设备 * @example * ```typescript * if (sdm.support.isSigMeshDevice()) { * console.log('当前为 SIG Mesh 设备'); * } * ``` */ isSigMeshDevice: () => boolean; /** * 判断是否是蓝牙类设备(包含 Bluetooth、BLE Mesh、SIG Mesh) * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是蓝牙类设备 * @example * ```typescript * if (sdm.support.isBleDevice()) { * console.log('当前为蓝牙类设备(含 BLE Mesh / SIG Mesh)'); * } * ``` */ isBleDevice: () => boolean; /** * 判断是否是 Cat.1 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 Cat.1 设备 * @example * ```typescript * if (sdm.support.isCat1Device()) { * console.log('当前为 Cat.1 蜂窝设备'); * } * ``` */ isCat1Device: () => boolean; /** * 判断是否是 Beacon 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 Beacon 设备 * @example * ```typescript * if (sdm.support.isBeaconDevice()) { * console.log('当前为 Beacon 设备'); * } * ``` */ isBeaconDevice: () => boolean; /** * 判断是否是 LTE Cat.4 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 LTE Cat.4 设备 * @example * ```typescript * if (sdm.support.isLteCat4Device()) { * console.log('当前为 LTE Cat.4 设备'); * } * ``` */ isLteCat4Device: () => boolean; /** * 判断是否是 LTE Cat.10 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 LTE Cat.10 设备 * @example * ```typescript * if (sdm.support.isLteCat10Device()) { * console.log('当前为 LTE Cat.10 设备'); * } * ``` */ isLteCat10Device: () => boolean; /** * 判断是否是 LTE Cat.M 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 LTE Cat.M 设备 * @example * ```typescript * if (sdm.support.isLteCatMDevice()) { * console.log('当前为 LTE Cat.M 设备'); * } * ``` */ isLteCatMDevice: () => boolean; /** * 判断是否是 Thread 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 Thread 设备 * @example * ```typescript * if (sdm.support.isThreadDevice()) { * console.log('当前为 Thread 设备'); * } * ``` */ isThreadDevice: () => boolean; /** * 判断是否是 Matter 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是 Matter 设备(包含涂鸦 Matter 和三方 Matter) * @example * ```typescript * if (sdm.support.isMatterDevice()) { * console.log('当前为 Matter 设备'); * } * ``` */ isMatterDevice(): boolean; /** * 判断是否是涂鸦 Matter 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是涂鸦 Matter 设备(排除三方 Matter) * @example * ```typescript * if (sdm.support.isTuyaMatterDevice()) { * console.log('当前为涂鸦 Matter 设备'); * } * ``` */ isTuyaMatterDevice(): boolean; /** * 判断是否是三方 Matter 设备 * @public * @since @ray-js/panel-sdk 1.0.0 * @returns 是否是三方 Matter 设备 * @example * ```typescript * if (sdm.support.isTripartiteMatter()) { * console.log('当前为三方 Matter 设备'); * } * ``` */ isTripartiteMatter(): boolean; /** * 判断是否支持 Matter 白光 * @public * @since @ray-js/panel-sdk 1.0.0 * @param force - 当没有接入 matter-kit 时,需要传入 true * @returns 是否支持 Matter 白光 * @example * ```typescript * const supportMatterWhite = sdm.support.isSupportMatterWhite(); * console.log('支持 Matter 白光:', supportMatterWhite); * ``` */ isSupportMatterWhite(force?: boolean): boolean; } export { SmartSupportAbility }; export default SmartSupportAbility;