diff --git a/config/configuration.yaml b/config/configuration.yaml index f993e4c..876ff00 100644 --- a/config/configuration.yaml +++ b/config/configuration.yaml @@ -369,39 +369,53 @@ climate: # cold_tolerance: 0.3 # hot_tolerance: 0.3 + # - platform: dual_smart_thermostat + # name: Edge Case 239 + # unique_id: edge_case_239 + # heater: switch.heater + # # cooler: switch.cooler + # target_sensor: sensor.room_temp + # 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 + # 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: Edge Case 239 - unique_id: edge_case_239 + name: Edge Case 289 + unique_id: edge_case_289 heater: switch.heater - # cooler: switch.cooler + cooler: switch.cooler target_sensor: sensor.room_temp - 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 + ac_mode: false min_temp: 16 - max_temp: 32 - cold_tolerance: 0.4 - hot_tolerance: 0.1 + max_temp: 30 + cold_tolerance: 1 + hot_tolerance: 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 + precision: 0.1 # - platform: dual_smart_thermostat # name: Edge Case 210 diff --git a/custom_components/dual_smart_thermostat/managers/environment_manager.py b/custom_components/dual_smart_thermostat/managers/environment_manager.py index 0b33703..1018d7c 100644 --- a/custom_components/dual_smart_thermostat/managers/environment_manager.py +++ b/custom_components/dual_smart_thermostat/managers/environment_manager.py @@ -765,14 +765,17 @@ def _set_temps_when_target_mode( self.target_temp = self.saved_target_temp # switching from preset NONE to NONE elif supports_temp_range: - if hvac_mode in [HVACMode.COOL, HVACMode.FAN_ONLY]: + if ( + hvac_mode in [HVACMode.COOL, HVACMode.FAN_ONLY] + and self.target_temp_high is not None + ): _LOGGER.debug( "Setting temperatures from no preset target mode. HVACMode.COOL, target temp: %s", self.target_temp, ) self.target_temp = self.target_temp_high - elif hvac_mode == HVACMode.HEAT: + elif hvac_mode == HVACMode.HEAT and self.target_temp_low is not None: _LOGGER.debug( "Setting temperatures from no preset target mode. HVACMode.HEAT, target temp: %s", self.target_temp, diff --git a/tests/test_dual_mode.py b/tests/test_dual_mode.py index 2ad8d90..8a61722 100644 --- a/tests/test_dual_mode.py +++ b/tests/test_dual_mode.py @@ -425,6 +425,25 @@ async def test_heat_cool_get_hvac_modes_fan_configured( ) +async def test_set_hvac_mode_chnage_trarget_temp( + hass: HomeAssistant, setup_comp_dual # noqa: F811 +) -> None: + """Test the changing of the hvac mode avoid invalid target temp.""" + await common.async_set_temperature(hass, 30) + state = hass.states.get(common.ENTITY) + assert state.attributes.get("temperature") == 30 + + await common.async_set_hvac_mode(hass, HVACMode.COOL) + await hass.async_block_till_done() + state = hass.states.get(common.ENTITY) + assert state.attributes.get("temperature") == 30 + + await common.async_set_hvac_mode(hass, HVACMode.HEAT) + await hass.async_block_till_done() + state = hass.states.get(common.ENTITY) + assert state.attributes.get("temperature") == 30 + + async def test_set_target_temp_dual( hass: HomeAssistant, setup_comp_dual # noqa: F811 ) -> None: