Skip to content

Commit

Permalink
setStateAsync
Browse files Browse the repository at this point in the history
  • Loading branch information
klein0r committed Nov 12, 2021
1 parent 225a0a8 commit 472b431
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
21 changes: 12 additions & 9 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Comfoairq extends utils.Adapter {
}

async onReady() {
this.setState('info.connection', false, true);
await this.setStateAsync('info.connection', false, true);

// Get active sensors by configuration
for (const key of Object.keys(this.config)) {
Expand Down Expand Up @@ -120,14 +120,17 @@ class Comfoairq extends utils.Adapter {
read: true,
write: false
},
native: {}
native: {
sensorId: sensorId
}
});
this.setState('sensor.' + sensorNameClean, {val: sensorValue, ack: true});

await this.setStateAsync('sensor.' + sensorNameClean, sensorValue, true);

} else if (data.kind == 68) { // 68 = VersionConfirm
this.setState('version.comfonet', {val: data.result.data.comfoNetVersion, ack: true});
this.setState('version.serial', {val: data.result.data.serialNumber, ack: true});
this.setState('version.gateway', {val: data.result.data.gatewayVersion, ack: true});
await this.setStateAsync('version.comfonet', data.result.data.comfoNetVersion, true);
await this.setStateAsync('version.serial', data.result.data.serialNumber, true);
await this.setStateAsync('version.gateway', data.result.data.gatewayVersion, true);
}
}
});
Expand All @@ -138,7 +141,7 @@ class Comfoairq extends utils.Adapter {
this.log.warn('Other session started: ' + JSON.stringify(reason));
}

this.setState('info.connection', false, true);
this.setStateAsync('info.connection', false, true);
});

this.log.debug('register the app...');
Expand All @@ -157,7 +160,7 @@ class Comfoairq extends utils.Adapter {

this.zehnder.VersionRequest();

this.setState('info.connection', true, true);
await this.setStateAsync('info.connection', true, true);
this.connected = true;
this.subscribeStates('*');
} else {
Expand Down Expand Up @@ -209,7 +212,7 @@ class Comfoairq extends utils.Adapter {
this.zehnder.CloseSession();
this.zehnder = null;

this.setState('info.connection', false, true);
this.setStateAsync('info.connection', false, true);

callback();
} catch (e) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

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

0 comments on commit 472b431

Please sign in to comment.