mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 12:45:28 +02:00
Use identity checks for EntityPlatformState enum (#115067)
This commit is contained in:
@@ -1092,7 +1092,7 @@ class Entity(
|
||||
@callback
|
||||
def _async_write_ha_state(self) -> None:
|
||||
"""Write the state to the state machine."""
|
||||
if self._platform_state == EntityPlatformState.REMOVED:
|
||||
if self._platform_state is EntityPlatformState.REMOVED:
|
||||
# Polling returned after the entity has already been removed
|
||||
return
|
||||
|
||||
@@ -1305,7 +1305,7 @@ class Entity(
|
||||
parallel_updates: asyncio.Semaphore | None,
|
||||
) -> None:
|
||||
"""Start adding an entity to a platform."""
|
||||
if self._platform_state != EntityPlatformState.NOT_ADDED:
|
||||
if self._platform_state is not EntityPlatformState.NOT_ADDED:
|
||||
raise HomeAssistantError(
|
||||
f"Entity '{self.entity_id}' cannot be added a second time to an entity"
|
||||
" platform"
|
||||
@@ -1572,7 +1572,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:
|
||||
if self._platform_state is not EntityPlatformState.ADDED:
|
||||
return f"<entity unknown.unknown={STATE_UNKNOWN}>"
|
||||
return f"<entity {self.entity_id}={self._stringify_state(self.available)}>"
|
||||
|
||||
|
Reference in New Issue
Block a user