Skip to content

Commit

Permalink
fix tests, prevent crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
Apollon77 committed Nov 25, 2023
1 parent 710376b commit 387945b
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions smartmeter.js
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ async function storeObisData(err, obisResult) {
setConnected(true);
let updateCount = 0;
for (const obisId in obisResult) {
if (stopInProgress) return;
if (!obisResult.hasOwnProperty(obisId)) continue;

adapter.log.debug(obisResult[obisId].idToString() + ': ' + SmartmeterObis.ObisNames.resolveObisName(obisResult[obisId], adapter.config.obisNameLanguage).obisName + ' = ' + obisResult[obisId].valueToString());
Expand Down Expand Up @@ -436,6 +437,7 @@ async function storeObisData(err, obisResult) {

if (obisResult[obisId].getValueLength() > 1) {
for (i = 1; i < obisResult[obisId].getValueLength(); i++) {
if (stopInProgress) return;
adapter.log.debug('Create State ' + ioChannelId + '.value' + (i + 1));
try {
await adapter.setObjectNotExistsAsync(ioChannelId + '.value' + (i + 1), {
Expand Down Expand Up @@ -469,6 +471,7 @@ async function storeObisData(err, obisResult) {

if (obisResult[obisId].getValueLength() > 1) {
for (i = 1; i < obisResult[obisId].getValueLength(); i++) {
if (stopInProgress) return;
adapter.log.debug('Set State '+ ioChannelId + '.value' + (i + 1) + ' = ' + obisResult[obisId].getValue(i).value);
await adapter.setStateAsync(ioChannelId + '.value' + (i + 1), {ack: true, val: obisResult[obisId].getValue(i).value});
}
Expand Down

0 comments on commit 387945b

Please sign in to comment.