Skip to content

Commit bb5e29c

Browse files
authored
Merge pull request #3 from jozefKruszynski/parse-auto-pull-spring
2 parents 0622300 + 2ce521b commit bb5e29c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

aiotedee/lock.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def __init__(
3434
is_charging: bool = False,
3535
state_change_result: int = 0,
3636
is_enabled_pullspring: bool = False,
37+
is_enabled_auto_pullspring: bool = False,
3738
duration_pullspring: int = 0,
3839
) -> None:
3940
"""Initialize a new lock."""
@@ -47,6 +48,7 @@ def __init__(
4748
self._state_change_result = state_change_result
4849
self._duration_pullspring = duration_pullspring
4950
self._is_enabled_pullspring = is_enabled_pullspring
51+
self._is_enabled_auto_pullspring = is_enabled_auto_pullspring
5052

5153
@property
5254
def lock_name(self) -> str:
@@ -137,6 +139,15 @@ def is_enabled_pullspring(self) -> bool:
137139
def is_enabled_pullspring(self, value: bool):
138140
self._is_enabled_pullspring = value
139141

142+
@property
143+
def is_enabled_auto_pullspring(self) -> bool:
144+
"""Return true if the lock is charging."""
145+
return bool(self._is_enabled_auto_pullspring)
146+
147+
@is_enabled_auto_pullspring.setter
148+
def is_enabled_auto_pullspring(self, value: bool):
149+
self._is_enabled_auto_pullspring = value
150+
140151
@property
141152
def duration_pullspring(self) -> int:
142153
"""Return the duration of the pullspring."""
@@ -158,5 +169,6 @@ def to_dict(self) -> dict[str, str | int | bool | None]:
158169
"is_charging": self._is_charging,
159170
"state_change_result": self._state_change_result,
160171
"is_enabled_pullspring": self._is_enabled_pullspring,
172+
"is_enabled_auto_pullspring": self._is_enabled_auto_pullspring,
161173
"duration_pullspring": self._duration_pullspring,
162174
}

aiotedee/tedee_client.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ async def get_locks(self) -> None:
141141
) = self.parse_lock_properties(lock_json)
142142
(
143143
is_enabled_pullspring,
144+
is_enabled_auto_pullspring,
144145
duration_pullspring,
145146
) = self.parse_pull_spring_settings(lock_json)
146147

@@ -154,6 +155,7 @@ async def get_locks(self) -> None:
154155
is_charging,
155156
state_change_result,
156157
is_enabled_pullspring,
158+
is_enabled_auto_pullspring,
157159
duration_pullspring,
158160
)
159161

@@ -203,6 +205,7 @@ async def sync(self) -> None:
203205
if local_call_success:
204206
(
205207
lock.is_enabled_pullspring,
208+
lock.is_enabled_auto_pullspring,
206209
lock.duration_pullspring,
207210
) = self.parse_pull_spring_settings(lock_json)
208211

@@ -354,8 +357,9 @@ def parse_pull_spring_settings(self, settings: dict):
354357
"""Parse the pull spring settings"""
355358
device_settings = settings.get("deviceSettings", {})
356359
pull_spring_enabled = bool(device_settings.get("pullSpringEnabled", False))
360+
pull_spring_auto_enabled = bool(device_settings.get("autoPullSpringEnabled", False))
357361
pull_spring_duration = device_settings.get("pullSpringDuration", 5)
358-
return pull_spring_enabled, pull_spring_duration
362+
return pull_spring_enabled, pull_spring_auto_enabled, pull_spring_duration
359363

360364
def _calculate_secure_local_token(self) -> str:
361365
"""Calculate the secure token"""

0 commit comments

Comments
 (0)