Use identity checks for EntityPlatformState enum (#115067)

This commit is contained in:
J. Nick Koston 2024-04-06 14:31:23 -10:00 committed by GitHub
parent 164d29d4d9
commit a0936902c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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)}>"