From 2432104f5fcbbb8235b618b4038b5dba0105116f Mon Sep 17 00:00:00 2001 From: G Johansson Date: Wed, 27 Aug 2025 18:09:01 +0000 Subject: [PATCH] Fix --- homeassistant/helpers/service.py | 4 +++- tests/helpers/test_entity_component.py | 3 ++- tests/helpers/test_entity_platform.py | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index d1d0f9bd378..beb9e233772 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -1134,7 +1134,9 @@ def async_register_entity_service( if schema is None or isinstance(schema, dict): schema = cv.make_entity_service_schema(schema) elif not cv.is_entity_service_schema(schema): - raise HomeAssistantError("The schema is not an entity service schema") + raise HomeAssistantError( + f"The {domain}.{name} service registers an entity service with a non entity service schema" + ) service_func: str | HassJob[..., Any] service_func = func if isinstance(func, str) else HassJob(func) diff --git a/tests/helpers/test_entity_component.py b/tests/helpers/test_entity_component.py index aa86215eea1..7ef02f05e08 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -564,7 +564,6 @@ async def test_register_entity_service_non_entity_service_schema( ) -> None: """Test attempting to register a service with a non entity service schema.""" component = EntityComponent(_LOGGER, DOMAIN, hass) - expected_message = "The schema is not an entity service schema" for idx, schema in enumerate( ( @@ -573,6 +572,7 @@ async def test_register_entity_service_non_entity_service_schema( vol.Any(vol.Schema({"some": str})), ) ): + expected_message = f"The test_domain.hello_{idx} service registers an entity service with a non entity service schema" with pytest.raises(HomeAssistantError, match=expected_message): component.async_register_entity_service(f"hello_{idx}", schema, Mock()) @@ -583,6 +583,7 @@ async def test_register_entity_service_non_entity_service_schema( vol.All(cv.make_entity_service_schema({"some": str})), ) ): + expected_message = f"The test_domain.hello_{idx} service registers an entity service with a non entity service schema" component.async_register_entity_service(f"test_service_{idx}", schema, Mock()) diff --git a/tests/helpers/test_entity_platform.py b/tests/helpers/test_entity_platform.py index 47f3857283a..ca466388f7c 100644 --- a/tests/helpers/test_entity_platform.py +++ b/tests/helpers/test_entity_platform.py @@ -1884,7 +1884,6 @@ async def test_register_entity_service_non_entity_service_schema( entity_platform = MockEntityPlatform( hass, domain="mock_integration", platform_name="mock_platform", platform=None ) - expected_message = "The schema is not an entity service schema" for idx, schema in enumerate( ( @@ -1893,6 +1892,7 @@ async def test_register_entity_service_non_entity_service_schema( vol.Any(vol.Schema({"some": str})), ) ): + expected_message = f"The mock_platform.hello_{idx} service registers an entity service with a non entity service schema" with pytest.raises(HomeAssistantError, match=expected_message): entity_platform.async_register_entity_service( f"hello_{idx}", schema, Mock() @@ -1905,6 +1905,7 @@ async def test_register_entity_service_non_entity_service_schema( vol.All(cv.make_entity_service_schema({"some": str})), ) ): + expected_message = f"The mock_platform.hello_{idx} service registers an entity service with a non entity service schema" entity_platform.async_register_entity_service( f"test_service_{idx}", schema, Mock() )