Skip to content

Commit

Permalink
Log and do clearInverval only when it's needed
Browse files Browse the repository at this point in the history
  • Loading branch information
aivus committed Jun 12, 2022
1 parent 6df0d5a commit 891ea08
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions drivers/gree_cooper_hunter_hvac/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,12 @@ class GreeHVACDevice extends Homey.Device {
*/
_onConnect(client) {
this.log('[connect]', 'connected to', client.getDeviceId());
this.homey.clearInterval(this._reconnectInterval);
delete this._reconnectInterval;

if (this._reconnectInterval) {
this.homey.clearInterval(this._reconnectInterval);
delete this._reconnectInterval;
}

this.log('[connect]', 'mark device available');
this.setAvailable();
}
Expand Down Expand Up @@ -224,11 +228,15 @@ class GreeHVACDevice extends Homey.Device {
// turbo: 'off',
// powerSave: 'off' }

this.homey.clearInterval(this._reconnectInterval);
delete this._reconnectInterval;
if (this._reconnectInterval) {
this.homey.clearInterval(this._reconnectInterval);
delete this._reconnectInterval;
}

this.log('[update]', 'mark device available');
this.setAvailable();
if (!this.getAvailable()) {
this.log('[update]', 'mark device available');
this.setAvailable();
}

if (this._checkBoolPropertyChanged(updatedProperties, HVAC.PROPERTY.power, 'onoff')) {
const value = updatedProperties[HVAC.PROPERTY.power] === HVAC.VALUE.power.on;
Expand Down Expand Up @@ -501,6 +509,7 @@ class GreeHVACDevice extends Homey.Device {
this.client.setDebug(newSettings.enable_debug);
}
}

}

/**
Expand Down

0 comments on commit 891ea08

Please sign in to comment.