Skip to content
This repository has been archived by the owner on Oct 30, 2021. It is now read-only.

Commit

Permalink
homekit logic mostly working
Browse files Browse the repository at this point in the history
TODO: from off to heat or cool will not set mode
TODO: Changing temp will not set actual temp
  • Loading branch information
Kevin Van den Abeele committed Jun 2, 2020
1 parent 35e0c4a commit 2fbf4b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
13 changes: 0 additions & 13 deletions src/lg-airco-accessory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
6 changes: 6 additions & 0 deletions src/lg/dummy-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export class DummyController extends Controller {
public async setPowerState(powerOn: boolean): Promise<void> {
if (this.isOn !== powerOn) {
this.isOn = powerOn;
console.log('Setting power value: ' + powerOn);
}
}

Expand All @@ -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);
}
}
Expand Down Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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);
}
}
}

0 comments on commit 2fbf4b6

Please sign in to comment.