diff --git a/custom_components/dual_smart_thermostat/climate.py b/custom_components/dual_smart_thermostat/climate.py index f912deb..95f8753 100644 --- a/custom_components/dual_smart_thermostat/climate.py +++ b/custom_components/dual_smart_thermostat/climate.py @@ -765,33 +765,8 @@ def extra_state_attributes(self) -> dict: if self.environment.saved_target_temp_high is not None: attributes[ATTR_PREV_TARGET_HIGH] = self.environment.saved_target_temp_high - # if self.environment.target_temp_low is not None: - # if self._attr_preset_mode != PRESET_NONE and self.features.is_range_mode: - # attributes[ATTR_PREV_TARGET_LOW] = ( - # self.environment.saved_target_temp_low - # ) - # else: - # attributes[ATTR_PREV_TARGET_LOW] = self.environment.target_temp_low - # if self.environment.target_temp_high is not None: - # if self._attr_preset_mode != PRESET_NONE and self.features.is_range_mode: - # attributes[ATTR_PREV_TARGET_HIGH] = ( - # self.environment.saved_target_temp_high - # ) - # else: - # attributes[ATTR_PREV_TARGET_HIGH] = self.environment.target_temp_high if self.environment.saved_target_temp is not None: attributes[ATTR_PREV_TARGET] = self.environment.saved_target_temp - # if self.environment.target_temp is not None: - # _LOGGER.debug( - # "Setting previous target temp: %s, %s, %s", - # self.environment.target_temp, - # self.environment.saved_target_temp, - # self._attr_preset_mode, - # ) - # if self._attr_preset_mode != PRESET_NONE and self.features.is_target_mode: - # attributes[ATTR_PREV_TARGET] = self.environment.saved_target_temp - # else: - # attributes[ATTR_PREV_TARGET] = self.environment.target_temp if self._cur_humidity is not None: attributes[ATTR_PREV_HUMIDITY] = self.environment.target_humidity @@ -1232,9 +1207,7 @@ async def async_set_preset_mode(self, preset_mode: str) -> None: _LOGGER.debug("Preset mode is the same, skipping") return - self.presets.set_preset_mode( - preset_mode, self.hvac_device.hvac_mode, self.hvac_device.hvac_modes - ) + self.presets.set_preset_mode(preset_mode) self._attr_preset_mode = self.presets.preset_mode diff --git a/custom_components/dual_smart_thermostat/managers/environment_manager.py b/custom_components/dual_smart_thermostat/managers/environment_manager.py index bb1b7d4..4fcb619 100644 --- a/custom_components/dual_smart_thermostat/managers/environment_manager.py +++ b/custom_components/dual_smart_thermostat/managers/environment_manager.py @@ -550,7 +550,6 @@ def set_humidity_from_preset(self, preset_mode: str, preset_env: PresetEnv) -> N if preset_mode == PRESET_NONE: if self.saved_target_humidity: self.target_humidity = self.saved_target_humidity - # self._environment.saved_target_humidity = self._environment.target_humidity else: if preset_env.to_dict[ATTR_HUMIDITY] is not None: @@ -634,7 +633,6 @@ def _set_temps_when_have_preset_mode( if preset_env.has_temp_range(): self.target_temp_low = preset_env.to_dict[ATTR_TARGET_TEMP_LOW] self.target_temp_high = preset_env.to_dict[ATTR_TARGET_TEMP_HIGH] - return else: _LOGGER.debug( @@ -673,7 +671,6 @@ def _set_temps_when_have_preset_mode( self._saved_target_temp, ) self.target_temp = self._saved_target_temp - return # handles when temperature is not set in preset but temp range is set else: diff --git a/custom_components/dual_smart_thermostat/managers/feature_manager.py b/custom_components/dual_smart_thermostat/managers/feature_manager.py index 91bedc5..4812dd2 100644 --- a/custom_components/dual_smart_thermostat/managers/feature_manager.py +++ b/custom_components/dual_smart_thermostat/managers/feature_manager.py @@ -229,9 +229,6 @@ def set_support_flags( self.environment.set_default_target_humidity() else: - # TODO: Preset based ltemperature logic should move to environment manager - if self.is_target_mode and preset_mode != PRESET_NONE: - self.environment.target_temp = self.environment.saved_target_temp self._supported_features = ( self._default_support_flags | ClimateEntityFeature.TARGET_TEMPERATURE_RANGE @@ -252,7 +249,9 @@ def set_support_flags( if self.is_configured_for_dryer_mode: self._supported_features |= ClimateEntityFeature.TARGET_HUMIDITY - def apply_old_state(self, old_state: State, hvac_mode, presets) -> None: + def apply_old_state( + self, old_state: State | None, hvac_mode: HVACMode | None = None, presets=[] + ) -> None: if old_state is None: return diff --git a/custom_components/dual_smart_thermostat/managers/preset_manager.py b/custom_components/dual_smart_thermostat/managers/preset_manager.py index b63295e..e9e217e 100644 --- a/custom_components/dual_smart_thermostat/managers/preset_manager.py +++ b/custom_components/dual_smart_thermostat/managers/preset_manager.py @@ -5,7 +5,6 @@ ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, PRESET_NONE, - HVACMode, ) from homeassistant.const import ATTR_TEMPERATURE from homeassistant.core import State @@ -115,9 +114,7 @@ def _get_preset_modes_from_config( ) return presets - def set_preset_mode( - self, preset_mode: str, hvac_mode: HVACMode, hvac_modes: list[HVACMode] - ) -> None: + def set_preset_mode(self, preset_mode: str) -> None: """Set new preset mode.""" _LOGGER.debug("Setting preset mode: %s", preset_mode) if preset_mode not in (self.preset_modes or []): @@ -131,20 +128,14 @@ def set_preset_mode( # if preset_mode == self._preset_mode we still need to continue # to set the target environment to the preset mode if preset_mode == PRESET_NONE: - self._set_presets_when_no_preset_mode() + self._preset_mode = PRESET_NONE + self._preset_env = PresetEnv() else: - self._set_presets_when_have_preset_mode(preset_mode, hvac_mode, hvac_modes) + self._set_presets_when_have_preset_mode(preset_mode) _LOGGER.debug("Preset env set: %s", self._preset_env) - def _set_presets_when_no_preset_mode(self): - """Sets target environment when preset is none.""" - self._preset_mode = PRESET_NONE - self._preset_env = PresetEnv() - - def _set_presets_when_have_preset_mode( - self, preset_mode: str, hvac_mode: HVACMode, hvac_modes: list[HVACMode] - ): + def _set_presets_when_have_preset_mode(self, preset_mode: str): """Sets target temperatures when have preset is not none.""" _LOGGER.debug("Setting presets when have preset mode") if self._features.is_range_mode: