From f934cad59ef3cea2f359f200c48ce4b4f9e2f3a4 Mon Sep 17 00:00:00 2001 From: Malene Trab Date: Tue, 10 Dec 2024 13:48:04 +0000 Subject: [PATCH] Fix deprecation warnings --- .devcontainer.json | 29 +++++++-------- custom_components/danfoss_ally/__init__.py | 10 +++-- custom_components/danfoss_ally/climate.py | 43 +++++++++------------- 3 files changed, 37 insertions(+), 45 deletions(-) diff --git a/.devcontainer.json b/.devcontainer.json index c224a87..8af5b71 100644 --- a/.devcontainer.json +++ b/.devcontainer.json @@ -1,16 +1,16 @@ { - "name": "ludeeus/integration_blueprint", - "image": "mcr.microsoft.com/devcontainers/base:ubuntu", - "postCreateCommand": "scripts/setup", - "appPort": [ - "9126:8123" - ], - "portsAttributes": { - "8123": { - "label": "Home Assistant - Danfoss Ally integration", - "onAutoForward": "notify" - } - }, + "name": "ludeeus/integration_blueprint", + "image": "mcr.microsoft.com/devcontainers/python:3.12-bullseye", + "postCreateCommand": "scripts/setup", + "appPort": [ + "9126:8123" + ], + "portsAttributes": { + "8123": { + "label": "Home Assistant - Danfoss Ally integration", + "onAutoForward": "notify" + } + }, "customizations": { "vscode": { "extensions": [ @@ -37,9 +37,6 @@ }, "remoteUser": "root", "features": { - "ghcr.io/devcontainers/features/rust:1": {}, - "ghcr.io/devcontainers/features/python:1": { - "version": "latest" - } + "ghcr.io/devcontainers/features/rust:1": {} } } \ No newline at end of file diff --git a/custom_components/danfoss_ally/__init__.py b/custom_components/danfoss_ally/__init__.py index 26ca6eb..522878d 100644 --- a/custom_components/danfoss_ally/__init__.py +++ b/custom_components/danfoss_ally/__init__.py @@ -156,10 +156,12 @@ async def _update(now): UPDATE_LISTENER: update_listener, } - for component in ALLY_COMPONENTS: - hass.async_create_task( - hass.config_entries.async_forward_entry_setup(entry, component) - ) + await hass.config_entries.async_forward_entry_setups(entry, ALLY_COMPONENTS) + + # for component in ALLY_COMPONENTS: + # hass.async_create_task( + # hass.config_entries.async_forward_entry_setups(entry, component) + # ) return True diff --git a/custom_components/danfoss_ally/climate.py b/custom_components/danfoss_ally/climate.py index fee4f17..8ca3e10 100644 --- a/custom_components/danfoss_ally/climate.py +++ b/custom_components/danfoss_ally/climate.py @@ -9,13 +9,6 @@ from homeassistant.components.climate.const import ( # SUPPORT_PRESET_MODE,; SUPPORT_TARGET_TEMPERATURE, ATTR_HVAC_MODE, ATTR_PRESET_MODE, - CURRENT_HVAC_HEAT, - CURRENT_HVAC_COOL, - CURRENT_HVAC_IDLE, - HVAC_MODE_AUTO, - HVAC_MODE_HEAT, - HVAC_MODE_COOL, - HVAC_MODE_OFF, HVACAction, PRESET_AWAY, PRESET_HOME, @@ -498,7 +491,7 @@ def __init__( @property def hvac_mode(self): """Return hvac operation ie. heat, cool mode. - Need to be one of HVAC_MODE_*. + Need to be one of HVACMode. """ if "mode" in self._device: if ( @@ -508,23 +501,23 @@ def hvac_mode(self): or self._device["mode"] == "holiday" or self._device["mode"] == "pause" ): - return HVAC_MODE_AUTO + return HVACMode.AUTO elif ( self._device["work_state"] == "Heat" or self._device["work_state"] == "heat_active" ): if self._device["manual_mode_fast"] == self._device["lower_temp"]: - return HVAC_MODE_OFF + return HVACMode.OFF else: - return HVAC_MODE_HEAT + return HVACMode.HEAT elif ( self._device["work_state"] == "Cool" or self._device["work_state"] == "cool_active" ): if self._device["manual_mode_fast"] == self._device["upper_temp"]: - return HVAC_MODE_OFF + return HVACMode.OFF else: - return HVAC_MODE_COOL + return HVACMode.COOL @callback def _async_update_callback(self): """Load data and update state.""" @@ -536,16 +529,16 @@ def set_hvac_mode(self, hvac_mode): _LOGGER.debug("Setting hvac mode to %s", hvac_mode) - if hvac_mode == HVAC_MODE_AUTO: + if hvac_mode == HVACMode.AUTO: mode = "at_home" # We have to choose either at_home or leaving_home manual_set = self._device["at_home_setting"] - elif hvac_mode == HVAC_MODE_HEAT: + elif hvac_mode == HVACMode.HEAT: mode = "manual" manual_set = self._device["leaving_home_setting"] - elif hvac_mode == HVAC_MODE_COOL: + elif hvac_mode == HVACMode.COOL: mode = "manual" manual_set = self._device["at_home_setting"] - elif hvac_mode == HVAC_MODE_OFF: + elif hvac_mode == HVACMode.OFF: mode = "manual" if ( self._device["work_state"] == "heat_active" @@ -580,14 +573,14 @@ def hvac_action(self): self._device["work_state"] == "Heat" or self._device["work_state"] == "heat_active" ): - return CURRENT_HVAC_HEAT + return HVACAction.HEATING elif ( self._device["work_state"] == "Cool" or self._device["work_state"] == "cool_active" ): - return CURRENT_HVAC_COOL + return HVACAction.COOLING elif self._device["output_status"] == False: - return CURRENT_HVAC_IDLE + return HVACAction.IDLE async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities @@ -652,13 +645,13 @@ def create_climate_entity(ally, name: str, device_id: str, model: str) -> AllyCl if model == "Icon RT": supported_hvac_modes = [ - HVAC_MODE_AUTO, - HVAC_MODE_HEAT, - HVAC_MODE_COOL, - HVAC_MODE_OFF, + HVACMode.AUTO, + HVACMode.HEAT, + HVACMode.COOL, + HVACMode.OFF, ] else: - supported_hvac_modes = [HVAC_MODE_AUTO, HVAC_MODE_HEAT] + supported_hvac_modes = [HVACMode.AUTO, HVACMode.HEAT] heat_min_temp = 4.5 heat_max_temp = 35.0