Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable energy save and air clean switches #295

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions config.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,16 @@
}
}
},
"ac_energy_save": {
"title": "Energy save as switch",
"type": "boolean",
"default": true
},
"ac_air_clean": {
"title": "Air purify as switch",
"type": "boolean",
"default": true
},
"ac_temperature_unit": {
"title": "Temperature Unit",
"type": "string",
Expand Down Expand Up @@ -328,6 +338,8 @@
"devices[].ac_temperature_sensor",
"devices[].ac_humidity_sensor",
"devices[].ac_fan_control",
"devices[].ac_energy_save",
"devices[].ac_air_clean",
"devices[].ac_temperature_unit",
{
"key": "devices[].ac_buttons",
Expand Down
40 changes: 30 additions & 10 deletions src/devices/AirConditioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,37 @@ export default class AirConditioner extends baseDevice {
}

if (this.energySaveModeModels.includes(device.model)) {
this.serviceEnergySaveMode = accessory.getService('Energy save') || accessory.addService(Switch, 'Energy save', 'Energy save');
this.serviceEnergySaveMode.updateCharacteristic(platform.Characteristic.Name, 'Energy save');
this.serviceEnergySaveMode.getCharacteristic(platform.Characteristic.On)
.onSet(this.setEnergySaveActive.bind(this));
this.serviceEnergySaveMode = accessory.getService('Energy save');

if (this.config.ac_energy_save as boolean) {
if (!this.serviceEnergySaveMode) {
accessory.addService(Switch, 'Energy save', 'Energy save');
}

this.serviceEnergySaveMode.updateCharacteristic(platform.Characteristic.Name, 'Energy save');
this.serviceEnergySaveMode.getCharacteristic(platform.Characteristic.On)
.onSet(this.setEnergySaveActive.bind(this));
} else if (this.serviceEnergySaveMode) {
accessory.removeService(this.serviceEnergySaveMode);
this.serviceEnergySaveMode = null;
}
}

if (this.airCleanModels.includes(device.model)) {
this.serviceAirClean = accessory.getService('Air Purify') || accessory.addService(Switch, 'Air Purify', 'Air Purify');
this.serviceAirClean.updateCharacteristic(platform.Characteristic.Name, 'Air Purify');
this.serviceAirClean.getCharacteristic(platform.Characteristic.On)
.onSet(this.setAirCleanActive.bind(this));
this.serviceAirClean = accessory.getService('Air Purify');

if (this.config.ac_air_clean as boolean) {
if (!this.serviceAirClean) {
accessory.addService(Switch, 'Air Purify', 'Air Purify');
}

this.serviceAirClean.updateCharacteristic(platform.Characteristic.Name, 'Air Purify');
this.serviceAirClean.getCharacteristic(platform.Characteristic.On)
.onSet(this.setAirCleanActive.bind(this));
} else if (this.serviceAirClean) {
accessory.removeService(this.serviceAirClean);
this.serviceAirClean = null;
}
}

this.setupButton(device);
Expand Down Expand Up @@ -347,11 +367,11 @@ export default class AirConditioner extends baseDevice {
this.serviceQuietMode.updateCharacteristic(Characteristic.On, !!device.snapshot['airState.miscFuncState.silentAWHP']);
}

if (this.energySaveModeModels.includes(device.model)) {
if (this.energySaveModeModels.includes(device.model) && this.config.ac_energy_save as boolean) {
this.serviceEnergySaveMode.updateCharacteristic(Characteristic.On, !!device.snapshot['airState.powerSave.basic']);
}

if (this.airCleanModels.includes(device.model)) {
if (this.airCleanModels.includes(device.model) && this.config.ac_air_clean as boolean) {
this.serviceAirClean.updateCharacteristic(Characteristic.On, !!device.snapshot['airState.wMode.airClean']);
}
}
Expand Down
Loading