Skip to content

Commit

Permalink
update for AUTO mode
Browse files Browse the repository at this point in the history
  • Loading branch information
CyrilP committed May 15, 2024
1 parent 26e567f commit c98f913
Showing 1 changed file with 34 additions and 27 deletions.
61 changes: 34 additions & 27 deletions custom_components/deltadore_tydom/ha_entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,25 +608,6 @@ class HaClimate(ClimateEntity, HAEntity):
"temperature": UnitOfTemperature.CELSIUS,
}

DICT_MODES_HA_TO_DD = {
HVACMode.AUTO: "ANTI_FROST",
HVACMode.COOL: "COOLING",
HVACMode.HEAT: "NORMAL",
HVACMode.OFF: "STOP",
HVACMode.FAN_ONLY: "VENTILATING",
HVACMode.DRY: "DRYING"
}
DICT_MODES_DD_TO_HA = {
"COOLING": HVACMode.COOL,
"ANTI_FROST": HVACMode.AUTO,
"NORMAL": HVACMode.HEAT,
"HEATING": HVACMode.HEAT,
"STOP": HVACMode.OFF,
"AUTO": HVACMode.AUTO,
"VENTILATING": HVACMode.FAN_ONLY,
"DRYING": HVACMode.DRY
}

def __init__(self, device: TydomBoiler, hass) -> None:
"""Initialize Climate."""
super().__init__()
Expand All @@ -637,6 +618,32 @@ def __init__(self, device: TydomBoiler, hass) -> None:
self._attr_name = self._device.device_name
self._enable_turn_on_off_backwards_compatibility = False

self.dict_modes_ha_to_dd = {
HVACMode.COOL: "COOLING",
HVACMode.HEAT: "NORMAL",
HVACMode.OFF: "STOP",
HVACMode.FAN_ONLY: "VENTILATING",
HVACMode.DRY: "DRYING"
}
self.dict_modes_dd_to_ha = {
"COOLING": HVACMode.COOL,
"ANTI_FROST": HVACMode.AUTO,
"NORMAL": HVACMode.HEAT,
"HEATING": HVACMode.HEAT,
"STOP": HVACMode.OFF,
"AUTO": HVACMode.AUTO,
"VENTILATING": HVACMode.FAN_ONLY,
"DRYING": HVACMode.DRY
}

if "hvacMode" in self._device._metadata and "AUTO" in self._device._metadata["hvacMode"]["enum_values"]:
self.dict_modes_ha_to_dd[HVACMode.AUTO] = "AUTO"
elif "hvacMode" in self._device._metadata and "ANTI_FROST" in self._device._metadata["hvacMode"]["enum_values"]:
self.dict_modes_ha_to_dd[HVACMode.AUTO] = "ANTI_FROST"
else:
self.dict_modes_ha_to_dd[HVACMode.AUTO] = "AUTO"


if hasattr(self._device, "minSetpoint"):
self._attr_min_temp = self._device.minSetpoint

Expand All @@ -651,7 +658,7 @@ def __init__(self, device: TydomBoiler, hass) -> None:
)

if "NORMAL" in self._device._metadata["thermicLevel"] and "AUTO" in self._device._metadata["thermicLevel"]:
self.DICT_MODES_HA_TO_DD[HVACMode.HEAT] = "AUTO"
self.dict_modes_ha_to_dd[HVACMode.HEAT] = "AUTO"

# self._attr_preset_modes = ["NORMAL", "STOP", "ANTI_FROST"]
self._attr_hvac_modes = [
Expand Down Expand Up @@ -695,14 +702,14 @@ def temperature_unit(self) -> str:
def hvac_mode(self) -> HVACMode:
"""Return the current operation (e.g. heat, cool, idle)."""
if hasattr(self._device, 'hvacMode'):
LOGGER.debug("hvac_mode = %s", self.DICT_MODES_DD_TO_HA[self._device.hvacMode])
return self.DICT_MODES_DD_TO_HA[self._device.hvacMode]
LOGGER.debug("hvac_mode = %s", self.dict_modes_dd_to_ha[self._device.hvacMode])
return self.dict_modes_dd_to_ha[self._device.hvacMode]
elif hasattr(self._device, 'authorization'):
LOGGER.debug("authorization = %s", self.DICT_MODES_DD_TO_HA[self._device.thermicLevel])
return self.DICT_MODES_DD_TO_HA[self._device.authorization]
LOGGER.debug("authorization = %s", self.dict_modes_dd_to_ha[self._device.thermicLevel])
return self.dict_modes_dd_to_ha[self._device.authorization]
elif hasattr(self._device, 'thermicLevel'):
LOGGER.debug("thermicLevel = %s", self.DICT_MODES_DD_TO_HA[self._device.thermicLevel])
return self.DICT_MODES_DD_TO_HA[self._device.thermicLevel]
LOGGER.debug("thermicLevel = %s", self.dict_modes_dd_to_ha[self._device.thermicLevel])
return self.dict_modes_dd_to_ha[self._device.thermicLevel]
else:
return None

Expand Down Expand Up @@ -742,7 +749,7 @@ def target_temperature(self) -> float | None:

async def async_set_hvac_mode(self, hvac_mode):
"""Set new target hvac mode."""
await self._device.set_hvac_mode(self.DICT_MODES_HA_TO_DD[hvac_mode])
await self._device.set_hvac_mode(self.dict_modes_ha_to_dd[hvac_mode])

async def async_set_preset_mode(self, preset_mode):
"""Set new target preset mode."""
Expand Down

0 comments on commit c98f913

Please sign in to comment.