Skip to content

Commit

Permalink
Fixed issue where locks were not properly parsing open/close and lock…
Browse files Browse the repository at this point in the history
… state [Closes #7]
  • Loading branch information
Shaun Tarves committed Apr 28, 2021
1 parent b79ebdc commit 7a344ff
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 2 additions & 0 deletions wyze_sdk/models/devices/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,8 @@ def _extract_property(self, prop_def: Union[str, PropDef], others: Union[dict, S
return self._extract_property(prop_def=prop_def, others=others['props'])
if 'property_list' in others:
return self._extract_property(prop_def=prop_def, others=others['property_list'])
if 'device_params' in others:
return self._extract_property(prop_def=prop_def, others=others['device_params'])
self.logger.debug(prop_def.pid)
for key, value in others.items():
self.logger.debug(f"key: {key}, value: {value}")
Expand Down
9 changes: 7 additions & 2 deletions wyze_sdk/models/devices/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class LockProps(object):
@classmethod
@property
def lock_state(cls) -> PropDef:
return PropDef("switch_state", bool, str)
return PropDef("switch_state", bool, int)

@classmethod
@property
def open_close_state(cls) -> PropDef:
return PropDef("open_close_state", bool, str)
return PropDef("open_close_state", bool, int)


class LockEventType(Enum):
Expand Down Expand Up @@ -276,6 +276,11 @@ def parent(self) -> str:
def record_count(self) -> int:
return self._record_count

@property
def is_locked(self) -> bool:
# locks use switch_state = 0 to indicate locked
return not self.lock_state


class LockGateway(AbstractWirelessNetworkedDevice):

Expand Down

0 comments on commit 7a344ff

Please sign in to comment.