Skip to content

Commit

Permalink
fix KeyError
Browse files Browse the repository at this point in the history
  • Loading branch information
Ernst79 committed Feb 19, 2024
1 parent db2ef67 commit 93e843d
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions custom_components/degree_days/knmi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,11 @@ def __init__(self, startdate, station, T_indoor, T_heatinglimit, total_consumpti
self.total_degree_days_this_year = data["total_degree_days_this_year"]
self.weighted_degree_days_year = data["weighted_degree_days_year"]
if self.heatpump:
if self.total_consumption:
self.energy_consumption_per_weighted_degree_day = data["consumption_per_weighted_degree_day"]
self.energy_consumption_prognose = data["consumption_prognose"]
else:
self.energy_consumption_per_weighted_degree_day = None
self.energy_consumption_prognose = None
self.energy_consumption_per_weighted_degree_day = data["consumption_per_weighted_degree_day"]
self.energy_consumption_prognose = data["consumption_prognose"]
else:
if self.total_consumption:
self.gas_per_weighted_degree_day = data["consumption_per_weighted_degree_day"]
self.gas_prognose = data["consumption_prognose"]
else:
self.gas_per_weighted_degree_day = None
self.gas_prognose = None
self.gas_per_weighted_degree_day = data["consumption_per_weighted_degree_day"]
self.gas_prognose = data["consumption_prognose"]

def get_degree_days(self):
"""Calculate degree days."""
Expand Down Expand Up @@ -105,6 +97,9 @@ def get_degree_days(self):

data["consumption_per_weighted_degree_day"] = consumption_per_weighted_degree_day
data["consumption_prognose"] = consumption_prognose
else:
data["consumption_per_weighted_degree_day"] = None
data["consumption_prognose"] = None

return data

Expand Down

0 comments on commit 93e843d

Please sign in to comment.