Skip to content

Commit

Permalink
Merge pull request #91 from dknowles2/attr-connected
Browse files Browse the repository at this point in the history
Add a "connected" attribute to Lock
  • Loading branch information
dknowles2 committed Sep 3, 2023
2 parents 52da3b9 + 53d0bef commit ba8d2fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pyschlage/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ class Lock(Mutable):
Also see known device types in device.py.
"""

connected: bool = False
"""Whether the lock is connected to WiFi."""

battery_level: int | None = None
"""The remaining battery level of the lock.
Expand Down Expand Up @@ -134,6 +137,7 @@ def from_json(cls, auth: Auth, json: dict) -> Lock:
name=json["name"],
model_name=json["modelName"],
device_type=json["devicetypeId"],
connected=json["connected"],
battery_level=attributes.get("batteryLevel"),
is_locked=is_locked,
is_jammed=is_jammed,
Expand Down
1 change: 1 addition & 0 deletions tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def test_from_json(self, mock_auth, lock_json):
assert lock.name == "Door Lock"
assert lock.model_name == "__model_name__"
assert lock.device_type == "be489wifi"
assert lock.connected is True
assert lock.battery_level == 95
assert lock.is_locked
assert lock._cat == "01234"
Expand Down

0 comments on commit ba8d2fc

Please sign in to comment.