Drop __eq__ dunder method from Entity (#90585)
parent
469321157d
commit
149e610bca
|
@ -945,25 +945,6 @@ class Entity(ABC):
|
||||||
self.entity_id = self.registry_entry.entity_id
|
self.entity_id = self.registry_entry.entity_id
|
||||||
await self.platform.async_add_entities([self])
|
await self.platform.async_add_entities([self])
|
||||||
|
|
||||||
def __eq__(self, other: Any) -> bool:
|
|
||||||
"""Return the comparison."""
|
|
||||||
if not isinstance(other, self.__class__):
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Can only decide equality if both have a unique id
|
|
||||||
if self.unique_id is None or other.unique_id is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
# Ensure they belong to the same platform
|
|
||||||
if self.platform is not None or other.platform is not None:
|
|
||||||
if self.platform is None or other.platform is None:
|
|
||||||
return False
|
|
||||||
|
|
||||||
if self.platform.platform != other.platform.platform:
|
|
||||||
return False
|
|
||||||
|
|
||||||
return self.unique_id == other.unique_id
|
|
||||||
|
|
||||||
def __repr__(self) -> str:
|
def __repr__(self) -> str:
|
||||||
"""Return the representation."""
|
"""Return the representation."""
|
||||||
return f"<entity {self.entity_id}={self._stringify_state(self.available)}>"
|
return f"<entity {self.entity_id}={self._stringify_state(self.available)}>"
|
||||||
|
|
Loading…
Reference in New Issue