switchbot-api 2.9.0__tar.gz → 2.10.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/PKG-INFO +1 -1
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/pyproject.toml +1 -1
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/switchbot_api/__init__.py +8 -0
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/switchbot_api/commands.py +15 -1
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/switchbot_api/exceptions.py +4 -0
- switchbot_api-2.10.0/switchbot_api/utils.py +28 -0
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/LICENSE +0 -0
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/README.md +0 -0
- {switchbot_api-2.9.0 → switchbot_api-2.10.0}/switchbot_api/models.py +0 -0
|
@@ -18,6 +18,7 @@ from aiohttp.hdrs import METH_GET, METH_POST
|
|
|
18
18
|
from switchbot_api.commands import (
|
|
19
19
|
AirConditionerCommands,
|
|
20
20
|
AirPurifierCommands,
|
|
21
|
+
ArtFrameCommands,
|
|
21
22
|
BatteryCirculatorFanCommands,
|
|
22
23
|
BlindTiltCommands,
|
|
23
24
|
BotCommands,
|
|
@@ -30,9 +31,11 @@ from switchbot_api.commands import (
|
|
|
30
31
|
FanCommands,
|
|
31
32
|
HumidifierCommands,
|
|
32
33
|
HumidifierV2Commands,
|
|
34
|
+
KeyPadCommands,
|
|
33
35
|
LightCommands,
|
|
34
36
|
LockCommands,
|
|
35
37
|
LockV2Commands,
|
|
38
|
+
LockV3Commands,
|
|
36
39
|
OthersCommands,
|
|
37
40
|
RGBWLightCommands,
|
|
38
41
|
RGBWWLightCommands,
|
|
@@ -54,6 +57,7 @@ from switchbot_api.exceptions import (
|
|
|
54
57
|
)
|
|
55
58
|
from switchbot_api.models import (
|
|
56
59
|
BatteryCirculatorFanMode,
|
|
60
|
+
BatteryLevel,
|
|
57
61
|
PowerState,
|
|
58
62
|
SmartRadiatorThermostatMode,
|
|
59
63
|
VacuumCleanMode,
|
|
@@ -64,8 +68,10 @@ from switchbot_api.models import (
|
|
|
64
68
|
__all__ = [
|
|
65
69
|
"AirConditionerCommands",
|
|
66
70
|
"AirPurifierCommands",
|
|
71
|
+
"ArtFrameCommands",
|
|
67
72
|
"BatteryCirculatorFanCommands",
|
|
68
73
|
"BatteryCirculatorFanMode",
|
|
74
|
+
"BatteryLevel",
|
|
69
75
|
"BlindTiltCommands",
|
|
70
76
|
"BotCommands",
|
|
71
77
|
"CeilingLightCommands",
|
|
@@ -78,9 +84,11 @@ __all__ = [
|
|
|
78
84
|
"FanCommands",
|
|
79
85
|
"HumidifierCommands",
|
|
80
86
|
"HumidifierV2Commands",
|
|
87
|
+
"KeyPadCommands",
|
|
81
88
|
"LightCommands",
|
|
82
89
|
"LockCommands",
|
|
83
90
|
"LockV2Commands",
|
|
91
|
+
"LockV3Commands",
|
|
84
92
|
"OthersCommands",
|
|
85
93
|
"PowerState",
|
|
86
94
|
"RGBWLightCommands",
|
|
@@ -93,7 +93,21 @@ class LockV2Commands(Commands):
|
|
|
93
93
|
@classmethod
|
|
94
94
|
def get_supported_devices(cls) -> list[str]:
|
|
95
95
|
"""Get supported devices."""
|
|
96
|
-
return ["Smart Lock", "Smart Lock Pro", "Smart Lock Ultra"]
|
|
96
|
+
return ["Smart Lock", "Smart Lock Pro", "Smart Lock Ultra", "Smart Lock Vision"]
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class LockV3Commands(Commands):
|
|
100
|
+
"""Lock commands."""
|
|
101
|
+
|
|
102
|
+
LOCK = "lock"
|
|
103
|
+
UNLOCK = "unlock"
|
|
104
|
+
DEADBOLT = "deadbolt"
|
|
105
|
+
NIGHT_LATCH_UNLOCK = "nightLatchUnlock"
|
|
106
|
+
|
|
107
|
+
@classmethod
|
|
108
|
+
def get_supported_devices(cls) -> list[str]:
|
|
109
|
+
"""Get supported devices."""
|
|
110
|
+
return ["Smart Lock Vision Pro"]
|
|
97
111
|
|
|
98
112
|
|
|
99
113
|
class HumidifierCommands(Commands):
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"""util for SwitchBot API."""
|
|
2
|
+
|
|
3
|
+
import aiohttp
|
|
4
|
+
from aiohttp import ClientResponse
|
|
5
|
+
|
|
6
|
+
from .exceptions import SwitchBotDeviceRequestError
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def check_response_status(response: ClientResponse) -> None:
|
|
10
|
+
"""Check https response status."""
|
|
11
|
+
if response.status != 200:
|
|
12
|
+
msg = f"status code != 200 (actual: {response.status})"
|
|
13
|
+
raise SwitchBotDeviceRequestError(msg)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
async def get_file_stream_from_cloud(url: str, timeout: float = 5) -> bytes:
|
|
17
|
+
"""Get file stream from cloud."""
|
|
18
|
+
# now only for download <AI Art Frame> Picture
|
|
19
|
+
try:
|
|
20
|
+
async with (
|
|
21
|
+
aiohttp.ClientSession() as session,
|
|
22
|
+
session.get(url, timeout=aiohttp.ClientTimeout(total=timeout)) as response,
|
|
23
|
+
):
|
|
24
|
+
check_response_status(response)
|
|
25
|
+
return await response.read()
|
|
26
|
+
except Exception as e:
|
|
27
|
+
msg = f"{e}"
|
|
28
|
+
raise SwitchBotDeviceRequestError(msg) from e
|
|
File without changes
|
|
File without changes
|
|
File without changes
|