From c262a387dc83c2813c8cdf861fcb58b05a7b5b1b Mon Sep 17 00:00:00 2001 From: Derek Brooks Date: Wed, 6 Dec 2017 22:24:54 -0600 Subject: [PATCH] add supported_features functionality --- homeassistant/components/climate/nuheat.py | 12 ++++++++++++ tests/components/climate/test_nuheat.py | 14 +++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/climate/nuheat.py b/homeassistant/components/climate/nuheat.py index 696a6961cb3..ae3aff8c673 100644 --- a/homeassistant/components/climate/nuheat.py +++ b/homeassistant/components/climate/nuheat.py @@ -9,6 +9,10 @@ from datetime import timedelta from homeassistant.components.climate import ( ClimateDevice, + SUPPORT_AWAY_MODE, + SUPPORT_HOLD_MODE, + SUPPORT_OPERATION_MODE, + SUPPORT_TARGET_TEMPERATURE, STATE_HEAT, STATE_IDLE) from homeassistant.components.nuheat import DATA_NUHEAT @@ -39,6 +43,9 @@ SCHEDULE_HOLD = 3 SCHEDULE_RUN = 1 SCHEDULE_TEMPORARY_HOLD = 2 +SUPPORT_FLAGS = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_HOLD_MODE | + SUPPORT_AWAY_MODE | SUPPORT_OPERATION_MODE) + def setup_platform(hass, config, add_devices, discovery_info=None): """Set up the NuHeat thermostat(s).""" @@ -74,6 +81,11 @@ class NuHeatThermostat(ClimateDevice): """Return the icon to use in the frontend.""" return ICON + @property + def supported_features(self): + """Return the list of supported features.""" + return SUPPORT_FLAGS + @property def temperature_unit(self): """Return the unit of measurement.""" diff --git a/tests/components/climate/test_nuheat.py b/tests/components/climate/test_nuheat.py index 0b3b8c91ef4..a9946c49bce 100644 --- a/tests/components/climate/test_nuheat.py +++ b/tests/components/climate/test_nuheat.py @@ -2,7 +2,13 @@ import unittest from unittest.mock import PropertyMock, Mock, patch -from homeassistant.components.climate import STATE_HEAT, STATE_IDLE +from homeassistant.components.climate import ( + SUPPORT_AWAY_MODE, + SUPPORT_HOLD_MODE, + SUPPORT_OPERATION_MODE, + SUPPORT_TARGET_TEMPERATURE, + STATE_HEAT, + STATE_IDLE) import homeassistant.components.climate.nuheat as nuheat from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT @@ -73,6 +79,12 @@ class TestNuHeat(unittest.TestCase): """Test name property.""" self.assertEqual(self.thermostat.icon, "mdi:thermometer") + def test_supported_features(self): + """Test name property.""" + features = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_HOLD_MODE | + SUPPORT_AWAY_MODE | SUPPORT_OPERATION_MODE) + self.assertEqual(self.thermostat.supported_features, features) + def test_temperature_unit(self): """Test temperature unit.""" self.assertEqual(self.thermostat.temperature_unit, TEMP_FAHRENHEIT)