Skip to content

Commit

Permalink
feat: implement support for pure a9
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekkleszcz authored Jul 7, 2023
1 parent e95ee19 commit e68f96d
Show file tree
Hide file tree
Showing 8 changed files with 157 additions and 30 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@ This is a plugin for connecting Electrolux devices which are controlled by the [
## 🌡️ Supported devices
- Comfort 600 air conditioner
- Well A7 air purifier
- Pure A9/AX 9 air purifier

If your device is not on the list, please create the issue. I'll be more than happy to implement the support for your device. 😄
8 changes: 7 additions & 1 deletion config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,13 @@
"title": "Polling interval",
"type": "number",
"required": false,
"default": "10"
"default": "30"
},
"carbonDioxideSensorAlarmValue": {
"title": "Carbon dioxide sensor alarm value",
"type": "number",
"required": false,
"default": "1000"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"displayName": "Homebridge Electrolux Devices",
"name": "homebridge-electrolux-devices",
"version": "0.0.2",
"version": "0.0.3",
"description": "Homebridge plugin for Electrolux devices",
"license": "Apache-2.0",
"repository": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import {CharacteristicValue, PlatformAccessory, Service} from 'homebridge';

import { ElectroluxDevicesPlatform } from '../../platform';
import { Appliance } from '../../definitions/appliance';
import { ElectroluxAccessoryController } from '../controller';
import { ElectroluxDevicesPlatform } from '../../../platform';
import { Appliance } from '../../../definitions/appliance';
import { ElectroluxAccessoryController } from '../../controller';

export class WellA7 extends ElectroluxAccessoryController {
export class AirPurifier extends ElectroluxAccessoryController {

private airPurifierService: Service;
private airQualityService: Service;
private carbonDioxideSensorService: Service;
private humiditySensorService: Service;
private temperatureSensorService: Service;

Expand Down Expand Up @@ -65,15 +64,6 @@ export class WellA7 extends ElectroluxAccessoryController {
this.airQualityService.getCharacteristic(this.platform.Characteristic.VOCDensity)
.onGet(this.getVOCDensity.bind(this));

this.carbonDioxideSensorService = this.accessory.getService(this.platform.Service.CarbonDioxideSensor) ||
this.accessory.addService(this.platform.Service.CarbonDioxideSensor);

this.carbonDioxideSensorService.getCharacteristic(this.platform.Characteristic.CarbonDioxideDetected)
.onGet(this.getCarbonDioxideDetected.bind(this));

this.carbonDioxideSensorService.getCharacteristic(this.platform.Characteristic.CarbonDioxideLevel)
.onGet(this.getCarbonDioxideLevel.bind(this));

this.humiditySensorService = this.accessory.getService(this.platform.Service.HumiditySensor) ||
this.accessory.addService(this.platform.Service.HumiditySensor);

Expand Down Expand Up @@ -243,15 +233,6 @@ export class WellA7 extends ElectroluxAccessoryController {
return this.appliance.properties.reported.TVOC;
}

async getCarbonDioxideDetected(): Promise<CharacteristicValue> {
return this.appliance.properties.reported.ECO2 > 1000 ?
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL :
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL;
}

async getCarbonDioxideLevel(): Promise<CharacteristicValue> {
return this.appliance.properties.reported.ECO2;
}

async getCurrentRelativeHumidity(): Promise<CharacteristicValue> {
return this.appliance.properties.reported.Humidity;
Expand All @@ -261,7 +242,7 @@ export class WellA7 extends ElectroluxAccessoryController {
return this.appliance.properties.reported.Temp;
}

update(appliance: Appliance) {
async update(appliance: Appliance) {
this.appliance = appliance;

switch(this.appliance.properties.reported.Workmode) {
Expand Down Expand Up @@ -319,6 +300,33 @@ export class WellA7 extends ElectroluxAccessoryController {
this.platform.Characteristic.RotationSpeed,
this.appliance.properties.reported.Fanspeed * 20
);

this.airQualityService.updateCharacteristic(
this.platform.Characteristic.AirQuality,
await this.getAirQuality()
);
this.airQualityService.updateCharacteristic(
this.platform.Characteristic.PM2_5Density,
this.appliance.properties.reported.PM2_5
);
this.airQualityService.updateCharacteristic(
this.platform.Characteristic.PM10Density,
this.appliance.properties.reported.PM10
);
this.airQualityService.updateCharacteristic(
this.platform.Characteristic.VOCDensity,
this.appliance.properties.reported.TVOC
);

this.humiditySensorService.updateCharacteristic(
this.platform.Characteristic.CurrentRelativeHumidity,
this.appliance.properties.reported.Humidity
);

this.temperatureSensorService.updateCharacteristic(
this.platform.Characteristic.CurrentTemperature,
this.appliance.properties.reported.Temp
);
}

}
51 changes: 51 additions & 0 deletions src/accessories/devices/airPurifier/pureA9.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
import { AirPurifier } from './airPurifier';
import { ElectroluxDevicesPlatform } from '../../../platform';
import { ElectroluxAccessoryController } from '../../controller';
import { Appliance } from '../../../definitions/appliance';

export class PureA9 extends AirPurifier {

private carbonDioxideSensorService: Service;

constructor(
readonly _platform: ElectroluxDevicesPlatform,
readonly _accessory: PlatformAccessory<ElectroluxAccessoryController>,
readonly _appliance: Appliance
) {
super(_platform, _accessory, _appliance);

this.carbonDioxideSensorService = this.accessory.getService(this.platform.Service.CarbonDioxideSensor) ||
this.accessory.addService(this.platform.Service.CarbonDioxideSensor);

this.carbonDioxideSensorService.getCharacteristic(this.platform.Characteristic.CarbonDioxideDetected)
.onGet(this.getCarbonDioxideDetected.bind(this));

this.carbonDioxideSensorService.getCharacteristic(this.platform.Characteristic.CarbonDioxideLevel)
.onGet(this.getCarbonDioxideLevel.bind(this));
}

async getCarbonDioxideDetected(): Promise<CharacteristicValue> {
return this.appliance.properties.reported.ECO2 > 1000 ?
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL :
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL;
}

async getCarbonDioxideLevel(): Promise<CharacteristicValue> {
return this.appliance.properties.reported.ECO2;
}

async update(appliance: Appliance) {
this.appliance = appliance;

this.carbonDioxideSensorService.updateCharacteristic(
this.platform.Characteristic.CarbonDioxideDetected, this.appliance.properties.reported.CO2 > this.platform.config.carbonDioxideSensorAlarmValue ?
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL :
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL
);
this.carbonDioxideSensorService.updateCharacteristic(
this.platform.Characteristic.CarbonDioxideLevel, this.appliance.properties.reported.CO2
);
}

}
51 changes: 51 additions & 0 deletions src/accessories/devices/airPurifier/wellA7.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
import { ElectroluxDevicesPlatform } from '../../../platform';
import { AirPurifier } from './airPurifier';
import { ElectroluxAccessoryController } from '../../controller';
import { Appliance } from '../../../definitions/appliance';

export class WellA7 extends AirPurifier {

private carbonDioxideSensorService: Service;

constructor(
readonly _platform: ElectroluxDevicesPlatform,
readonly _accessory: PlatformAccessory<ElectroluxAccessoryController>,
readonly _appliance: Appliance
) {
super(_platform, _accessory, _appliance);

this.carbonDioxideSensorService = this.accessory.getService(this.platform.Service.CarbonDioxideSensor) ||
this.accessory.addService(this.platform.Service.CarbonDioxideSensor);

this.carbonDioxideSensorService.getCharacteristic(this.platform.Characteristic.CarbonDioxideDetected)
.onGet(this.getCarbonDioxideDetected.bind(this));

this.carbonDioxideSensorService.getCharacteristic(this.platform.Characteristic.CarbonDioxideLevel)
.onGet(this.getCarbonDioxideLevel.bind(this));
}

async getCarbonDioxideDetected(): Promise<CharacteristicValue> {
return this.appliance.properties.reported.ECO2 > 1000 ?
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL :
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL;
}

async getCarbonDioxideLevel(): Promise<CharacteristicValue> {
return this.appliance.properties.reported.ECO2;
}

async update(appliance: Appliance) {
this.appliance = appliance;

this.carbonDioxideSensorService.updateCharacteristic(
this.platform.Characteristic.CarbonDioxideDetected, this.appliance.properties.reported.ECO2 > this.platform.config.carbonDioxideSensorAlarmValue ?
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_ABNORMAL :
this.platform.Characteristic.CarbonDioxideDetected.CO2_LEVELS_NORMAL
);
this.carbonDioxideSensorService.updateCharacteristic(
this.platform.Characteristic.CarbonDioxideLevel, this.appliance.properties.reported.ECO2
);
}

}
9 changes: 7 additions & 2 deletions src/const/devices.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Comfort600 } from '../accessories/devices/comfort600';
import { WellA7 } from '../accessories/devices/wellA7';
import { WellA7 } from '../accessories/devices/airPurifier/wellA7';
import { PureA9 } from '../accessories/devices/airPurifier/pureA9';

export const DEVICES = {
/* Air conditioners */
'Azul': Comfort600,
'WELLA7': WellA7

/* Air purifiers */
'WELLA7': WellA7,
'PUREA9': PureA9
};
9 changes: 7 additions & 2 deletions src/definitions/appliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ type ApplianceProperties = {
filterState: State;
ambientTemperatureC: number;

/* Well A7 */
/* Air purifiers */
Workmode: WorkMode;
Fanspeed: number;
Ionizer: boolean;
Expand All @@ -34,8 +34,13 @@ type ApplianceProperties = {
PM10: number;
Temp: number;
Humidity: number;
ECO2: number;
TVOC: number;

/* Well A7 */
ECO2: number;

/* Pure A9 */
CO2: number;
};

/* Comfort 600 */
Expand Down

0 comments on commit e68f96d

Please sign in to comment.