Skip to content

Commit

Permalink
fix: Improve looping when retrieving all devices from herdsman (#23405)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nerivec authored Jul 24, 2024
1 parent 1bf3032 commit b7d9d9e
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/zigbee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,15 @@ export default class Zigbee {
}

devices(includeCoordinator = true): Device[] {
return this.herdsman
.getDevices()
.map((d) => this.resolveDevice(d.ieeeAddr))
.filter((d) => includeCoordinator || d.zh.type !== 'Coordinator');
const devices: Device[] = [];

for (const device of this.herdsman.getDevices()) {
if (includeCoordinator || device.type !== 'Coordinator') {
devices.push(this.resolveDevice(device.ieeeAddr));
}
}

return devices;
}

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

0 comments on commit b7d9d9e

Please sign in to comment.