diff --git a/homeassistant/exceptions.py b/homeassistant/exceptions.py index e94d5fd6b57..81856f27c45 100644 --- a/homeassistant/exceptions.py +++ b/homeassistant/exceptions.py @@ -261,7 +261,6 @@ class ServiceNotFound(HomeAssistantError): """Initialize error.""" super().__init__( self, - f"Service {domain}.{service} not found.", translation_domain="homeassistant", translation_key="service_not_found", translation_placeholders={"domain": domain, "service": service}, diff --git a/tests/test_core.py b/tests/test_core.py index ad67adb78b9..f95a2104ff5 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1676,8 +1676,18 @@ async def test_serviceregistry_service_that_not_exists(hass: HomeAssistant) -> N await hass.async_block_till_done() assert len(calls_remove) == 0 - with pytest.raises(ServiceNotFound): + with pytest.raises(ServiceNotFound) as exc: await hass.services.async_call("test_do_not", "exist", {}) + assert exc.value.translation_domain == "homeassistant" + assert exc.value.translation_key == "service_not_found" + assert exc.value.translation_placeholders == { + "domain": "test_do_not", + "service": "exist", + } + assert exc.value.domain == "test_do_not" + assert exc.value.service == "exist" + + assert str(exc.value) == "Service test_do_not.exist not found." async def test_serviceregistry_async_service_raise_exception(