switchbot-api 2.0.0__tar.gz → 2.2.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.0.0 → switchbot_api-2.2.0}/PKG-INFO +1 -1
- {switchbot_api-2.0.0 → switchbot_api-2.2.0}/pyproject.toml +2 -2
- {switchbot_api-2.0.0 → switchbot_api-2.2.0}/switchbot_api/__init__.py +15 -7
- {switchbot_api-2.0.0 → switchbot_api-2.2.0}/LICENSE +0 -0
- {switchbot_api-2.0.0 → switchbot_api-2.2.0}/README.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[tool.poetry]
|
|
2
2
|
name = "switchbot_api"
|
|
3
|
-
version = "2.
|
|
3
|
+
version = "2.2.0"
|
|
4
4
|
description = "An asynchronous library to use Switchbot API"
|
|
5
5
|
authors = ["Ravaka Razafimanantsoa <contact@ravaka.dev>"]
|
|
6
6
|
license = "MIT"
|
|
@@ -16,7 +16,7 @@ aiohttp = "^3.8.4"
|
|
|
16
16
|
[tool.poetry.group.dev.dependencies]
|
|
17
17
|
pytest = "^7.2.2"
|
|
18
18
|
flake8 = "^6.0.0"
|
|
19
|
-
black = "
|
|
19
|
+
black = ">=23.1,<25.0"
|
|
20
20
|
coverage = "^7.2.1"
|
|
21
21
|
parameterized = "^0.8.1"
|
|
22
22
|
isort = "^5.12.0"
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"""Tools to query the SwitchBot API."""
|
|
2
|
+
|
|
2
3
|
import base64
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from enum import Enum
|
|
5
4
|
import hashlib
|
|
6
5
|
import hmac
|
|
7
6
|
import logging
|
|
8
7
|
import time
|
|
9
|
-
from typing import TypeVar
|
|
10
8
|
import uuid
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from enum import Enum
|
|
11
|
+
from typing import TypeVar
|
|
11
12
|
|
|
12
13
|
from aiohttp import ClientSession
|
|
13
14
|
|
|
@@ -146,6 +147,13 @@ class LightCommands(Commands):
|
|
|
146
147
|
BRIGHTNESS_DOWN = "brightnessDown"
|
|
147
148
|
|
|
148
149
|
|
|
150
|
+
class LockCommands(Commands):
|
|
151
|
+
"""Lock commands"""
|
|
152
|
+
|
|
153
|
+
LOCK = "lock"
|
|
154
|
+
UNLOCK = "unlock"
|
|
155
|
+
|
|
156
|
+
|
|
149
157
|
class CeilingLightCommands(Commands):
|
|
150
158
|
"""Ceiling light commands."""
|
|
151
159
|
|
|
@@ -221,7 +229,7 @@ class SwitchBotAPI:
|
|
|
221
229
|
_LOGGER.error("Error %s: %s", response.status, body)
|
|
222
230
|
raise CannotConnect()
|
|
223
231
|
|
|
224
|
-
async def list_devices(self):
|
|
232
|
+
async def list_devices(self) -> list[Device | Remote]:
|
|
225
233
|
"""List devices."""
|
|
226
234
|
body = await self._request("devices")
|
|
227
235
|
_LOGGER.debug("Devices: %s", body)
|
|
@@ -256,7 +264,7 @@ class SwitchBotAPI:
|
|
|
256
264
|
async def send_command(
|
|
257
265
|
self,
|
|
258
266
|
device_id: str,
|
|
259
|
-
command: T,
|
|
267
|
+
command: T | str,
|
|
260
268
|
command_type: str = "command",
|
|
261
269
|
parameters: dict | str = "default",
|
|
262
270
|
):
|
|
@@ -264,7 +272,7 @@ class SwitchBotAPI:
|
|
|
264
272
|
|
|
265
273
|
Args:
|
|
266
274
|
device_id (str): The ID of the device.
|
|
267
|
-
command (extends CommonCommands): The command to be sent.
|
|
275
|
+
command (string | extends CommonCommands): The command to be sent.
|
|
268
276
|
command_type (str, optional): The type of the command. Defaults to "command".
|
|
269
277
|
parameters (dict | str, optional): The parameters for the command. Defaults to "default".
|
|
270
278
|
|
|
@@ -277,7 +285,7 @@ class SwitchBotAPI:
|
|
|
277
285
|
"""
|
|
278
286
|
json = {
|
|
279
287
|
"commandType": command_type,
|
|
280
|
-
"command": command
|
|
288
|
+
"command": command if isinstance(command, Commands) else command,
|
|
281
289
|
"parameter": parameters,
|
|
282
290
|
}
|
|
283
291
|
await self._request(f"devices/{device_id}/commands", callback="post", json=json)
|
|
File without changes
|
|
File without changes
|