From 150764bc67099ea871a24665c905a1555e49008a Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Sat, 2 May 2020 17:47:04 +0200 Subject: [PATCH 1/4] Fix typing in component service method --- homeassistant/helpers/entity_component.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/helpers/entity_component.py b/homeassistant/helpers/entity_component.py index 0a7c52f70599e..fb7762fb9aec5 100644 --- a/homeassistant/helpers/entity_component.py +++ b/homeassistant/helpers/entity_component.py @@ -201,7 +201,7 @@ def async_register_entity_service( 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): From a6361360607e25b875d005654519d084774502ab Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Sat, 2 May 2020 17:47:39 +0200 Subject: [PATCH 2/4] Add required features to cover service registration --- homeassistant/components/cover/__init__.py | 27 +++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/cover/__init__.py b/homeassistant/components/cover/__init__.py index 84494e60c6ac3..ef17abc8a4076 100644 --- a/homeassistant/components/cover/__init__.py +++ b/homeassistant/components/cover/__init__.py @@ -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", + [SUPPORT_SET_POSITION], ) - component.async_register_entity_service(SERVICE_STOP_COVER, {}, "async_stop_cover") + component.async_register_entity_service( + SERVICE_STOP_COVER, {}, "async_stop_cover", [SUPPORT_STOP] + ) - component.async_register_entity_service(SERVICE_TOGGLE, {}, "async_toggle") + component.async_register_entity_service( + SERVICE_TOGGLE, {}, "async_toggle", [SUPPORT_OPEN | SUPPORT_CLOSE] + ) component.async_register_entity_service( - SERVICE_OPEN_COVER_TILT, {}, "async_open_cover_tilt" + SERVICE_OPEN_COVER_TILT, {}, "async_open_cover_tilt", [SUPPORT_OPEN_TILT] ) component.async_register_entity_service( - SERVICE_CLOSE_COVER_TILT, {}, "async_close_cover_tilt" + SERVICE_CLOSE_COVER_TILT, {}, "async_close_cover_tilt", [SUPPORT_CLOSE_TILT] ) component.async_register_entity_service( - SERVICE_STOP_COVER_TILT, {}, "async_stop_cover_tilt" + 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 From 67f459553ed8d12de10106a7eed4fb20434b8909 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Sun, 3 May 2020 02:39:07 +0200 Subject: [PATCH 3/4] Fix template cover tilt features --- homeassistant/components/template/cover.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/template/cover.py b/homeassistant/components/template/cover.py index cea91ea2963d2..e8bdebe2f58a5 100644 --- a/homeassistant/components/template/cover.py +++ b/homeassistant/components/template/cover.py @@ -297,7 +297,7 @@ def supported_features(self): 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 From 95d075cc43b69beb33d3a89b7bdd7353743c6367 Mon Sep 17 00:00:00 2001 From: Martin Hjelmare Date: Sun, 3 May 2020 02:39:31 +0200 Subject: [PATCH 4/4] Delint template cover tests --- tests/components/template/test_cover.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/components/template/test_cover.py b/tests/components/template/test_cover.py index c8caf28ddf6c5..095393c8acb83 100644 --- a/tests/components/template/test_cover.py +++ b/tests/components/template/test_cover.py @@ -30,8 +30,8 @@ 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")