Skip to content

Commit

Permalink
Fix device Type V3 (#81)
Browse files Browse the repository at this point in the history
Co-authored-by: Philipp Schmitt <[email protected]>
Co-authored-by: Philipp Schmitt <[email protected]>
  • Loading branch information
3 people authored Mar 25, 2023
1 parent 394c813 commit 79a6219
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
22 changes: 14 additions & 8 deletions pynuki/bridge.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,38 +253,44 @@ def locks(self):
def openers(self):
return self._get_devices(device_type=const.DEVICE_TYPE_OPENER)

def lock(self, nuki_id, block=False):
def lock(self, nuki_id, device_type=const.DEVICE_TYPE_LOCK, block=False):
return self.lock_action(
nuki_id,
action=const.ACTION_LOCK_LOCK,
device_type=const.DEVICE_TYPE_LOCK,
device_type=device_type,
block=block,
)

def unlock(self, nuki_id, block=False):
def unlock(self, nuki_id, device_type=const.DEVICE_TYPE_LOCK, block=False):
return self.lock_action(
nuki_id,
action=const.ACTION_LOCK_UNLOCK,
device_type=const.DEVICE_TYPE_LOCK,
device_type=device_type,
block=block,
)

def lock_n_go(self, nuki_id, unlatch=False, block=False):
def lock_n_go(
self,
nuki_id,
device_type=const.DEVICE_TYPE_LOCK,
unlatch=False,
block=False,
):
action = const.ACTION_LOCK_LOCK_N_GO
if unlatch:
action = const.ACTION_LOCK_LOCK_N_GO_WITH_UNLATCH
return self.lock_action(
nuki_id,
action=action,
device_type=const.DEVICE_TYPE_LOCK,
device_type=device_type,
block=block,
)

def unlatch(self, nuki_id, block=False):
def unlatch(self, nuki_id, device_type=const.DEVICE_TYPE_LOCK, block=False):
return self.lock_action(
nuki_id,
action=const.ACTION_LOCK_UNLATCH,
device_type=const.DEVICE_TYPE_LOCK,
device_type=device_type,
block=block,
)

Expand Down
17 changes: 13 additions & 4 deletions pynuki/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,24 @@ def battery_critical_keypad(self):
return self._json.get("keypadBatteryCritical")

def lock(self, block=False):
return self._bridge.lock(nuki_id=self.nuki_id, block=block)
return self._bridge.lock(
nuki_id=self.nuki_id, device_type=self.device_type, block=block
)

def unlock(self, block=False):
return self._bridge.unlock(nuki_id=self.nuki_id, block=block)
return self._bridge.unlock(
nuki_id=self.nuki_id, device_type=self.device_type, block=block
)

def lock_n_go(self, unlatch=False, block=False):
return self._bridge.lock_n_go(
nuki_id=self.nuki_id, unlatch=unlatch, block=block
nuki_id=self.nuki_id,
unlatch=unlatch,
device_type=self.device_type,
block=block,
)

def unlatch(self, block=False):
return self._bridge.unlatch(nuki_id=self.nuki_id, block=block)
return self._bridge.unlatch(
nuki_id=self.nuki_id, device_type=self.device_type, block=block
)

0 comments on commit 79a6219

Please sign in to comment.