Add lock typing in nuki (#73545)

This commit is contained in:
epenet 2022-06-16 10:20:34 +02:00 committed by GitHub
parent 2b5748912d
commit 521d52a8b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@
from abc import ABC, abstractmethod
from typing import Any
from pynuki import NukiLock, NukiOpener
from pynuki.constants import MODE_OPENER_CONTINUOUS
import voluptuous as vol
@ -73,11 +74,6 @@ class NukiDeviceEntity(NukiEntity, LockEntity, ABC):
"""Return a unique ID."""
return self._nuki_device.nuki_id
@property
@abstractmethod
def is_locked(self):
"""Return true if lock is locked."""
@property
def extra_state_attributes(self):
"""Return the device specific state attributes."""
@ -108,8 +104,10 @@ class NukiDeviceEntity(NukiEntity, LockEntity, ABC):
class NukiLockEntity(NukiDeviceEntity):
"""Representation of a Nuki lock."""
_nuki_device: NukiLock
@property
def is_locked(self):
def is_locked(self) -> bool:
"""Return true if lock is locked."""
return self._nuki_device.is_locked
@ -137,8 +135,10 @@ class NukiLockEntity(NukiDeviceEntity):
class NukiOpenerEntity(NukiDeviceEntity):
"""Representation of a Nuki opener."""
_nuki_device: NukiOpener
@property
def is_locked(self):
def is_locked(self) -> bool:
"""Return true if either ring-to-open or continuous mode is enabled."""
return not (
self._nuki_device.is_rto_activated