SmartDevicesManager.getDevices()

版本要求:
@ray-js/panel-sdk≥1.16.0

描述

获取所有已注册设备实例的浅拷贝,以 key 为索引。 常用于需要直接操作设备实例而非通过 Hooks 的场景,例如在事件回调中遍历所有设备。

参数

无

返回值

类型:Record<string, SmartDeviceModel>
所有设备实例的记录对象

示例代码

获取设备实例集合

const instances = manager.getDevices();
Object.values(instances).forEach(device => {
  device.publishDps({ switch_led: true });
});