diff --git a/homeassistant/components/climate/nuheat.py b/homeassistant/components/climate/nuheat.py index 63369ed5769..ff1d1158ad1 100644 --- a/homeassistant/components/climate/nuheat.py +++ b/homeassistant/components/climate/nuheat.py @@ -175,6 +175,11 @@ class NuHeatThermostat(ClimateDevice): if not self.is_away_mode_on: return + self.resume_program() + self._force_update = True + + def resume_program(self): + """Resume the thermostat's programmed schedule.""" self._thermostat.resume_schedule() self._force_update = True diff --git a/tests/components/climate/test_nuheat.py b/tests/components/climate/test_nuheat.py index c1b86d5d9e1..83dbfac8449 100644 --- a/tests/components/climate/test_nuheat.py +++ b/tests/components/climate/test_nuheat.py @@ -36,6 +36,8 @@ class TestNuHeat(unittest.TestCase): target_celsius=22, target_fahrenheit=72) + thermostat.resume_schedule = Mock() + api = Mock() api.get_thermostat.return_value = thermostat @@ -171,6 +173,32 @@ class TestNuHeat(unittest.TestCase): self.thermostat.turn_away_mode_on() set_temp.assert_not_called() + @patch.object( + nuheat.NuHeatThermostat, "is_away_mode_on", new_callable=PropertyMock) + @patch.object(nuheat.NuHeatThermostat, "resume_program") + def test_turn_away_mode_off_home(self, resume, is_away_mode_on): + """Test turn away mode off when home.""" + is_away_mode_on.return_value = False + self.thermostat.turn_away_mode_off() + self.assertFalse(self.thermostat._force_update) + resume.assert_not_called() + + @patch.object( + nuheat.NuHeatThermostat, "is_away_mode_on", new_callable=PropertyMock) + @patch.object(nuheat.NuHeatThermostat, "resume_program") + def test_turn_away_mode_off_away(self, resume, is_away_mode_on): + """Test turn away mode off when away.""" + is_away_mode_on.return_value = True + self.thermostat.turn_away_mode_off() + self.assertTrue(self.thermostat._force_update) + resume.assert_called_once() + + def test_resume_program(self): + """Test resume schedule.""" + self.thermostat.resume_program() + self.thermostat._thermostat.resume_schedule.assert_called_once() + self.assertTrue(self.thermostat._force_update) + def test_set_temperature(self): """Test set temperature.""" self.thermostat.set_temperature(temperature=85)