Skip to content

Commit

Permalink
Use identity checks for ESPHome Enums (#124334)
Browse files Browse the repository at this point in the history
Enums are singletons and should use is to compare.

The valve platform was updated but cover and lock were missed.
  • Loading branch information
bdraco authored Aug 22, 2024
1 parent 2533bde commit 61ac4c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions homeassistant/components/esphome/cover.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ def is_closed(self) -> bool | None:
@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
Expand Down
8 changes: 4 additions & 4 deletions homeassistant/components/esphome/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ def _on_static_info_update(self, static_info: EntityInfo) -> None:
@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:
Expand Down

0 comments on commit 61ac4c7

Please sign in to comment.