mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 17:27:52 +00:00
add ability to change the Nuheat thermostat hold mode
This commit is contained in:
parent
419ec7f7a7
commit
fb90dab471
@ -12,12 +12,12 @@ from homeassistant.components.climate import (
|
||||
SUPPORT_HOLD_MODE,
|
||||
SUPPORT_OPERATION_MODE,
|
||||
SUPPORT_TARGET_TEMPERATURE,
|
||||
STATE_AUTO,
|
||||
STATE_HEAT,
|
||||
STATE_IDLE)
|
||||
from homeassistant.components.nuheat import DATA_NUHEAT
|
||||
from homeassistant.const import (
|
||||
ATTR_TEMPERATURE,
|
||||
STATE_HOME,
|
||||
TEMP_CELSIUS,
|
||||
TEMP_FAHRENHEIT)
|
||||
from homeassistant.util import Throttle
|
||||
@ -31,7 +31,7 @@ ICON = "mdi:thermometer"
|
||||
MIN_TIME_BETWEEN_UPDATES = timedelta(minutes=5)
|
||||
|
||||
# Hold modes
|
||||
MODE_AUTO = STATE_HOME # Run device schedule
|
||||
MODE_AUTO = STATE_AUTO # Run device schedule
|
||||
MODE_HOLD_TEMPERATURE = "temperature"
|
||||
MODE_TEMPORARY_HOLD = "temporary_temperature"
|
||||
|
||||
@ -156,6 +156,20 @@ class NuHeatThermostat(ClimateDevice):
|
||||
self._thermostat.resume_schedule()
|
||||
self._force_update = True
|
||||
|
||||
def set_hold_mode(self, hold_mode, **kwargs):
|
||||
"""Update the hold mode of the thermostat."""
|
||||
if hold_mode == MODE_AUTO:
|
||||
schedule_mode = SCHEDULE_RUN
|
||||
|
||||
if hold_mode == MODE_HOLD_TEMPERATURE:
|
||||
schedule_mode = SCHEDULE_HOLD
|
||||
|
||||
if hold_mode == MODE_TEMPORARY_HOLD:
|
||||
schedule_mode = SCHEDULE_TEMPORARY_HOLD
|
||||
|
||||
self._thermostat.schedule_mode = schedule_mode
|
||||
self._force_update = True
|
||||
|
||||
def set_temperature(self, **kwargs):
|
||||
"""Set a new target temperature."""
|
||||
temperature = kwargs.get(ATTR_TEMPERATURE)
|
||||
|
@ -138,6 +138,20 @@ class TestNuHeat(unittest.TestCase):
|
||||
self.thermostat._thermostat.resume_schedule.assert_called_once_with()
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
|
||||
def test_set_hold_mode(self):
|
||||
"""Test set hold mode."""
|
||||
self.thermostat.set_hold_mode("temperature")
|
||||
self.assertEqual(self.thermostat._thermostat.schedule_mode, SCHEDULE_HOLD)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
|
||||
self.thermostat.set_hold_mode("temporary_temperature")
|
||||
self.assertEqual(self.thermostat._thermostat.schedule_mode, SCHEDULE_TEMPORARY_HOLD)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
|
||||
self.thermostat.set_hold_mode("auto")
|
||||
self.assertEqual(self.thermostat._thermostat.schedule_mode, SCHEDULE_RUN)
|
||||
self.assertTrue(self.thermostat._force_update)
|
||||
|
||||
def test_set_temperature(self):
|
||||
"""Test set temperature."""
|
||||
self.thermostat.set_temperature(temperature=85)
|
||||
|
Loading…
x
Reference in New Issue
Block a user