From 7a344ff73fd9c16d625c5e3c1734694c523c8de8 Mon Sep 17 00:00:00 2001 From: Shaun Tarves Date: Wed, 28 Apr 2021 09:22:30 -0400 Subject: [PATCH] Fixed issue where locks were not properly parsing open/close and lock state [Closes #7] --- wyze_sdk/models/devices/base.py | 2 ++ wyze_sdk/models/devices/locks.py | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/wyze_sdk/models/devices/base.py b/wyze_sdk/models/devices/base.py index aa5a091..43162f0 100644 --- a/wyze_sdk/models/devices/base.py +++ b/wyze_sdk/models/devices/base.py @@ -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}") diff --git a/wyze_sdk/models/devices/locks.py b/wyze_sdk/models/devices/locks.py index 1541ca5..7743275 100644 --- a/wyze_sdk/models/devices/locks.py +++ b/wyze_sdk/models/devices/locks.py @@ -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): @@ -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):