Skip to content

Commit e4be1ab

Browse files
authored
Merge pull request #292 from aabdellah/fix_update-ac-temp
Fix the frequency of AC temperature update
2 parents b9afead + b27b872 commit e4be1ab

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/devices/AirConditioner.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@ export default class AirConditioner extends baseDevice {
146146
// send request every minute to update temperature
147147
// https://github.com/nVuln/homebridge-lg-thinq/issues/177
148148
setInterval(() => {
149-
this.platform.ThinQ?.deviceControl(device.id, {
150-
dataKey: 'airState.mon.timeout',
151-
dataValue: '70',
152-
}, 'Set', 'allEventEnable').then(() => {
153-
// success
154-
});
149+
if (device.online) {
150+
this.platform.ThinQ?.deviceControl(device.id, {
151+
dataKey: 'airState.mon.timeout',
152+
dataValue: '70',
153+
}, 'Set', 'allEventEnable', 'control').then(() => {
154+
// success
155+
});
156+
}
155157
}, 60000);
156158
}
157159

src/lib/API.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,8 @@ export class API {
180180
return this._homes;
181181
}
182182

183-
public async sendCommandToDevice(device_id: string, values: Record<string, any>, command: 'Set' | 'Operation', ctrlKey = 'basicCtrl') {
184-
return await this.postRequest('service/devices/' + device_id + '/control-sync', {
183+
public async sendCommandToDevice(device_id: string, values: Record<string, any>, command: 'Set' | 'Operation', ctrlKey = 'basicCtrl', ctrlPath = 'control-sync') {
184+
return await this.postRequest('service/devices/' + device_id + '/' + ctrlPath, {
185185
ctrlKey,
186186
'command': command,
187187
...values,

src/lib/ThinQ.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@ export class ThinQ {
171171
});
172172
}
173173

174-
public deviceControl(device: string | Device, values: Record<string, any>, command: 'Set' | 'Operation' = 'Set', ctrlKey = 'basicCtrl') {
174+
public deviceControl(device: string | Device, values: Record<string, any>, command: 'Set' | 'Operation' = 'Set', ctrlKey = 'basicCtrl', ctrlPath = 'control-sync') {
175175
const id = device instanceof Device ? device.id : device;
176-
return this.api.sendCommandToDevice(id, values, command, ctrlKey)
176+
return this.api.sendCommandToDevice(id, values, command, ctrlKey, ctrlPath)
177177
.then(response => {
178178
if (response.resultCode === '0000') {
179179
this.log.debug('ThinQ Device Received the Command');

0 commit comments

Comments
 (0)