Skip to content

Commit 24fbe25

Browse files
committed
Improve looping when retrieving all devices from herdsman.
1 parent 8545309 commit 24fbe25

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/zigbee.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -330,10 +330,15 @@ export default class Zigbee {
330330
}
331331

332332
devices(includeCoordinator = true): Device[] {
333-
return this.herdsman
334-
.getDevices()
335-
.map((d) => this.resolveDevice(d.ieeeAddr))
336-
.filter((d) => includeCoordinator || d.zh.type !== 'Coordinator');
333+
const devices: Device[] = [];
334+
335+
for (const device of this.herdsman.getDevices()) {
336+
if (includeCoordinator || device.type !== 'Coordinator') {
337+
devices.push(this.resolveDevice(device.ieeeAddr));
338+
}
339+
}
340+
341+
return devices;
337342
}
338343

339344
@bind private async acceptJoiningDeviceHandler(ieeeAddr: string): Promise<boolean> {

0 commit comments

Comments
 (0)