Skip to content

Commit 70293ba

Browse files
authored
Merge pull request #6 from zweckj/door-state
Add door state
2 parents 7ce9f2d + c77d584 commit 70293ba

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

aiotedee/lock.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@ class TedeeLockState(IntEnum):
2020
UNPULLING = 255
2121

2222

23+
class TedeeDoorState(IntEnum):
24+
"""Tedee Door State."""
25+
26+
NOT_PAIRED = 0
27+
DISCONNECTED = 1
28+
OPENED = 2
29+
CLOSED = 3
30+
UNCALIBRATED = 4
31+
32+
2333
class TedeeLock:
2434
"""Tedee Lock."""
2535

@@ -36,6 +46,7 @@ def __init__(
3646
is_enabled_pullspring: bool = False,
3747
is_enabled_auto_pullspring: bool = False,
3848
duration_pullspring: int = 0,
49+
door_state: int = 0,
3950
) -> None:
4051
"""Initialize a new lock."""
4152
self._lock_name = lock_name
@@ -49,6 +60,7 @@ def __init__(
4960
self._duration_pullspring = duration_pullspring
5061
self._is_enabled_pullspring = is_enabled_pullspring
5162
self._is_enabled_auto_pullspring = is_enabled_auto_pullspring
63+
self._door_state = door_state
5264

5365
@property
5466
def lock_name(self) -> str:
@@ -90,6 +102,15 @@ def state(self) -> TedeeLockState:
90102
"""Return the state of the lock."""
91103
return TedeeLockState(self._state)
92104

105+
@property
106+
def door_state(self) -> TedeeDoorState:
107+
"""Return the state of the door."""
108+
return TedeeDoorState(self._door_state)
109+
110+
@door_state.setter
111+
def door_state(self, state: int):
112+
self._door_state = state
113+
93114
@state.setter
94115
def state(self, status: int):
95116
self._state = status
@@ -146,7 +167,7 @@ def is_enabled_auto_pullspring(self) -> bool:
146167

147168
@is_enabled_auto_pullspring.setter
148169
def is_enabled_auto_pullspring(self, value: bool):
149-
self._is_enabled_auto_pullspring = value
170+
self._is_enabled_auto_pullspring = value
150171

151172
@property
152173
def duration_pullspring(self) -> int:

aiotedee/tedee_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ async def get_locks(self) -> None:
138138
battery_level,
139139
is_charging,
140140
state_change_result,
141+
door_state
141142
) = self.parse_lock_properties(lock_json)
142143
(
143144
is_enabled_pullspring,
@@ -157,6 +158,7 @@ async def get_locks(self) -> None:
157158
is_enabled_pullspring,
158159
is_enabled_auto_pullspring,
159160
duration_pullspring,
161+
door_state,
160162
)
161163

162164
self._locks_dict[lock_id] = lock
@@ -200,6 +202,7 @@ async def sync(self) -> None:
200202
lock.battery_level,
201203
lock.is_charging,
202204
lock.state_change_result,
205+
lock.door_state,
203206
) = self.parse_lock_properties(lock_json)
204207

205208
if local_call_success:
@@ -344,14 +347,16 @@ def parse_lock_properties(self, json_properties: dict):
344347
battery_level = lock_properties.get("batteryLevel", 50)
345348
is_charging = lock_properties.get("isCharging", False)
346349
state_change_result = lock_properties.get("stateChangeResult", 0)
350+
door_state = lock_properties.get("doorState", 0)
347351
else:
348352
# local call does not have lock properties
349353
state = json_properties.get("state", 9)
350354
battery_level = json_properties.get("batteryLevel", 50)
351355
is_charging = bool(json_properties.get("isCharging", False))
352356
state_change_result = json_properties.get("jammed", 0)
357+
door_state = json_properties.get("doorState", 0)
353358

354-
return connected, state, battery_level, is_charging, state_change_result
359+
return connected, state, battery_level, is_charging, state_change_result, door_state
355360

356361
def parse_pull_spring_settings(self, settings: dict):
357362
"""Parse the pull spring settings"""

pyproject.toml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
[project]
22
name = "aiotedee"
3-
version = "0.2.23"
4-
license = {text = "MIT License"}
3+
version = "0.2.24"
4+
license = { text = "MIT License" }
55
description = "A package to interact with Tedee locks using asyncio"
66
readme = "README.md"
7-
authors = [{name = "Josef Zweck", email = "24647999+zweckj@users.noreply.github.com"}]
8-
maintainers = [{name = "Josef Zweck", email = "24647999+zweckj@users.noreply.github.com"}]
7+
authors = [
8+
{ name = "Josef Zweck", email = "24647999+zweckj@users.noreply.github.com" },
9+
]
10+
maintainers = [
11+
{ name = "Josef Zweck", email = "24647999+zweckj@users.noreply.github.com" },
12+
]
913
keywords = ["Tedee", "api", "async", "client"]
1014
classifiers = [
1115
"Development Status :: 5 - Production/Stable",
@@ -16,9 +20,7 @@ classifiers = [
1620
"Programming Language :: Python",
1721
"Programming Language :: Python :: 3.12",
1822
]
19-
dependencies = [
20-
"aiohttp >= 3.8.1",
21-
]
23+
dependencies = ["aiohttp >= 3.8.1"]
2224
requires-python = ">= 3.9"
2325

2426
[project.urls]

0 commit comments

Comments
 (0)