mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +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
|
||||
def is_locked(self) -> bool | None:
|
||||
"""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
|
||||
return None
|
||||
return int(
|
||||
LOCK_CMD_CLASS_TO_LOCKED_STATE_MAP[
|
||||
CommandClass(self.info.primary_value.command_class)
|
||||
]
|
||||
) == int(self.info.primary_value.value)
|
||||
return (
|
||||
LOCK_CMD_CLASS_TO_LOCKED_STATE_MAP[CommandClass(value.command_class)]
|
||||
== self.info.primary_value.value
|
||||
)
|
||||
|
||||
async def _set_lock_state(self, target_state: str, **kwargs: Any) -> None:
|
||||
"""Set the lock state."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user