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 import error #30

Merged
merged 2 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
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
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"
}
Loading