Skip to content

Commit

Permalink
fix(air purifier): disable auto mode on fan speed change
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekkleszcz committed Mar 6, 2024
1 parent 7e32a21 commit a66f859
Showing 1 changed file with 19 additions and 20 deletions.
39 changes: 19 additions & 20 deletions src/accessories/devices/airPurifier/airPurifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@ export class AirPurifier extends ElectroluxAccessoryController {
this.appliance.applianceData.applianceName
);

this.airPurifierService.getCharacteristic(
this.platform.Characteristic.RotationSpeed
).props.minStep = 20;

this.airPurifierService
.getCharacteristic(this.platform.Characteristic.Active)
.onGet(this.getActive.bind(this))
Expand Down Expand Up @@ -75,6 +71,11 @@ export class AirPurifier extends ElectroluxAccessoryController {

this.airPurifierService
.getCharacteristic(this.platform.Characteristic.RotationSpeed)
.setProps({
minValue: 0,
maxValue: 5,
minStep: 1
})
.onGet(this.getRotationSpeed.bind(this))
.onSet(this.setRotationSpeed.bind(this));

Expand Down Expand Up @@ -331,7 +332,7 @@ export class AirPurifier extends ElectroluxAccessoryController {
);
}

return this.appliance.properties.reported.Fanspeed * 20;
return this.appliance.properties.reported.Fanspeed;
}

async setRotationSpeed(value: CharacteristicValue) {
Expand All @@ -341,16 +342,6 @@ export class AirPurifier extends ElectroluxAccessoryController {
);
}

if (this.appliance.properties.reported.Workmode === 'Auto') {
setTimeout(() => {
this.airPurifierService.updateCharacteristic(
this.platform.Characteristic.RotationSpeed,
this.appliance.properties.reported.Fanspeed * 20
);
}, 100);
return;
}

if (value === 0) {
await this.sendCommand({
Workmode: 'PowerOff'
Expand All @@ -366,15 +357,23 @@ export class AirPurifier extends ElectroluxAccessoryController {
this.platform.Characteristic.TargetAirPurifierState.AUTO
);
return;
} else if (this.appliance.properties.reported.Workmode === 'Auto') {
await this.sendCommand({
Workmode: 'Manual'
});
this.appliance.properties.reported.Workmode = 'Manual';

this.airPurifierService.updateCharacteristic(
this.platform.Characteristic.TargetAirPurifierState,
this.platform.Characteristic.TargetAirPurifierState.MANUAL
);
}

await this.sendCommand({
Fanspeed: Math.round((value as number) / 20)
Fanspeed: value
});

this.appliance.properties.reported.Fanspeed = Math.round(
(value as number) / 20
);
this.appliance.properties.reported.Fanspeed = value as number;
}

async getIonizer(): Promise<CharacteristicValue> {
Expand Down Expand Up @@ -569,7 +568,7 @@ export class AirPurifier extends ElectroluxAccessoryController {
);
this.airPurifierService.updateCharacteristic(
this.platform.Characteristic.RotationSpeed,
this.appliance.properties.reported.Fanspeed * 20
this.appliance.properties.reported.Fanspeed
);

this.ionizerService.updateCharacteristic(
Expand Down

0 comments on commit a66f859

Please sign in to comment.