Skip to content

Commit

Permalink
Fixed warning on unload()
Browse files Browse the repository at this point in the history
  • Loading branch information
DEV2DEV-DE committed Nov 29, 2023
1 parent 5d202d5 commit fbbb46e
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Jablotron extends utils.Adapter {
name: 'jablotron',
});

this.connected = false;
this.isConnected = false;
this.sessionId = '';
this.timeout = undefined;
this.states = [];
Expand All @@ -47,15 +47,15 @@ class Jablotron extends utils.Adapter {
* Getter for the connected property.
* @returns {boolean} The connection status.
*/
get connected() {
return this._connected || false;
get isConnected() {
return this._isConnected || false;
}
/**
* Setter for the connected property.
* @param {boolean} value - The new value for the connected property.
*/
set connected(value) {
this._connected = value;
set isConnected(value) {
this._isConnected = value;
this.setState('info.connection', { val: value, ack: true });
}

Expand All @@ -73,10 +73,10 @@ class Jablotron extends utils.Adapter {
if (!this.config.username || !this.config.password) throw new Error('Username and password are mandatory');

this.sessionId = await this.fetchSessionId(this.config.username, this.config.password);
this.connected = this.sessionId !== '';
this.isConnected = this.sessionId !== '';

// create interval for recurring tasks
if (this.connected) {
if (this.isConnected) {
this.log.debug('Setting up recurring refresh');
this.recurringRefresh();
// subscribe to all state changes
Expand All @@ -86,7 +86,7 @@ class Jablotron extends utils.Adapter {
}
} catch (error) {
this.log.error('Error in onReady: ' + error);
this.connected = false;
this.isConnected = false;
}

}
Expand Down Expand Up @@ -118,7 +118,7 @@ class Jablotron extends utils.Adapter {
}
} catch (error) {
this.log.error(error);
this.connected = false;
this.isConnected = false;
return '';
}
}
Expand Down Expand Up @@ -348,10 +348,10 @@ class Jablotron extends utils.Adapter {
* Is called when adapter shuts down - callback has to be called under any circumstances!
* @param {() => void} callback
*/
onUnload(callback) {
async onUnload(callback) {
try {
await this.setState('info.connection', { val: false, ack: true });
if (this.timeout) this.clearTimeout(this.timeout);
this.connected = false;
callback();
} catch (e) {
callback();
Expand Down

0 comments on commit fbbb46e

Please sign in to comment.