mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Use identity checks for EntityPlatformState enum (#115067)
This commit is contained in:
parent
164d29d4d9
commit
a0936902c2
@ -1092,7 +1092,7 @@ class Entity(
|
|||||||
@callback
|
@callback
|
||||||
def _async_write_ha_state(self) -> None:
|
def _async_write_ha_state(self) -> None:
|
||||||
"""Write the state to the state machine."""
|
"""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
|
# Polling returned after the entity has already been removed
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -1305,7 +1305,7 @@ class Entity(
|
|||||||
parallel_updates: asyncio.Semaphore | None,
|
parallel_updates: asyncio.Semaphore | None,
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Start adding an entity to a platform."""
|
"""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(
|
raise HomeAssistantError(
|
||||||
f"Entity '{self.entity_id}' cannot be added a second time to an entity"
|
f"Entity '{self.entity_id}' cannot be added a second time to an entity"
|
||||||
" platform"
|
" 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 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 unknown.unknown={STATE_UNKNOWN}>"
|
||||||
return f"<entity {self.entity_id}={self._stringify_state(self.available)}>"
|
return f"<entity {self.entity_id}={self._stringify_state(self.available)}>"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user