Skip to content

Commit

Permalink
feat: stop state polling temporary when manually switching on or off
Browse files Browse the repository at this point in the history
  • Loading branch information
jvandenaardweg committed Dec 19, 2024
1 parent d34b3aa commit 58c2d40
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/energy-socket-accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});
Expand All @@ -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();
}
}

Expand Down

0 comments on commit 58c2d40

Please sign in to comment.