From 1593bdf2e9cc4840a7dc3cbca843c98f10a023c9 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Wed, 20 May 2020 23:47:30 +0200 Subject: [PATCH] Add climate services required features (#35804) --- homeassistant/components/climate/__init__.py | 10 +++++++++- homeassistant/components/demo/climate.py | 4 ++-- tests/components/climate/test_init.py | 10 ++++++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/climate/__init__.py b/homeassistant/components/climate/__init__.py index d3241791cf2..32dfaa0e8fb 100644 --- a/homeassistant/components/climate/__init__.py +++ b/homeassistant/components/climate/__init__.py @@ -118,29 +118,37 @@ async def async_setup(hass: HomeAssistantType, config: ConfigType) -> bool: SERVICE_SET_PRESET_MODE, {vol.Required(ATTR_PRESET_MODE): cv.string}, "async_set_preset_mode", + [SUPPORT_PRESET_MODE], ) component.async_register_entity_service( SERVICE_SET_AUX_HEAT, {vol.Required(ATTR_AUX_HEAT): cv.boolean}, async_service_aux_heat, + [SUPPORT_AUX_HEAT], ) component.async_register_entity_service( - SERVICE_SET_TEMPERATURE, SET_TEMPERATURE_SCHEMA, async_service_temperature_set, + SERVICE_SET_TEMPERATURE, + SET_TEMPERATURE_SCHEMA, + async_service_temperature_set, + [SUPPORT_TARGET_TEMPERATURE, SUPPORT_TARGET_TEMPERATURE_RANGE], ) component.async_register_entity_service( SERVICE_SET_HUMIDITY, {vol.Required(ATTR_HUMIDITY): vol.Coerce(float)}, "async_set_humidity", + [SUPPORT_TARGET_HUMIDITY], ) component.async_register_entity_service( SERVICE_SET_FAN_MODE, {vol.Required(ATTR_FAN_MODE): cv.string}, "async_set_fan_mode", + [SUPPORT_FAN_MODE], ) component.async_register_entity_service( SERVICE_SET_SWING_MODE, {vol.Required(ATTR_SWING_MODE): cv.string}, "async_set_swing_mode", + [SUPPORT_SWING_MODE], ) return True diff --git a/homeassistant/components/demo/climate.py b/homeassistant/components/demo/climate.py index fd5615c82bd..57feae64a89 100644 --- a/homeassistant/components/demo/climate.py +++ b/homeassistant/components/demo/climate.py @@ -309,12 +309,12 @@ class DemoClimate(ClimateEntity): self._preset = preset_mode self.async_write_ha_state() - def turn_aux_heat_on(self): + async def async_turn_aux_heat_on(self): """Turn auxiliary heater on.""" self._aux = True self.async_write_ha_state() - def turn_aux_heat_off(self): + async def async_turn_aux_heat_off(self): """Turn auxiliary heater off.""" self._aux = False self.async_write_ha_state() diff --git a/tests/components/climate/test_init.py b/tests/components/climate/test_init.py index e42bf8c7e3c..89c12b4c517 100644 --- a/tests/components/climate/test_init.py +++ b/tests/components/climate/test_init.py @@ -65,6 +65,12 @@ class MockClimateEntity(ClimateEntity): """ return [HVAC_MODE_OFF, HVAC_MODE_HEAT] + def turn_on(self) -> None: + """Turn on.""" + + def turn_off(self) -> None: + """Turn off.""" + async def test_sync_turn_on(hass): """Test if async turn_on calls sync turn_on.""" @@ -92,9 +98,13 @@ def test_deprecated_base_class(caplog): """Test deprecated base class.""" class CustomClimate(ClimateDevice): + """Custom climate entity class.""" + + @property def hvac_mode(self): pass + @property def hvac_modes(self): pass