Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix KeyError: 'all' hc at midnight #1553

Merged
merged 1 commit into from
Apr 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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