diff --git a/README.md b/README.md index 381ada5..b48e25b 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Thermostat names can be changed in Uponor Smatrix app or via configuration. `switch.uponor_away` controls away mode. It activates ECO mode for all thermostat. -`switch.uponor_cooling_mode` activates cooling when switched on and heating mode when it's switched off. +`switch.uponor_cooling_mode` activates cooling mode when switched on and heating mode when it's switched off. This switch will be added only if cooling is available in your system. ## Configuration diff --git a/custom_components/uponor/__init__.py b/custom_components/uponor/__init__.py index bdd445c..d5e544e 100644 --- a/custom_components/uponor/__init__.py +++ b/custom_components/uponor/__init__.py @@ -127,13 +127,23 @@ def get_humidity(self, thermostat): # Temperature setpoint def get_setpoint(self, thermostat): + setback = 0 + var_setback = thermostat + '_eco_offset' + if var_setback in self._data and (self.is_eco(thermostat) or self.is_away()): + setback = int(self._data[var_setback]) + var = thermostat + '_setpoint' if var in self._data: - return math.floor((int(self._data[var]) - 320) / 1.8) / 10 + return math.floor((int(self._data[var]) - setback - 320) / 1.8) / 10 def set_setpoint(self, thermostat, temp): + setback = 0 + var_setback = thermostat + '_eco_offset' + if var_setback in self._data and (self.is_eco(thermostat) or self.is_away()): + setback = int(self._data[var_setback]) + var = thermostat + '_setpoint' - setpoint = int(temp * 18 + 320) + setpoint = int(temp * 18 + setback + 320) self._client.send_data({var: setpoint}) self._data[var] = setpoint async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE) @@ -221,7 +231,7 @@ def is_cool_enabled(self): if var in self._data: return self._data[var] == "1" - # Away mode + # Away & Eco def is_away(self): var = 'sys_forced_eco_mode' @@ -234,6 +244,11 @@ async def async_set_away(self, is_away): self._data[var] = data async_dispatcher_send(self._hass, SIGNAL_UPONOR_STATE_UPDATE) + def is_eco(self, thermostat): + var = thermostat + '_stat_cb_comfort_eco_mode' + var_temp = 'cust_Temporary_ECO_Activation' + return (var in self._data and self._data[var] == "1") or (var_temp in self._data and self._data[var_temp] == "1") + # Rest async def async_update(self, event_time): diff --git a/custom_components/uponor/climate.py b/custom_components/uponor/climate.py index 16ab4c7..f5b4a98 100644 --- a/custom_components/uponor/climate.py +++ b/custom_components/uponor/climate.py @@ -11,7 +11,12 @@ CURRENT_HVAC_HEAT, CURRENT_HVAC_COOL, CURRENT_HVAC_IDLE, + PRESET_AWAY, + PRESET_COMFORT, + PRESET_ECO, SUPPORT_TARGET_TEMPERATURE, + SUPPORT_PRESET_MODE + ) from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS @@ -69,7 +74,7 @@ def _update_callback(self): @property def supported_features(self): if self._is_on: - return SUPPORT_TARGET_TEMPERATURE + return SUPPORT_TARGET_TEMPERATURE | SUPPORT_PRESET_MODE return 0 @property @@ -102,6 +107,18 @@ def hvac_modes(self): return [HVAC_MODE_COOL, HVAC_MODE_OFF] return [HVAC_MODE_HEAT, HVAC_MODE_OFF] + @property + def preset_mode(self): + if self._state_proxy.is_eco(self._thermostat): + return PRESET_ECO + if self._state_proxy.is_away(): + return PRESET_AWAY + return PRESET_COMFORT + + @property + def preset_modes(self): + return [self.preset_mode] + @property def temperature_unit(self): return TEMP_CELSIUS