Skip to content

Commit

Permalink
Merge pull request #30 from Ernst79/default_import
Browse files Browse the repository at this point in the history
Fix import error
  • Loading branch information
Ernst79 authored Feb 19, 2024
2 parents 4cea9ea + 93e843d commit 674ec2e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
5 changes: 4 additions & 1 deletion custom_components/degree_days/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
entry.async_on_unload(entry.add_update_listener(update_listener))
return True


async def update_listener(hass: HomeAssistant, entry: ConfigEntry) -> None:
"""Update listener."""
await hass.config_entries.async_reload(entry.entry_id)


async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry):
"""Unload a config entry."""
return await hass.config_entries.async_unload_platforms(entry, PLATFORMS)


async def async_migrate_entry(hass, config_entry):
"""Migrate config entry to new version."""
if config_entry.version == 1:
Expand Down Expand Up @@ -81,7 +84,7 @@ def __init__(self, hass: HomeAssistant, entry: ConfigEntry) -> None:
CONF_STARTDAY: data.pop(CONF_STARTDAY, DEFAULT_STARTDAY),
CONF_STARTMONTH: data.pop(CONF_STARTMONTH, DEFAULT_STARTMONTH),
CONF_CONSUMPTION_SENSOR: data.pop(CONF_CONSUMPTION_SENSOR, DEFAULT_CONSUMPTION_SENSOR),
CONF_DHW_CONSUMPTION: data.pop(CONF_DHW_CONSUMPTION, DEFAULT_CONSUMPTION_USE_OTHER),
CONF_DHW_CONSUMPTION: data.pop(CONF_DHW_CONSUMPTION, DEFAULT_DHW_CONSUMPTION),
CONF_HEATPUMP: data.pop(CONF_HEATPUMP, DEFAULT_HEATPUMP),
}

Expand Down
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
2 changes: 1 addition & 1 deletion custom_components/degree_days/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
"iot_class": "cloud_polling",
"issue_tracker": "https://github.com/Ernst79/degree-days/issues",
"requirements": [],
"version": "1.1.0"
"version": "1.1.1"
}

0 comments on commit 674ec2e

Please sign in to comment.