diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index f9bb1effeb2..a3b64b5de15 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -957,7 +957,7 @@ class Entity(ABC): def __repr__(self) -> str: """Return the representation.""" - return f"" + return f"" async def async_request_call(self, coro: Coroutine[Any, Any, Any]) -> None: """Process request batched.""" diff --git a/tests/helpers/test_entity.py b/tests/helpers/test_entity.py index ac337b11b50..57f8ae03eaa 100644 --- a/tests/helpers/test_entity.py +++ b/tests/helpers/test_entity.py @@ -953,3 +953,18 @@ async def test_translation_key(hass): ) mock_entity2.entity_id = "hello.world" assert mock_entity2.translation_key == "from_entity_description" + + +async def test_repr_using_stringify_state(): + """Test that repr uses stringify state.""" + + class MyEntity(MockEntity): + """Mock entity.""" + + @property + def state(self): + """Return the state.""" + raise ValueError("Boom") + + entity = MyEntity(entity_id="test.test", available=False) + assert str(entity) == ""