diff --git a/homeassistant/components/climate/nuheat.py b/homeassistant/components/climate/nuheat.py index fc49399c2cc..d49d060f032 100644 --- a/homeassistant/components/climate/nuheat.py +++ b/homeassistant/components/climate/nuheat.py @@ -151,9 +151,21 @@ class NuHeatThermostat(ClimateDevice): Return true if away mode is on. Away mode is determined by setting and HOLDing the target temperature - to the minimum temperature supported. + to the user-defined minimum away temperature or the minimum + temperature supported by the thermostat. """ - if self._thermostat.target_celsius > self._thermostat.min_celsius: + if self._min_away_temp: + if self._temperature_unit == "C": + min_target = self._min_away_temp + target = self._thermostat.target_celsius + else: + min_target = self._min_away_temp + target = self._thermostat.target_fahrenheit + + if target > min_target: + return False + + elif self._thermostat.target_celsius > self._thermostat.min_celsius: return False if self._thermostat.schedule_mode != SCHEDULE_HOLD: diff --git a/tests/components/climate/test_nuheat.py b/tests/components/climate/test_nuheat.py index ba0f6c8a6d6..558122dd366 100644 --- a/tests/components/climate/test_nuheat.py +++ b/tests/components/climate/test_nuheat.py @@ -137,13 +137,29 @@ class TestNuHeat(unittest.TestCase): def test_is_away_mode_on(self): """Test is away mode on.""" _thermostat = self.thermostat._thermostat - _thermostat.target_celsius = _thermostat.min_celsius _thermostat.schedule_mode = SCHEDULE_HOLD + + # user-defined minimum fahrenheit + self.thermostat._min_away_temp = 59 + _thermostat.target_fahrenheit = 59 self.assertTrue(self.thermostat.is_away_mode_on) + # user-defined minimum celsius + self.thermostat._temperature_unit = "C" + self.thermostat._min_away_temp = 15 + _thermostat.target_celsius = 15 + self.assertTrue(self.thermostat.is_away_mode_on) + + # thermostat's minimum supported temperature + self.thermostat._min_away_temp = None + _thermostat.target_celsius = _thermostat.min_celsius + self.assertTrue(self.thermostat.is_away_mode_on) + + # thermostat held at a temperature above the minimum _thermostat.target_celsius = _thermostat.min_celsius + 1 self.assertFalse(self.thermostat.is_away_mode_on) + # thermostat not on HOLD _thermostat.target_celsius = _thermostat.min_celsius _thermostat.schedule_mode = SCHEDULE_RUN self.assertFalse(self.thermostat.is_away_mode_on)