Skip to content
This repository was archived by the owner on Jun 28, 2024. It is now read-only.

Commit 8ea1598

Browse files
Add missing thermostat API (#111)
* Add missing thermostat methods * Update types * Update devices (+ unmanaged) list method * Test new methods * Update type for parse_list_device_params * Fix import * Fix set_fan_mode, fix test, use ecobeed factory because nest doesn't suppott set_fan_mode
1 parent fb7ba4d commit 8ea1598

File tree

6 files changed

+562
-66
lines changed

6 files changed

+562
-66
lines changed

seamapi/devices.py

Lines changed: 21 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
DeviceType,
1313
)
1414
from typing import Any, List, Union, Optional, Dict
15+
from seamapi.utils.parse_list_device_params import parse_list_device_params
1516
from seamapi.utils.convert_to_id import (
16-
to_connect_webview_id,
17-
to_connected_account_id,
1817
to_device_id,
1918
)
2019
from seamapi.utils.report_error import report_error
@@ -69,6 +68,8 @@ def list(
6968
device_types: Optional[List[DeviceType]] = None,
7069
device_ids: Optional[List[Union[DeviceId, Device]]] = None,
7170
manufacturer: Optional[str] = None,
71+
limit: Optional[float] = None,
72+
created_before: Optional[str] = None,
7273
) -> List[Device]:
7374
"""Gets a list of devices.
7475
@@ -88,6 +89,10 @@ def list(
8889
Device IDs to filter devices by
8990
manufacturer : Optional[str]
9091
Manufacturer name to filter devices by e.g. august, schlage
92+
limit : str, optional
93+
Limit the number of devices returned
94+
created_before : str, optional
95+
If specified, only devices created before this date will be returned
9196
9297
Raises
9398
------
@@ -99,14 +104,16 @@ def list(
99104
A list of devices.
100105
"""
101106

102-
params = parse_list_params(
107+
params = parse_list_device_params(
103108
connected_account,
104109
connected_accounts,
105110
connect_webview,
106111
device_type,
107112
device_types,
108113
device_ids,
109114
manufacturer,
115+
limit,
116+
created_before,
110117
)
111118

112119
res = self.seam.make_request(
@@ -318,6 +325,8 @@ def list(
318325
device_types: Optional[List[DeviceType]] = None,
319326
device_ids: Optional[List[Union[DeviceId, Device]]] = None,
320327
manufacturer: Optional[str] = None,
328+
limit: Optional[float] = None,
329+
created_before: Optional[str] = None,
321330
) -> List[UnmanagedDevice]:
322331
"""Gets a list of unmanaged devices.
323332
@@ -333,10 +342,14 @@ def list(
333342
Device type e.g. august_lock
334343
device_types : List[DeviceType], optional
335344
List of device types e.g. august_lock
336-
device_ids : Optional[List[Union[DeviceId, Device]]]
345+
device_ids : List[Union[DeviceId, Device]], optional
337346
Device IDs to filter devices by
338-
manufacturer : Optional[str]
347+
manufacturer : str, optional
339348
Manufacturer name to filter devices by e.g. august, schlage
349+
limit : str, optional
350+
Limit the number of devices returned
351+
created_before : str, optional
352+
If specified, only devices created before this date will be returned
340353
341354
Raises
342355
------
@@ -348,14 +361,16 @@ def list(
348361
A list of unmanaged devices.
349362
"""
350363

351-
params = parse_list_params(
364+
params = parse_list_device_params(
352365
connected_account,
353366
connected_accounts,
354367
connect_webview,
355368
device_type,
356369
device_types,
357370
device_ids,
358371
manufacturer,
372+
limit,
373+
created_before,
359374
)
360375

361376
res = self.seam.make_request(
@@ -405,34 +420,3 @@ def update(
405420
)
406421

407422
return True
408-
409-
410-
def parse_list_params(
411-
connected_account,
412-
connected_accounts,
413-
connect_webview,
414-
device_type,
415-
device_types,
416-
device_ids,
417-
manufacturer,
418-
):
419-
params = {}
420-
if connected_account:
421-
params["connected_account_id"] = to_connected_account_id(
422-
connected_account
423-
)
424-
if connected_accounts:
425-
params["connected_account_ids"] = [
426-
to_connected_account_id(ca) for ca in connected_accounts
427-
]
428-
if connect_webview:
429-
params["connect_webview_id"] = to_connect_webview_id(connect_webview)
430-
if device_type:
431-
params["device_type"] = device_type
432-
if device_types is not None:
433-
params["device_types"] = device_types
434-
if device_ids is not None:
435-
params["device_ids"] = [to_device_id(d) for d in device_ids]
436-
if manufacturer:
437-
params["manufacturer"] = manufacturer
438-
return params

0 commit comments

Comments
 (0)