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..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').then(() => { - // success - }); + if (device.online) { + this.platform.ThinQ?.deviceControl(device.id, { + dataKey: 'airState.mon.timeout', + dataValue: '70', + }, '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');