diff --git a/custom_components/degree_days/__init__.py b/custom_components/degree_days/__init__.py index 3643860..e98d3d0 100644 --- a/custom_components/degree_days/__init__.py +++ b/custom_components/degree_days/__init__.py @@ -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: @@ -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), } diff --git a/custom_components/degree_days/knmi/__init__.py b/custom_components/degree_days/knmi/__init__.py index 2e8179d..e0a60d6 100644 --- a/custom_components/degree_days/knmi/__init__.py +++ b/custom_components/degree_days/knmi/__init__.py @@ -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.""" @@ -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 diff --git a/custom_components/degree_days/manifest.json b/custom_components/degree_days/manifest.json index 0a743ee..1c1eb0f 100644 --- a/custom_components/degree_days/manifest.json +++ b/custom_components/degree_days/manifest.json @@ -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" }