From 183f7a6edec4ffa70aa321b4bc887174faa900b4 Mon Sep 17 00:00:00 2001 From: Ahmed Abdellah Date: Thu, 30 May 2024 19:10:20 +0300 Subject: [PATCH 1/5] fix: AC accurate temperature update using control endpoint --- package-lock.json | 4 ++-- src/devices/AirConditioner.ts | 2 +- src/lib/API.ts | 4 ++-- src/lib/ThinQ.ts | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b4dc0d..4887fd2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "homebridge-lg-thinq", - "version": "1.8.1", + "version": "1.8.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "homebridge-lg-thinq", - "version": "1.8.1", + "version": "1.8.4", "funding": [ { "type": "paypal", diff --git a/src/devices/AirConditioner.ts b/src/devices/AirConditioner.ts index 87d262a..5443790 100644 --- a/src/devices/AirConditioner.ts +++ b/src/devices/AirConditioner.ts @@ -149,7 +149,7 @@ export default class AirConditioner extends baseDevice { this.platform.ThinQ?.deviceControl(device.id, { dataKey: 'airState.mon.timeout', dataValue: '70', - }, 'Set', 'allEventEnable').then(() => { + }, 'Set', 'allEventEnable', 'control').then(() => { // success }); }, 60000); diff --git a/src/lib/API.ts b/src/lib/API.ts index 461a369..a678b21 100644 --- a/src/lib/API.ts +++ b/src/lib/API.ts @@ -180,8 +180,8 @@ export class API { return this._homes; } - public async sendCommandToDevice(device_id: string, values: Record, command: 'Set' | 'Operation', ctrlKey = 'basicCtrl') { - return await this.postRequest('service/devices/' + device_id + '/control-sync', { + public async sendCommandToDevice(device_id: string, values: Record, command: 'Set' | 'Operation', ctrlKey = 'basicCtrl', ctrlPath = 'control-sync') { + return await this.postRequest('service/devices/' + device_id + '/' + ctrlPath, { ctrlKey, 'command': command, ...values, diff --git a/src/lib/ThinQ.ts b/src/lib/ThinQ.ts index 0c70c93..d6ffed2 100644 --- a/src/lib/ThinQ.ts +++ b/src/lib/ThinQ.ts @@ -171,9 +171,9 @@ export class ThinQ { }); } - public deviceControl(device: string | Device, values: Record, command: 'Set' | 'Operation' = 'Set', ctrlKey = 'basicCtrl') { + public deviceControl(device: string | Device, values: Record, command: 'Set' | 'Operation' = 'Set', ctrlKey = 'basicCtrl', ctrlPath = 'control-sync') { const id = device instanceof Device ? device.id : device; - return this.api.sendCommandToDevice(id, values, command, ctrlKey) + return this.api.sendCommandToDevice(id, values, command, ctrlKey, ctrlPath) .then(response => { if (response.resultCode === '0000') { this.log.debug('ThinQ Device Received the Command'); From 5759c9d5780a23b3cdd2e38d7274fb36b83c8bad Mon Sep 17 00:00:00 2001 From: Ahmed Abdellah Date: Thu, 30 May 2024 22:25:46 +0300 Subject: [PATCH 2/5] fix: Only send control requests for online ACs --- src/devices/AirConditioner.ts | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/devices/AirConditioner.ts b/src/devices/AirConditioner.ts index 5443790..f8e6bf5 100644 --- a/src/devices/AirConditioner.ts +++ b/src/devices/AirConditioner.ts @@ -146,12 +146,14 @@ export default class AirConditioner extends baseDevice { // send request every minute to update temperature // https://github.com/nVuln/homebridge-lg-thinq/issues/177 setInterval(() => { - this.platform.ThinQ?.deviceControl(device.id, { - dataKey: 'airState.mon.timeout', - dataValue: '70', - }, 'Set', 'allEventEnable', 'control').then(() => { - // success - }); + if (device.online) { + this.platform.ThinQ?.deviceControl(device.id, { + dataKey: 'airState.mon.timeout', + dataValue: '70', + }, 'Set', 'allEventEnable', 'control').then(() => { + // success + }); + } }, 60000); } From fe2fc8add97fc2b00a9e56265b32e4c8b4be15ea Mon Sep 17 00:00:00 2001 From: Ahmed Abdellah Date: Thu, 30 May 2024 23:17:46 +0300 Subject: [PATCH 3/5] fix: Set default threshold temperature step to 1 --- src/devices/AirConditioner.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/devices/AirConditioner.ts b/src/devices/AirConditioner.ts index f8e6bf5..1144e6e 100644 --- a/src/devices/AirConditioner.ts +++ b/src/devices/AirConditioner.ts @@ -663,7 +663,7 @@ export default class AirConditioner extends baseDevice { type: ValueType.Range, min: 0, max: 0, - step: 0.01, + step: 1, }; if (minRange && maxRange) { @@ -693,6 +693,7 @@ export default class AirConditioner extends baseDevice { const targetHeatTemperature = targetTemperature(tempHeatMinRange, tempHeatMaxRange); if (targetHeatTemperature) { + console.debug('targetHeatTemperature: ' + targetHeatTemperature.step); this.service.getCharacteristic(Characteristic.HeatingThresholdTemperature) .setProps({ minValue: this.Status.convertTemperatureCelsiusFromLGToHomekit(targetHeatTemperature.min), @@ -707,6 +708,7 @@ export default class AirConditioner extends baseDevice { const targetCoolTemperature = targetTemperature(tempCoolMinRange, tempCoolMaxRange); if (targetCoolTemperature) { + console.debug('targetCoolTemperature: ' + targetCoolTemperature.step); this.service.getCharacteristic(Characteristic.CoolingThresholdTemperature) .setProps({ minValue: this.Status.convertTemperatureCelsiusFromLGToHomekit(targetCoolTemperature.min), From 037b5d356349c4e5a87cc58a90702cdcb51bb6e6 Mon Sep 17 00:00:00 2001 From: Ahmed Abdellah Date: Thu, 30 May 2024 23:25:43 +0300 Subject: [PATCH 4/5] fix: Remove console statements --- src/devices/AirConditioner.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/devices/AirConditioner.ts b/src/devices/AirConditioner.ts index 1144e6e..b0aba8f 100644 --- a/src/devices/AirConditioner.ts +++ b/src/devices/AirConditioner.ts @@ -693,7 +693,6 @@ export default class AirConditioner extends baseDevice { const targetHeatTemperature = targetTemperature(tempHeatMinRange, tempHeatMaxRange); if (targetHeatTemperature) { - console.debug('targetHeatTemperature: ' + targetHeatTemperature.step); this.service.getCharacteristic(Characteristic.HeatingThresholdTemperature) .setProps({ minValue: this.Status.convertTemperatureCelsiusFromLGToHomekit(targetHeatTemperature.min), @@ -708,7 +707,6 @@ export default class AirConditioner extends baseDevice { const targetCoolTemperature = targetTemperature(tempCoolMinRange, tempCoolMaxRange); if (targetCoolTemperature) { - console.debug('targetCoolTemperature: ' + targetCoolTemperature.step); this.service.getCharacteristic(Characteristic.CoolingThresholdTemperature) .setProps({ minValue: this.Status.convertTemperatureCelsiusFromLGToHomekit(targetCoolTemperature.min), From b27b87271cd6ce512ee0c21a8360597dfcc4a602 Mon Sep 17 00:00:00 2001 From: Ahmed Abdellah Date: Mon, 3 Jun 2024 18:24:05 +0300 Subject: [PATCH 5/5] Revert "fix: Set default threshold temperature step to 1" This reverts commit fe2fc8add97fc2b00a9e56265b32e4c8b4be15ea. --- src/devices/AirConditioner.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devices/AirConditioner.ts b/src/devices/AirConditioner.ts index b0aba8f..f8e6bf5 100644 --- a/src/devices/AirConditioner.ts +++ b/src/devices/AirConditioner.ts @@ -663,7 +663,7 @@ export default class AirConditioner extends baseDevice { type: ValueType.Range, min: 0, max: 0, - step: 1, + step: 0.01, }; if (minRange && maxRange) {