diff --git a/homeassistant/components/thermostat/honeywell.py b/homeassistant/components/thermostat/honeywell.py index f45b07b9fd6..b31dfea0b4b 100644 --- a/homeassistant/components/thermostat/honeywell.py +++ b/homeassistant/components/thermostat/honeywell.py @@ -136,11 +136,20 @@ class RoundThermostat(ThermostatDevice): """Set new target temperature.""" self.device.set_temperature(self._name, temperature) + @property + def operation(self: ThermostatDevice) -> str: + """Get the current operation of the system.""" + return self.device.system_mode + @property def is_away_mode_on(self): """Return true if away mode is on.""" return self._away + def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None: + """Set the HVAC mode for the thermostat.""" + self.device.system_mode = hvac_mode + def turn_away_mode_on(self): """Turn away on. @@ -219,6 +228,11 @@ class HoneywellUSThermostat(ThermostatDevice): else: return self._device.setpoint_heat + @property + def operation(self: ThermostatDevice) -> str: + """Return current operation ie. heat, cool, idle.""" + return self._device.system_mode + def set_temperature(self, temperature): """Set target temperature.""" import somecomfort @@ -244,3 +258,7 @@ class HoneywellUSThermostat(ThermostatDevice): def turn_away_mode_off(self): """Turn away off.""" pass + + def set_hvac_mode(self: ThermostatDevice, hvac_mode: str) -> None: + """Set the system mode (Cool, Heat, etc).""" + self._device.system_mode = hvac_mode diff --git a/tests/components/thermostat/test_honeywell.py b/tests/components/thermostat/test_honeywell.py index 7a5b4c93a98..e4f75e508e5 100644 --- a/tests/components/thermostat/test_honeywell.py +++ b/tests/components/thermostat/test_honeywell.py @@ -277,6 +277,16 @@ class TestHoneywellRound(unittest.TestCase): self.round1.set_temperature(25) self.device.set_temperature.assert_called_once_with('House', 25) + def test_set_hvac_mode(self: unittest.TestCase) -> None: + """Test setting the system operation.""" + self.round1.set_hvac_mode('cool') + self.assertEqual('cool', self.round1.operation) + self.assertEqual('cool', self.device.system_mode) + + self.round1.set_hvac_mode('heat') + self.assertEqual('heat', self.round1.operation) + self.assertEqual('heat', self.device.system_mode) + class TestHoneywellUS(unittest.TestCase): """A test class for Honeywell US thermostats.""" @@ -327,6 +337,16 @@ class TestHoneywellUS(unittest.TestCase): self.assertEqual(74, self.device.setpoint_cool) self.assertEqual(74, self.honeywell.target_temperature) + def test_set_hvac_mode(self: unittest.TestCase) -> None: + """Test setting the HVAC mode.""" + self.honeywell.set_hvac_mode('cool') + self.assertEqual('cool', self.honeywell.operation) + self.assertEqual('cool', self.device.system_mode) + + self.honeywell.set_hvac_mode('heat') + self.assertEqual('heat', self.honeywell.operation) + self.assertEqual('heat', self.device.system_mode) + def test_set_temp_fail(self): """Test if setting the temperature fails.""" self.device.setpoint_heat = mock.MagicMock(