From 056b06de13caa79e894043bb142adda01b5fbf0e Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 2 Jan 2024 11:35:16 +0100 Subject: [PATCH] Don't use entity_id in __repr__ of not added entity (#106861) --- homeassistant/helpers/entity.py | 2 +- tests/helpers/test_entity.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/homeassistant/helpers/entity.py b/homeassistant/helpers/entity.py index b7ed7e3c095..3c3c8474e67 100644 --- a/homeassistant/helpers/entity.py +++ b/homeassistant/helpers/entity.py @@ -1481,7 +1481,7 @@ class Entity( If the entity is not added to a platform it's not safe to call _stringify_state. """ if self._platform_state != EntityPlatformState.ADDED: - return f"" + return f"" return f"" async def async_request_call(self, coro: Coroutine[Any, Any, _T]) -> _T: diff --git a/tests/helpers/test_entity.py b/tests/helpers/test_entity.py index 4fca7ed4c23..a18d8963947 100644 --- a/tests/helpers/test_entity.py +++ b/tests/helpers/test_entity.py @@ -1407,7 +1407,7 @@ async def test_repr(hass) -> None: my_entity = MyEntity(entity_id="test.test", available=False) # Not yet added - assert str(my_entity) == "" + assert str(my_entity) == "" # Added await platform.async_add_entities([my_entity]) @@ -1415,7 +1415,7 @@ async def test_repr(hass) -> None: # Removed await platform.async_remove_entity(my_entity.entity_id) - assert str(my_entity) == "" + assert str(my_entity) == "" async def test_warn_using_async_update_ha_state(