Add climate services required features (#35804)

This commit is contained in:
Martin Hjelmare 2020-05-20 23:47:30 +02:00 committed by GitHub
parent 9907e95c34
commit 1593bdf2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 3 deletions

View file

@ -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

View file

@ -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()

View file

@ -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