Use identity checks for ESPHome Enums (#124334)

Enums are singletons and should use is to compare.

The valve platform was updated but cover and lock were missed.
This commit is contained in:
J. Nick Koston 2024-08-22 14:50:15 -05:00 committed by GitHub
parent 2533bde27a
commit 61ac4c7af7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View file

@ -61,13 +61,13 @@ class EsphomeCover(EsphomeEntity[CoverInfo, CoverState], CoverEntity):
@esphome_state_property
def is_opening(self) -> bool:
"""Return if the cover is opening or not."""
return self._state.current_operation == CoverOperation.IS_OPENING
return self._state.current_operation is CoverOperation.IS_OPENING
@property
@esphome_state_property
def is_closing(self) -> bool:
"""Return if the cover is closing or not."""
return self._state.current_operation == CoverOperation.IS_CLOSING
return self._state.current_operation is CoverOperation.IS_CLOSING
@property
@esphome_state_property

View file

@ -40,25 +40,25 @@ class EsphomeLock(EsphomeEntity[LockInfo, LockEntityState], LockEntity):
@esphome_state_property
def is_locked(self) -> bool | None:
"""Return true if the lock is locked."""
return self._state.state == LockState.LOCKED
return self._state.state is LockState.LOCKED
@property
@esphome_state_property
def is_locking(self) -> bool | None:
"""Return true if the lock is locking."""
return self._state.state == LockState.LOCKING
return self._state.state is LockState.LOCKING
@property
@esphome_state_property
def is_unlocking(self) -> bool | None:
"""Return true if the lock is unlocking."""
return self._state.state == LockState.UNLOCKING
return self._state.state is LockState.UNLOCKING
@property
@esphome_state_property
def is_jammed(self) -> bool | None:
"""Return true if the lock is jammed (incomplete locking)."""
return self._state.state == LockState.JAMMED
return self._state.state is LockState.JAMMED
@convert_api_error_ha_error
async def async_lock(self, **kwargs: Any) -> None: