Skip to content

Commit

Permalink
fix: speed resetting when active state is already set
Browse files Browse the repository at this point in the history
  • Loading branch information
jvandenaardweg committed Dec 31, 2022
1 parent 8b22d41 commit 5925ff5
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/fan-accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,19 @@ export class FanAccessory {
* SET handler returned write response value, though the characteristic doesn't support write response. See https://homebridge.io/w/JtMGR for more info.
*/
handleSetActive(value: CharacteristicValue): void {
const currentActiveValue = this.service.getCharacteristic(
this.platform.Characteristic.Active,
).value;

const activeName = this.getActiveName(value as number);

this.log.info(`Setting Active to ${value} (${activeName})`);
if (currentActiveValue === value) {
this.log.debug(`Active: Already set to ${activeName}. Ignoring.`);

return;
}

this.log.info(`Active: Setting to: ${value} (was: ${currentActiveValue})`);

// If value to set is 1 (ACTIVE), then we need to set the fan as active
const activate = value === this.platform.Characteristic.Active.ACTIVE;
Expand Down

0 comments on commit 5925ff5

Please sign in to comment.