diff --git a/src/energy-socket-accessory.ts b/src/energy-socket-accessory.ts index 3756966..d557a59 100644 --- a/src/energy-socket-accessory.ts +++ b/src/energy-socket-accessory.ts @@ -441,6 +441,9 @@ export class EnergySocketAccessory { ); } + // Stop the state polling, it can interfere with this request + this.stopStatePolling(); + const response = await this.energySocketApi.updateState({ power_on: value as boolean, }); @@ -455,6 +458,9 @@ export class EnergySocketAccessory { const fallbackErrorMessage = 'A unknown error occurred while setting the ON state'; throw this.handleAccessoryApiError(error, fallbackErrorMessage); + } finally { + // Start the state polling again, because it was stopped in the try block + this.startStatePolling(); } }