Raise if referenced entity does not support service (#68394)

This commit is contained in:
Paulus Schoutsen 2022-03-20 16:01:58 -07:00 committed by GitHub
parent 0cbc29caca
commit 8bbbd1947d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 105 additions and 90 deletions

View file

@ -527,7 +527,7 @@ def async_set_service_schema(
@bind_hass
async def entity_service_call(
async def entity_service_call( # noqa: C901
hass: HomeAssistant,
platforms: Iterable[EntityPlatform],
func: str | Callable[..., Any],
@ -646,6 +646,12 @@ async def entity_service_call(
for feature_set in required_features
)
):
# If entity explicitly referenced, raise an error
if referenced is not None and entity.entity_id in referenced.referenced:
raise HomeAssistantError(
f"Entity {entity.entity_id} does not support this service."
)
continue
entities.append(entity)