diff --git a/lib/extension/configure.ts b/lib/extension/configure.ts index 6109f4661..76bfdc4e8 100644 --- a/lib/extension/configure.ts +++ b/lib/extension/configure.ts @@ -64,9 +64,11 @@ export default class Configure extends Extension { } override async start(): Promise { - for (const device of this.zigbee.devices(false)) { - await this.configure(device, 'started'); - } + setImmediate(async () => { + for (const device of this.zigbee.devices(false)) { + await this.configure(device, 'started'); + } + }); this.eventBus.onDeviceJoined(this, (data) => { if (data.device.zh.meta.hasOwnProperty('configured')) { diff --git a/test/configure.test.js b/test/configure.test.js index 750e9350d..ef9c29c97 100644 --- a/test/configure.test.js +++ b/test/configure.test.js @@ -65,6 +65,7 @@ describe('Configure', () => { jest.useFakeTimers(); controller = new Controller(jest.fn(), jest.fn()); await controller.start(); + await jest.runOnlyPendingTimers(); await flushPromises(); }); @@ -72,8 +73,9 @@ describe('Configure', () => { data.writeDefaultConfiguration(); settings.reRead(); mocksClear.forEach((m) => m.mockClear()); - coordinatorEndpoint = zigbeeHerdsman.devices.coordinator.getEndpoint(1); + coordinatorEndpoint = zigbeeHerdsman.devices.coordinator.getEndpoint(1); await resetExtension(); + await jest.runOnlyPendingTimers(); }); afterAll(async () => { diff --git a/test/otaUpdate.test.js b/test/otaUpdate.test.js index ad8eae0a9..807ec917e 100644 --- a/test/otaUpdate.test.js +++ b/test/otaUpdate.test.js @@ -36,6 +36,7 @@ describe('OTA update', () => { jest.useFakeTimers(); controller = new Controller(jest.fn(), jest.fn()); await controller.start(); + await jest.runOnlyPendingTimers(); await flushPromises(); }); diff --git a/test/receive.test.js b/test/receive.test.js index 5550ce8f5..638acf4db 100755 --- a/test/receive.test.js +++ b/test/receive.test.js @@ -16,6 +16,8 @@ describe('Receive', () => { jest.useFakeTimers(); controller = new Controller(jest.fn(), jest.fn()); await controller.start(); + await jest.runOnlyPendingTimers(); + await flushPromises(); }); beforeEach(async () => {