Skip to content

Commit

Permalink
Add setState
Browse files Browse the repository at this point in the history
Npm update
  • Loading branch information
Przemek Danysz committed Oct 6, 2024
1 parent 350e7e6 commit 3487743
Show file tree
Hide file tree
Showing 4 changed files with 1,523 additions and 1,101 deletions.
15 changes: 14 additions & 1 deletion io-package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
{
"common": {
"name": "kebahp",
"version": "0.1.1",
"version": "0.1.3",
"news": {
"0.1.3": {
"pl": "dodano obsługę wysyłki danych do KeBaHeatPump",
"en": "added sending data to KeBaHeatPump",
"de": "Daten werden gesendet",
"ru": "данные отправляются",
"pt": "dados enviados",
"nl": "gegevens worden verzonden",
"fr": "données envoyées",
"it": "dati inviati",
"es": "datos enviados",
"uk": "дані відправляються",
"zh-cn": "数据发送"
},
"0.1.1": {
"en": "fix version error",
"de": "fehler bei der ausführung",
Expand Down
10 changes: 10 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class Kebahp extends utils.Adapter {

this.on("ready", this.onReady.bind(this));
this.on("unload", this.onUnload.bind(this));
this.on("stateChange", this.onStateChange.bind(this));
}

/**
Expand Down Expand Up @@ -190,12 +191,21 @@ class Kebahp extends utils.Adapter {
* @param {ioBroker.State | null | undefined} state
*/
onStateChange(id, state) {
this.log.debug(`state ${id} changed: ${state?.val} (ack = ${state?.ack})`);

if (!this.apiClient) {
this.log.error("Apiclient not instanced.");
return;
}

if (state) {
// The state was changed
this.log.info(`state ${id} changed: ${state.val} (ack = ${state.ack})`);
this.setState(id, state.val);
} else {
// The state was deleted
this.log.info(`state ${id} deleted`);
this.setState(id, null);
}
}

Expand Down
Loading

0 comments on commit 3487743

Please sign in to comment.