diff --git a/homeassistant/helpers/service.py b/homeassistant/helpers/service.py index f9c846c60fa..d1d0f9bd378 100644 --- a/homeassistant/helpers/service.py +++ b/homeassistant/helpers/service.py @@ -1134,13 +1134,7 @@ 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): - from .frame import ReportBehavior, report_usage # noqa: PLC0415 - - report_usage( - "registers an entity service with a non entity service schema", - core_behavior=ReportBehavior.LOG, - breaks_in_ha_version="2025.9", - ) + raise HomeAssistantError("The schema is not an 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 20c243d0701..aa86215eea1 100644 --- a/tests/helpers/test_entity_component.py +++ b/tests/helpers/test_entity_component.py @@ -560,11 +560,11 @@ async def test_register_entity_service( async def test_register_entity_service_non_entity_service_schema( - hass: HomeAssistant, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, ) -> None: """Test attempting to register a service with a non entity service schema.""" component = EntityComponent(_LOGGER, DOMAIN, hass) - expected_message = "registers an entity service with a non entity service schema" + expected_message = "The schema is not an entity service schema" for idx, schema in enumerate( ( @@ -573,9 +573,8 @@ async def test_register_entity_service_non_entity_service_schema( vol.Any(vol.Schema({"some": str})), ) ): - component.async_register_entity_service(f"hello_{idx}", schema, Mock()) - assert expected_message in caplog.text - caplog.clear() + with pytest.raises(HomeAssistantError, match=expected_message): + component.async_register_entity_service(f"hello_{idx}", schema, Mock()) for idx, schema in enumerate( ( @@ -585,7 +584,6 @@ async def test_register_entity_service_non_entity_service_schema( ) ): component.async_register_entity_service(f"test_service_{idx}", schema, Mock()) - assert expected_message not in caplog.text async def test_register_entity_service_response_data(hass: HomeAssistant) -> None: diff --git a/tests/helpers/test_entity_platform.py b/tests/helpers/test_entity_platform.py index 53331b676fe..47f3857283a 100644 --- a/tests/helpers/test_entity_platform.py +++ b/tests/helpers/test_entity_platform.py @@ -1878,13 +1878,13 @@ async def test_register_entity_service_none_schema( async def test_register_entity_service_non_entity_service_schema( - hass: HomeAssistant, caplog: pytest.LogCaptureFixture + hass: HomeAssistant, ) -> None: """Test attempting to register a service with a non entity service schema.""" entity_platform = MockEntityPlatform( hass, domain="mock_integration", platform_name="mock_platform", platform=None ) - expected_message = "registers an entity service with a non entity service schema" + expected_message = "The schema is not an entity service schema" for idx, schema in enumerate( ( @@ -1893,9 +1893,10 @@ async def test_register_entity_service_non_entity_service_schema( vol.Any(vol.Schema({"some": str})), ) ): - entity_platform.async_register_entity_service(f"hello_{idx}", schema, Mock()) - assert expected_message in caplog.text - caplog.clear() + with pytest.raises(HomeAssistantError, match=expected_message): + entity_platform.async_register_entity_service( + f"hello_{idx}", schema, Mock() + ) for idx, schema in enumerate( ( @@ -1907,7 +1908,6 @@ async def test_register_entity_service_non_entity_service_schema( entity_platform.async_register_entity_service( f"test_service_{idx}", schema, Mock() ) - assert expected_message not in caplog.text @pytest.mark.parametrize("update_before_add", [True, False])