diff --git a/config/configuration.yaml b/config/configuration.yaml index bb14458..b4566f8 100644 --- a/config/configuration.yaml +++ b/config/configuration.yaml @@ -336,25 +336,59 @@ climate: # precision: 0.1 # target_temp_step: 0.5 + # - platform: dual_smart_thermostat + # name: Edge Case 181 + # unique_id: edge_case_181 + # heater: switch.heater + # cooler: switch.cooler + # fan: switch.fan + # target_sensor: sensor.room_temp + # floor_sensor: sensor.floor_temp + # heat_cool_mode: true + # max_floor_temp: 26 + # min_floor_temp: 10 + # fan_hot_tolerance: 0.7 + # target_temp_step: 0.1 + # precision: 0.1 + # min_temp: 9 + # max_temp: 32 + # target_temp: 20 + # cold_tolerance: 0.3 + # hot_tolerance: 0.3 + - platform: dual_smart_thermostat - name: Edge Case 181 - unique_id: edge_case_181 + name: Edge Case 239 + unique_id: edge_case_239 heater: switch.heater - cooler: switch.cooler - fan: switch.fan + # cooler: switch.cooler target_sensor: sensor.room_temp - floor_sensor: sensor.floor_temp - heat_cool_mode: true - max_floor_temp: 26 - min_floor_temp: 10 - fan_hot_tolerance: 0.7 - target_temp_step: 0.1 - precision: 0.1 - min_temp: 9 + heat_cool_mode: false #true # <-important + keep_alive: #lo attivo e commento initial_hvac_mode per verificare se mantiene lo stato al riavvio + minutes: 2 + ac_mode: true + min_temp: 16 max_temp: 32 - target_temp: 20 - cold_tolerance: 0.3 - hot_tolerance: 0.3 + cold_tolerance: 0.4 + hot_tolerance: 0.1 + target_temp_step: 0.1 + min_cycle_duration: + minutes: 1 + away: + temperature: 28.0 + target_temp_low: 27 + target_temp_high: 29.5 + home: + temperature: 23.0 + target_temp_low: 22.5 + target_temp_high: 23.5 + comfort: + temperature: 25.0 + target_temp_low: 24 + target_temp_high: 25.5 + sleep: + temperature: 27.5 + target_temp_low: 26.5 + target_temp_high: 28.0 - platform: dual_smart_thermostat name: Dual Humidity diff --git a/custom_components/dual_smart_thermostat/climate.py b/custom_components/dual_smart_thermostat/climate.py index 2582c73..2560fa1 100644 --- a/custom_components/dual_smart_thermostat/climate.py +++ b/custom_components/dual_smart_thermostat/climate.py @@ -733,6 +733,11 @@ def extra_state_attributes(self) -> dict: else: attributes[ATTR_PREV_TARGET_HIGH] = self.environment.target_temp_high if self._target_temp is not None: + _LOGGER.debug( + "Setting previous target temp: %s, %s", + self.environment.target_temp, + self.environment.saved_target_temp, + ) if self._attr_preset_mode != PRESET_NONE and self.features.is_target_mode: attributes[ATTR_PREV_TARGET] = self.environment.saved_target_temp else: diff --git a/custom_components/dual_smart_thermostat/managers/environment_manager.py b/custom_components/dual_smart_thermostat/managers/environment_manager.py index 1cb15d7..b9908f6 100644 --- a/custom_components/dual_smart_thermostat/managers/environment_manager.py +++ b/custom_components/dual_smart_thermostat/managers/environment_manager.py @@ -187,6 +187,7 @@ def saved_target_temp(self) -> float: @saved_target_temp.setter def saved_target_temp(self, temp: float) -> None: + _LOGGER.debug("Setting saved target temp: %s", temp) self._saved_target_temp = temp @property @@ -569,8 +570,12 @@ def apply_old_state(self, old_state: State) -> None: if old_target is None: _LOGGER.info("No previous target temperature") old_target = old_state.attributes.get(ATTR_TEMPERATURE) + # fix issues caused by old version saving target as dict + if isinstance(old_target, dict): + old_target = old_target.get(ATTR_TEMPERATURE) if old_target is not None: _LOGGER.info("Restoring previous target temperature: %s", old_target) + self._target_temp = float(old_target) self._max_floor_temp = ( diff --git a/custom_components/dual_smart_thermostat/managers/preset_manager.py b/custom_components/dual_smart_thermostat/managers/preset_manager.py index 93b1111..439a80a 100644 --- a/custom_components/dual_smart_thermostat/managers/preset_manager.py +++ b/custom_components/dual_smart_thermostat/managers/preset_manager.py @@ -95,8 +95,17 @@ def __init__( ) # sets the target environment to the preset mode - self._environment.saved_target_temp = self._environment.target_temp or next( - iter(presets.values()), None + _LOGGER.debug( + "Setting target temp when no preset mode, %s, %s", + self._environment.target_temp, + next(iter(presets.values())), + ) + + first_preset = next(iter(presets.values()), None) + preset_temperature = first_preset.get(ATTR_TEMPERATURE) + + self._environment.saved_target_temp = ( + self._environment.target_temp or preset_temperature or None ) @property @@ -171,6 +180,10 @@ def _set_presets_when_have_preset_mode(self, preset_mode: str, hvac_mode: HVACMo self._environment.target_temp_high = self._presets_range[preset_mode][1] else: if self._preset_mode == PRESET_NONE: + _LOGGER.debug( + "Saving target temp when target and no preset: %s", + self._environment.target_temp, + ) self._environment.saved_target_temp = self._environment.target_temp # handles when temperature is set in preset if self._presets[preset_mode].get(ATTR_TEMPERATURE) is not None: