Skip to content

Commit

Permalink
Merge pull request #1553 from LKuemmel/fix
Browse files Browse the repository at this point in the history
fix keyerror hc at midnight
  • Loading branch information
LKuemmel authored Apr 16, 2024
2 parents 41730a1 + 8e4aba2 commit 930e79e
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions packages/helpermodules/measurement_logging/process_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,12 +366,30 @@ def analyse_percentage_totals(entries, totals):


def _process_entries(entries: List, calculation: CalculationType):
if entries and len(entries) > 0:
for i in range(0, len(entries)-1):
entry = entries[i]
next_entry = entries[i+1]
entries[i] = process_entry(entry, next_entry, calculation)
entries.pop()
if entries:
if len(entries) == 1:
# Wenn es nur einen Eintrag gibt, kann keine Differenz berechnet werden und die Werte sind 0.
entry = entries[0]
for type in ("bat", "counter", "cp", "pv", "sh", "hc"):
if type in entry:
for module in entry[type].keys():
if calculation in [CalculationType.POWER, CalculationType.ALL]:
entry[type][module].update({
"power_average": 0,
"power_imported": 0,
"power_exported": 0
})
if calculation in [CalculationType.ENERGY, CalculationType.ALL]:
entry[type][module].update({
"energy_imported": 0,
"energy_exported": 0
})
elif len(entries) > 1:
for i in range(0, len(entries)-1):
entry = entries[i]
next_entry = entries[i+1]
entries[i] = process_entry(entry, next_entry, calculation)
entries.pop()
return entries


Expand Down

0 comments on commit 930e79e

Please sign in to comment.