Skip to content

Commit 7f4d06b

Browse files
author
NoBl
committed
fixed div/0
1 parent 4598118 commit 7f4d06b

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

main.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,10 @@ class Senec extends utils.Adapter {
547547
if (period == api_trans["THIS_YEAR"].dp) await this.insertAllTimeHistory(system, key, new Date(obj.aggregation.startzeitpunkt).getFullYear(), Number((value.wert).toFixed(0)), value.einheit);
548548
}
549549
}
550-
const autarky = Number((((obj.aggregation.stromerzeugung.wert - obj.aggregation.netzeinspeisung.wert - obj.aggregation.speicherbeladung.wert + obj.aggregation.speicherentnahme.wert) / obj.aggregation.stromverbrauch.wert) * 100).toFixed(2));
551-
await this.doState(pfx + "Autarkie", autarky, "", "%", false);
550+
if (obj.aggregation.stromverbrauch.wert != 0) {
551+
const autarky = Number((((obj.aggregation.stromerzeugung.wert - obj.aggregation.netzeinspeisung.wert - obj.aggregation.speicherbeladung.wert + obj.aggregation.speicherentnahme.wert) / obj.aggregation.stromverbrauch.wert) * 100).toFixed(2));
552+
await this.doState(pfx + "Autarkie", autarky, "", "%", false);
553+
}
552554
await this.updateAllTimeHistory(system);
553555
}
554556

@@ -593,8 +595,10 @@ class Senec extends utils.Adapter {
593595
await this.doState(pfx + key, Number(sum.toFixed(0)), "", einheit, false);
594596
}
595597
}
596-
const autarky = Number((((sums.stromerzeugung - sums.netzeinspeisung - sums.speicherbeladung + sums.speicherentnahme) / sums.stromverbrauch) * 100).toFixed(0));
597-
await this.doState(pfx + "Autarkie", autarky, "", "%", false);
598+
if (sums.stromverbrauch != 0) {
599+
const autarky = Number((((sums.stromerzeugung - sums.netzeinspeisung - sums.speicherbeladung + sums.speicherentnahme) / sums.stromverbrauch) * 100).toFixed(0));
600+
await this.doState(pfx + "Autarkie", autarky, "", "%", false);
601+
}
598602
}
599603

600604
/**

0 commit comments

Comments
 (0)