mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Improve logic for zwave_js.lock.is_locked attr (#93947)
This commit is contained in:
parent
3934f91242
commit
d9f059fcaa
@ -99,14 +99,17 @@ class ZWaveLock(ZWaveBaseEntity, LockEntity):
|
|||||||
@property
|
@property
|
||||||
def is_locked(self) -> bool | None:
|
def is_locked(self) -> bool | None:
|
||||||
"""Return true if the lock is locked."""
|
"""Return true if the lock is locked."""
|
||||||
if self.info.primary_value.value is None:
|
value = self.info.primary_value
|
||||||
|
if value.value is None or (
|
||||||
|
value.command_class == CommandClass.DOOR_LOCK
|
||||||
|
and value.value == DoorLockMode.UNKNOWN
|
||||||
|
):
|
||||||
# guard missing value
|
# guard missing value
|
||||||
return None
|
return None
|
||||||
return int(
|
return (
|
||||||
LOCK_CMD_CLASS_TO_LOCKED_STATE_MAP[
|
LOCK_CMD_CLASS_TO_LOCKED_STATE_MAP[CommandClass(value.command_class)]
|
||||||
CommandClass(self.info.primary_value.command_class)
|
== self.info.primary_value.value
|
||||||
]
|
)
|
||||||
) == int(self.info.primary_value.value)
|
|
||||||
|
|
||||||
async def _set_lock_state(self, target_state: str, **kwargs: Any) -> None:
|
async def _set_lock_state(self, target_state: str, **kwargs: Any) -> None:
|
||||||
"""Set the lock state."""
|
"""Set the lock state."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user