Skip to content

Commit

Permalink
Merge branch 'master' into fix/air_conditioner_auto_mode
Browse files Browse the repository at this point in the history
  • Loading branch information
tomekkleszcz authored Mar 11, 2024
2 parents 695a123 + a15cdc7 commit e7d39e5
Show file tree
Hide file tree
Showing 13 changed files with 507 additions and 251 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

# Homebridge Electrolux Devices

![NPM Downloads](https://img.shields.io/npm/dm/homebridge-electrolux-devices)
![NPM Version](https://img.shields.io/npm/v/homebridge-electrolux-devices)
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/tomekkleszcz/homebridge-electrolux-devices/tests.yml?label=tests)

This is a plugin for connecting Electrolux devices which are controlled by the [Electrolux](https://apps.apple.com/pl/app/electrolux/id1595816832) app to Homekit.

## 🧰 Installation
Expand All @@ -19,6 +23,7 @@ This is a plugin for connecting Electrolux devices which are controlled by the [
- Comfort 600 air conditioner
- Well A7 air purifier
- Pure A9/AX 9 air purifier
- UltimateHome 500 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. 😄

Expand Down
32 changes: 0 additions & 32 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,6 @@
"required": true,
"default": ""
},
"region": {
"title": "Region",
"type": "string",
"required": true,
"default": "eu",
"oneOf": [
{
"title": "Europe",
"enum": ["eu"]
},
{
"title": "United States",
"enum": ["us"]
},
{
"title": "Australia",
"enum": ["au"]
},
{
"title": "Russia",
"enum": ["ru"]
},
{
"title": "China",
"enum": ["cn"]
},
{
"title": "Israel",
"enum": ["il"]
}
]
},
"pollingInterval": {
"title": "Polling interval",
"type": "number",
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.9",
"version": "0.1.2",
"description": "Homebridge plugin for Electrolux devices",
"license": "Apache-2.0",
"repository": {
Expand Down
163 changes: 0 additions & 163 deletions src/accessories/devices/airPurifier/airPurifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,9 @@ import { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
import { ElectroluxDevicesPlatform } from '../../../platform';
import { Appliance, FilterType } from '../../../definitions/appliance';
import { ElectroluxAccessoryController } from '../../controller';
import { tvocPPBToVocDensity } from '../../../util/voc';

export class AirPurifier extends ElectroluxAccessoryController {
private airPurifierService: Service;
private ionizerService: Service;
private airQualityService: Service;
private humiditySensorService: Service;
private temperatureSensorService: Service;
private particleFilterService?: Service;

constructor(
Expand Down Expand Up @@ -107,80 +102,6 @@ export class AirPurifier extends ElectroluxAccessoryController {
)
);

this.ionizerService =
this.accessory.getService(this.platform.Service.Switch) ||
this.accessory.addService(this.platform.Service.Switch);

this.ionizerService.setCharacteristic(
this.platform.Characteristic.Name,
'Ionizer'
);

this.ionizerService
.getCharacteristic(this.platform.Characteristic.On)
.onGet(this.getCharacteristicValueGuard(this.getIonizer.bind(this)))
.onSet(
this.setCharacteristicValueGuard(this.setIonizer.bind(this))
);

this.airQualityService =
this.accessory.getService(this.platform.Service.AirQualitySensor) ||
this.accessory.addService(this.platform.Service.AirQualitySensor);

this.airQualityService
.getCharacteristic(this.platform.Characteristic.AirQuality)
.onGet(
this.getCharacteristicValueGuard(this.getAirQuality.bind(this))
);

this.airQualityService
.getCharacteristic(this.platform.Characteristic.PM2_5Density)
.onGet(
this.getCharacteristicValueGuard(
this.getPM2_5Density.bind(this)
)
);

this.airQualityService
.getCharacteristic(this.platform.Characteristic.PM10Density)
.onGet(
this.getCharacteristicValueGuard(this.getPM10Density.bind(this))
);

this.airQualityService
.getCharacteristic(this.platform.Characteristic.VOCDensity)
.onGet(
this.getCharacteristicValueGuard(this.getVOCDensity.bind(this))
);

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

this.humiditySensorService
.getCharacteristic(
this.platform.Characteristic.CurrentRelativeHumidity
)
.onGet(
this.getCharacteristicValueGuard(
this.getCurrentRelativeHumidity.bind(this)
)
);

this.temperatureSensorService =
this.accessory.getService(
this.platform.Service.TemperatureSensor
) ||
this.accessory.addService(this.platform.Service.TemperatureSensor);

this.temperatureSensorService
.getCharacteristic(this.platform.Characteristic.CurrentTemperature)
.onGet(
this.getCharacteristicValueGuard(
this.getCurrentTemperature.bind(this)
)
);

if (
this.appliance.properties.reported.FilterType_1 ===
FilterType.ParticleFilter ||
Expand Down Expand Up @@ -378,58 +299,6 @@ export class AirPurifier extends ElectroluxAccessoryController {
this.appliance.properties.reported.Fanspeed = value as number;
}

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

async setIonizer(value: CharacteristicValue) {
await this.sendCommand({
Ionizer: value
});

this.appliance.properties.reported.Ionizer = value as boolean;
}

async getAirQuality(): Promise<CharacteristicValue> {
if (this.appliance.properties.reported.PM2_5 <= 25) {
return this.platform.Characteristic.AirQuality.EXCELLENT;
} else if (this.appliance.properties.reported.PM2_5 <= 50) {
return this.platform.Characteristic.AirQuality.GOOD;
} else if (this.appliance.properties.reported.PM2_5 <= 75) {
return this.platform.Characteristic.AirQuality.FAIR;
} else if (this.appliance.properties.reported.PM2_5 <= 100) {
return this.platform.Characteristic.AirQuality.INFERIOR;
} else {
return this.platform.Characteristic.AirQuality.POOR;
}
}

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

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

async getVOCDensity(): Promise<CharacteristicValue> {
const vocDensity = tvocPPBToVocDensity(
this.appliance.properties.reported.TVOC,
this.appliance.properties.reported.Temp,
this._platform.config.vocMolecularWeight ?? 30.026
);

return vocDensity;
}

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

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

async getParticleFilterChangeIndication(): Promise<CharacteristicValue> {
const filterLife =
this.appliance.properties.reported.FilterType_1 ===
Expand Down Expand Up @@ -513,38 +382,6 @@ export class AirPurifier extends ElectroluxAccessoryController {
this.appliance.properties.reported.Fanspeed
);

this.ionizerService.updateCharacteristic(
this.platform.Characteristic.On,
this.appliance.properties.reported.Ionizer ? 1 : 0
);

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
);

const filterLife =
this.appliance.properties.reported.FilterType_1 ===
FilterType.ParticleFilter
Expand Down
Loading

0 comments on commit e7d39e5

Please sign in to comment.