From 2fbf4b648f13ca489cf818d64dc364a8ee4adac1 Mon Sep 17 00:00:00 2001 From: Kevin Van den Abeele Date: Tue, 2 Jun 2020 20:30:36 +0200 Subject: [PATCH] homekit logic mostly working TODO: from off to heat or cool will not set mode TODO: Changing temp will not set actual temp --- src/lg-airco-accessory.ts | 13 ------------- src/lg/dummy-controller.ts | 6 ++++++ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/lg-airco-accessory.ts b/src/lg-airco-accessory.ts index 260d667..0224abb 100644 --- a/src/lg-airco-accessory.ts +++ b/src/lg-airco-accessory.ts @@ -147,10 +147,7 @@ export class LgAirCoolerAccessory implements AccessoryPlugin { } private handleActiveSet(value: CharacteristicValue, callback: CharacteristicSetCallback): void { - console.log('Setting ACTIVE: ' + value); if (!this.powerStateWillChange && !this.controller.isPoweredOn() === (value === this.hap.Characteristic.Active.ACTIVE)) { - console.log('SETTING POWERING BY COMMAND!'); - this.controller.setPowerState(value === this.hap.Characteristic.Active.ACTIVE); } else { this.powerStateWillChange = false; @@ -196,8 +193,6 @@ export class LgAirCoolerAccessory implements AccessoryPlugin { } private handleTargetHeaterCoolerStateSet(value: CharacteristicValue, callback: CharacteristicSetCallback): void { - console.log('Setting TARGET STATE: ' + value); - if (!this.controller.isPoweredOn()) { this.powerStateWillChange = true; } @@ -229,8 +224,6 @@ export class LgAirCoolerAccessory implements AccessoryPlugin { } private handleCoolingThresholdTemperatureSet(value: CharacteristicValue, callback: CharacteristicSetCallback): void { - console.log('Setting COOLING TEMP: ' + value); - if (!this.controller.isPoweredOn()) { this.powerStateWillChange = true; } @@ -246,8 +239,6 @@ export class LgAirCoolerAccessory implements AccessoryPlugin { } private handleHeatingThresholdTemperatureSet(value: CharacteristicValue, callback: CharacteristicSetCallback): void { - console.log('Setting HEATING TEMP: ' + value); - if (!this.controller.isPoweredOn()) { this.powerStateWillChange = true; } @@ -263,8 +254,6 @@ export class LgAirCoolerAccessory implements AccessoryPlugin { } private handleRotationSpeedSet(value: CharacteristicValue, callback: CharacteristicSetCallback): void { - console.log('Setting FAN SPEED: ' + value); - if (!this.controller.isPoweredOn()) { this.powerStateWillChange = true; } @@ -286,8 +275,6 @@ export class LgAirCoolerAccessory implements AccessoryPlugin { } private handleSwingModeSet(value: CharacteristicValue, callback: CharacteristicSetCallback): void { - console.log('Setting SWING MODE: ' + value); - if (!this.controller.isPoweredOn()) { this.powerStateWillChange = true; } diff --git a/src/lg/dummy-controller.ts b/src/lg/dummy-controller.ts index 1db8884..db1b3cb 100644 --- a/src/lg/dummy-controller.ts +++ b/src/lg/dummy-controller.ts @@ -29,6 +29,7 @@ export class DummyController extends Controller { public async setPowerState(powerOn: boolean): Promise { if (this.isOn !== powerOn) { this.isOn = powerOn; + console.log('Setting power value: ' + powerOn); } } @@ -40,6 +41,7 @@ export class DummyController extends Controller { if (this.mode !== newTargetMode) { this.isOn = true; this.mode = newTargetMode; + console.log('Setting mode value: ' + newTargetMode); await this.setTargetTemperatureInCelsius(this.mode === Mode.COOL ? this.targetCoolingTemperatureInCelsius : this.targetHeatingTemperatureInCelsius); } } @@ -74,6 +76,7 @@ export class DummyController extends Controller { if (this.targetTemperatureInCelsius !== newTargetTemperatureInCelsius) { this.isOn = true; this.targetTemperatureInCelsius = newTargetTemperatureInCelsius; + console.log('Setting temperature value: ' + newTargetTemperatureInCelsius); } } @@ -85,6 +88,7 @@ export class DummyController extends Controller { if (this.swingModeV !== newVerticalSwingMode) { this.isOn = true; this.swingModeV = newVerticalSwingMode; + console.log('Setting swing V value: ' + newVerticalSwingMode); } } @@ -96,6 +100,7 @@ export class DummyController extends Controller { if (this.swingModeH !== newHorizontalSwingMode) { this.isOn = true; this.swingModeH = newHorizontalSwingMode; + console.log('Setting swing H value: ' + newHorizontalSwingMode); } } @@ -107,6 +112,7 @@ export class DummyController extends Controller { if (this.fanSpeed !== newFanSpeed) { this.isOn = true; this.fanSpeed = newFanSpeed; + console.log('Setting fan speed value: ' + newFanSpeed); } } } \ No newline at end of file