Skip to content

Commit

Permalink
Merge pull request #292 from aabdellah/fix_update-ac-temp
Browse files Browse the repository at this point in the history
Fix the frequency of AC temperature update
  • Loading branch information
nVuln authored Jun 3, 2024
2 parents b9afead + b27b872 commit e4be1ab
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions src/devices/AirConditioner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
4 changes: 2 additions & 2 deletions src/lib/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,8 @@ export class API {
return this._homes;
}

public async sendCommandToDevice(device_id: string, values: Record<string, any>, command: 'Set' | 'Operation', ctrlKey = 'basicCtrl') {
return await this.postRequest('service/devices/' + device_id + '/control-sync', {
public async sendCommandToDevice(device_id: string, values: Record<string, any>, command: 'Set' | 'Operation', ctrlKey = 'basicCtrl', ctrlPath = 'control-sync') {
return await this.postRequest('service/devices/' + device_id + '/' + ctrlPath, {
ctrlKey,
'command': command,
...values,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/ThinQ.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ export class ThinQ {
});
}

public deviceControl(device: string | Device, values: Record<string, any>, command: 'Set' | 'Operation' = 'Set', ctrlKey = 'basicCtrl') {
public deviceControl(device: string | Device, values: Record<string, any>, 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');
Expand Down

0 comments on commit e4be1ab

Please sign in to comment.