add supported_features functionality

This commit is contained in:
Derek Brooks 2017-12-06 22:24:54 -06:00
parent 36d5fff8e0
commit c262a387dc
2 changed files with 25 additions and 1 deletions

View File

@ -9,6 +9,10 @@ from datetime import timedelta
from homeassistant.components.climate import ( from homeassistant.components.climate import (
ClimateDevice, ClimateDevice,
SUPPORT_AWAY_MODE,
SUPPORT_HOLD_MODE,
SUPPORT_OPERATION_MODE,
SUPPORT_TARGET_TEMPERATURE,
STATE_HEAT, STATE_HEAT,
STATE_IDLE) STATE_IDLE)
from homeassistant.components.nuheat import DATA_NUHEAT from homeassistant.components.nuheat import DATA_NUHEAT
@ -39,6 +43,9 @@ SCHEDULE_HOLD = 3
SCHEDULE_RUN = 1 SCHEDULE_RUN = 1
SCHEDULE_TEMPORARY_HOLD = 2 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): def setup_platform(hass, config, add_devices, discovery_info=None):
"""Set up the NuHeat thermostat(s).""" """Set up the NuHeat thermostat(s)."""
@ -74,6 +81,11 @@ class NuHeatThermostat(ClimateDevice):
"""Return the icon to use in the frontend.""" """Return the icon to use in the frontend."""
return ICON return ICON
@property
def supported_features(self):
"""Return the list of supported features."""
return SUPPORT_FLAGS
@property @property
def temperature_unit(self): def temperature_unit(self):
"""Return the unit of measurement.""" """Return the unit of measurement."""

View File

@ -2,7 +2,13 @@
import unittest import unittest
from unittest.mock import PropertyMock, Mock, patch 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 import homeassistant.components.climate.nuheat as nuheat
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
@ -73,6 +79,12 @@ class TestNuHeat(unittest.TestCase):
"""Test name property.""" """Test name property."""
self.assertEqual(self.thermostat.icon, "mdi:thermometer") 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): def test_temperature_unit(self):
"""Test temperature unit.""" """Test temperature unit."""
self.assertEqual(self.thermostat.temperature_unit, TEMP_FAHRENHEIT) self.assertEqual(self.thermostat.temperature_unit, TEMP_FAHRENHEIT)