Add required features to cover service registration (#35073)

* Fix typing in component service method

* Add required features to cover service registration

* Fix template cover tilt features

* Delint template cover tests
pull/35156/head
Martin Hjelmare 2020-05-03 23:21:12 +02:00 committed by GitHub
parent b90cb09fd1
commit 39431c0764
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 17 deletions

View File

@ -94,10 +94,12 @@ async def async_setup(hass, config):
await component.async_setup(config)
component.async_register_entity_service(SERVICE_OPEN_COVER, {}, "async_open_cover")
component.async_register_entity_service(
SERVICE_OPEN_COVER, {}, "async_open_cover", [SUPPORT_OPEN]
)
component.async_register_entity_service(
SERVICE_CLOSE_COVER, {}, "async_close_cover"
SERVICE_CLOSE_COVER, {}, "async_close_cover", [SUPPORT_CLOSE]
)
component.async_register_entity_service(
@ -108,22 +110,27 @@ async def async_setup(hass, config):
)
},
"async_set_cover_position",
)
component.async_register_entity_service(SERVICE_STOP_COVER, {}, "async_stop_cover")
component.async_register_entity_service(SERVICE_TOGGLE, {}, "async_toggle")
component.async_register_entity_service(
SERVICE_OPEN_COVER_TILT, {}, "async_open_cover_tilt"
[SUPPORT_SET_POSITION],
)
component.async_register_entity_service(
SERVICE_CLOSE_COVER_TILT, {}, "async_close_cover_tilt"
SERVICE_STOP_COVER, {}, "async_stop_cover", [SUPPORT_STOP]
)
component.async_register_entity_service(
SERVICE_STOP_COVER_TILT, {}, "async_stop_cover_tilt"
SERVICE_TOGGLE, {}, "async_toggle", [SUPPORT_OPEN | SUPPORT_CLOSE]
)
component.async_register_entity_service(
SERVICE_OPEN_COVER_TILT, {}, "async_open_cover_tilt", [SUPPORT_OPEN_TILT]
)
component.async_register_entity_service(
SERVICE_CLOSE_COVER_TILT, {}, "async_close_cover_tilt", [SUPPORT_CLOSE_TILT]
)
component.async_register_entity_service(
SERVICE_STOP_COVER_TILT, {}, "async_stop_cover_tilt", [SUPPORT_STOP_TILT]
)
component.async_register_entity_service(
@ -134,10 +141,14 @@ async def async_setup(hass, config):
)
},
"async_set_cover_tilt_position",
[SUPPORT_SET_TILT_POSITION],
)
component.async_register_entity_service(
SERVICE_TOGGLE_COVER_TILT, {}, "async_toggle_tilt"
SERVICE_TOGGLE_COVER_TILT,
{},
"async_toggle_tilt",
[SUPPORT_OPEN_TILT | SUPPORT_CLOSE_TILT],
)
return True

View File

@ -297,7 +297,7 @@ class CoverTemplate(CoverEntity):
if self._position_script is not None:
supported_features |= SUPPORT_SET_POSITION
if self.current_cover_tilt_position is not None:
if self._tilt_script is not None:
supported_features |= TILT_FEATURES
return supported_features

View File

@ -201,7 +201,7 @@ class EntityComponent:
name: str,
schema: Union[Dict[str, Any], vol.Schema],
func: str,
required_features: Optional[int] = None,
required_features: Optional[List[int]] = None,
) -> None:
"""Register an entity service."""
if isinstance(schema, dict):

View File

@ -30,8 +30,8 @@ _LOGGER = logging.getLogger(__name__)
ENTITY_COVER = "cover.test_template_cover"
@pytest.fixture
def calls(hass):
@pytest.fixture(name="calls")
def calls_fixture(hass):
"""Track calls to a mock service."""
return async_mock_service(hass, "test", "automation")