Skip to content

Commit

Permalink
Merge pull request #190 from MTrab/Update-deprecated-constants
Browse files Browse the repository at this point in the history
Fix deprecation warnings
  • Loading branch information
MTrab authored Dec 10, 2024
2 parents ef82bc8 + f934cad commit 454f40d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 45 deletions.
29 changes: 13 additions & 16 deletions .devcontainer.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand All @@ -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": {}
}
}
10 changes: 6 additions & 4 deletions custom_components/danfoss_ally/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
43 changes: 18 additions & 25 deletions custom_components/danfoss_ally/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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 (
Expand All @@ -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."""
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 454f40d

Please sign in to comment.