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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: switchbot_api
3
- Version: 2.9.0
3
+ Version: 2.10.0
4
4
  Summary: An asynchronous library to use Switchbot API
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "switchbot_api"
3
- version = "2.9.0"
3
+ version = "2.10.0"
4
4
  description = "An asynchronous library to use Switchbot API"
5
5
  authors = ["Ravaka Razafimanantsoa <contact@ravaka.dev>"]
6
6
  license = "MIT"
@@ -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):
@@ -15,3 +15,7 @@ class SwitchBotAuthenticationError(SwitchBotError):
15
15
 
16
16
  class SwitchBotDeviceOfflineError(SwitchBotError):
17
17
  """Device currently offline."""
18
+
19
+
20
+ class SwitchBotDeviceRequestError(SwitchBotError):
21
+ """Device request error."""
@@ -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