Climate component: add supported_features (#10658)

* Implement supported_features for the climate component

* Test supported features

* Convert generic thermostat to supported features

* Max / min temperature are not features

* Fix lint

* Min / max humidity are not features

* Linting

* Remove current temperature / humidity

* Move c-hacker-style constants to boring integers. Booo!

* Refactor all the climate platforms to use the new supported_features

* Force all climate platforms to implement supported_features

* Fix mistakes

* Adapt hive platform

* Move flags into a constant

* Calm the hound
This commit is contained in:
Lukas Barth authored and Pascal Vizeli committed 2017-11-29 11:01:28 +01:00
1 parent 59fa4f18e4
commit 373508693a
28 files changed
+370 -34

No files matched your search

+15 -1
View File
@@ -8,7 +8,10 @@ from homeassistant.util.unit_system import (
from homeassistant.setup import setup_component
from homeassistant.components import climate
from homeassistant.const import STATE_OFF
from homeassistant.components.climate import (
SUPPORT_OPERATION_MODE, SUPPORT_TARGET_TEMPERATURE,
SUPPORT_FAN_MODE, SUPPORT_SWING_MODE, SUPPORT_HOLD_MODE,
SUPPORT_AWAY_MODE, SUPPORT_AUX_HEAT)
from tests.common import (get_test_home_assistant, mock_mqtt_component,
fire_mqtt_message, mock_component)
@@ -51,6 +54,17 @@ class TestMQTTClimate(unittest.TestCase):
self.assertEqual("off", state.attributes.get('swing_mode'))
self.assertEqual("off", state.attributes.get('operation_mode'))
def test_supported_features(self):
"""Test the supported_features."""
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)
state = self.hass.states.get(ENTITY_CLIMATE)
support = (SUPPORT_TARGET_TEMPERATURE | SUPPORT_OPERATION_MODE |
SUPPORT_SWING_MODE | SUPPORT_FAN_MODE | SUPPORT_AWAY_MODE |
SUPPORT_HOLD_MODE | SUPPORT_AUX_HEAT)
self.assertEqual(state.attributes.get("supported_features"), support)
def test_get_operation_modes(self):
"""Test that the operation list returns the correct modes."""
assert setup_component(self.hass, climate.DOMAIN, DEFAULT_CONFIG)