mirror of
https://github.com/home-assistant/core.git
synced 2025-11-16 06:20:07 +00:00
Ensure it's safe to call Entity.__repr__ on non added entity (#106032)
This commit is contained in:
@@ -1476,7 +1476,12 @@ class Entity(
|
||||
self.async_on_remove(self._async_unsubscribe_device_updates)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
"""Return the representation."""
|
||||
"""Return the representation.
|
||||
|
||||
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"<entity {self.entity_id}={STATE_UNKNOWN}>"
|
||||
return f"<entity {self.entity_id}={self._stringify_state(self.available)}>"
|
||||
|
||||
async def async_request_call(self, coro: Coroutine[Any, Any, _T]) -> _T:
|
||||
|
||||
Reference in New Issue
Block a user