Skip to content

Commit

Permalink
extract method
Browse files Browse the repository at this point in the history
  • Loading branch information
TA2k committed Nov 30, 2023
1 parent af8cf7c commit 1280ee8
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -4481,6 +4481,15 @@ class VwWeconnect extends utils.Adapter {
);
});
}
async setOtherStatesInChannelNull(channel, ts) {
const states = await this.getStatesAsync(channel + ".*");
const allIds = Object.keys(states);
for (const keyName of allIds) {
if (states[keyName] && states[keyName].ts < ts) {
await this.setStateAsync(keyName, null, true);
}
}
}

async setIsCarMoving(vin, isMoving) {
await this.setObjectNotExistsAsync(vin + ".position.isMoving", {
Expand Down Expand Up @@ -5914,7 +5923,7 @@ class VwWeconnect extends utils.Adapter {
});
await this.setStateAsync(vin + ".position.address." + key, body.address[key], true);
}
this.json2iob.setOtherStatesInChannelNull(vin + ".position.address", timestamp);
this.setOtherStatesInChannelNull(vin + ".position.address", timestamp);
} catch (err) {
this.log.error(err);
}
Expand Down

0 comments on commit 1280ee8

Please sign in to comment.