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 testspull/35156/head
parent
b90cb09fd1
commit
39431c0764
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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):
|
||||
|
|
|
@ -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")
|
||||
|
||||
|
|
Loading…
Reference in New Issue