Honeywell hvac mode (#2757)
* Add set hvac mode to honeywell us thermostat * Add hvac service to the HoneywellRound entity * Fix pydoc * Add typing * Typing to unit test
This commit is contained in:
parent
5445aafee7
commit
7e37634b54
2 changed files with 38 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Add table
Reference in a new issue