switchbot-api 1.2.1__tar.gz → 1.3.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-1.2.1 → switchbot_api-1.3.0}/PKG-INFO +2 -1
- {switchbot_api-1.2.1 → switchbot_api-1.3.0}/pyproject.toml +1 -1
- {switchbot_api-1.2.1 → switchbot_api-1.3.0}/switchbot_api/__init__.py +31 -7
- {switchbot_api-1.2.1 → switchbot_api-1.3.0}/LICENSE +0 -0
- {switchbot_api-1.2.1 → switchbot_api-1.3.0}/README.md +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: switchbot_api
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.3.0
|
|
4
4
|
Summary: An asynchronous library to use Switchbot API
|
|
5
5
|
Home-page: https://github.com/SeraphicCorp/py-switchbot-api
|
|
6
6
|
License: MIT
|
|
@@ -11,6 +11,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
11
11
|
Classifier: Programming Language :: Python :: 3
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.10
|
|
13
13
|
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
15
|
Requires-Dist: aiohttp (>=3.8.4,<4.0.0)
|
|
15
16
|
Project-URL: Repository, https://github.com/SeraphicCorp/py-switchbot-api
|
|
16
17
|
Description-Content-Type: text/markdown
|
|
@@ -38,7 +38,7 @@ class Device:
|
|
|
38
38
|
"""Initialize."""
|
|
39
39
|
self.device_id = kwargs["deviceId"]
|
|
40
40
|
self.device_name = kwargs["deviceName"]
|
|
41
|
-
self.device_type = kwargs.get("deviceType",
|
|
41
|
+
self.device_type = kwargs.get("deviceType", "-")
|
|
42
42
|
self.hub_device_id = kwargs["hubDeviceId"]
|
|
43
43
|
|
|
44
44
|
|
|
@@ -55,7 +55,7 @@ class Remote:
|
|
|
55
55
|
"""Initialize."""
|
|
56
56
|
self.device_id = kwargs["deviceId"]
|
|
57
57
|
self.device_name = kwargs["deviceName"]
|
|
58
|
-
self.device_type = kwargs.get("remoteType",
|
|
58
|
+
self.device_type = kwargs.get("remoteType", "-")
|
|
59
59
|
self.hub_device_id = kwargs["hubDeviceId"]
|
|
60
60
|
|
|
61
61
|
|
|
@@ -142,6 +142,15 @@ class LightCommands(Commands):
|
|
|
142
142
|
BRIGHTNESS_DOWN = "brightnessDown"
|
|
143
143
|
|
|
144
144
|
|
|
145
|
+
class VacuumCommands(Commands):
|
|
146
|
+
"""Vacuum commands."""
|
|
147
|
+
|
|
148
|
+
START = "start"
|
|
149
|
+
STOP = "stop"
|
|
150
|
+
DOCK = "dock"
|
|
151
|
+
POW_LEVEL = "PowLevel"
|
|
152
|
+
|
|
153
|
+
|
|
145
154
|
T = TypeVar("T", bound=CommonCommands)
|
|
146
155
|
|
|
147
156
|
|
|
@@ -171,10 +180,10 @@ class SwitchBotAPI:
|
|
|
171
180
|
"nonce": str(nonce),
|
|
172
181
|
}
|
|
173
182
|
|
|
174
|
-
async def
|
|
183
|
+
async def _request(self, path: str = "", callback: str = "get", json=None):
|
|
175
184
|
async with ClientSession() as session:
|
|
176
185
|
async with getattr(session, callback)(
|
|
177
|
-
f"{_API_HOST}/v1.1/
|
|
186
|
+
f"{_API_HOST}/v1.1/{path}",
|
|
178
187
|
headers=self.make_headers(self.token, self.secret),
|
|
179
188
|
json=json,
|
|
180
189
|
) as response:
|
|
@@ -188,7 +197,7 @@ class SwitchBotAPI:
|
|
|
188
197
|
|
|
189
198
|
async def list_devices(self):
|
|
190
199
|
"""List devices."""
|
|
191
|
-
body = await self.
|
|
200
|
+
body = await self._request("devices")
|
|
192
201
|
_LOGGER.debug("Devices: %s", body)
|
|
193
202
|
devices = [Device(**device) for device in body.get("deviceList")]
|
|
194
203
|
remotes = [
|
|
@@ -200,9 +209,24 @@ class SwitchBotAPI:
|
|
|
200
209
|
|
|
201
210
|
async def get_status(self, device_id: str):
|
|
202
211
|
"""No status for IR devices."""
|
|
203
|
-
body = await self.
|
|
212
|
+
body = await self._request(f"devices/{device_id}/status")
|
|
204
213
|
return body
|
|
205
214
|
|
|
215
|
+
async def get_webook_configuration(self):
|
|
216
|
+
"""List webhooks."""
|
|
217
|
+
json = {"action": "queryUrl"}
|
|
218
|
+
return await self._request("webhook/queryWebhook", callback="post", json=json)
|
|
219
|
+
|
|
220
|
+
async def setup_webhook(self, url: str):
|
|
221
|
+
"""Setup webhook to receive device status updates."""
|
|
222
|
+
json = {"deviceList": "ALL", "action": "setupWebhook", "url": url}
|
|
223
|
+
await self._request("webhook/setupWebhook", callback="post", json=json)
|
|
224
|
+
|
|
225
|
+
async def delete_webhook(self, url: str):
|
|
226
|
+
"""Delete webhook."""
|
|
227
|
+
json = {"action": "deleteWebhook", "url": url}
|
|
228
|
+
await self._request("webhook/deleteWebhook", callback="post", json=json)
|
|
229
|
+
|
|
206
230
|
async def send_command(
|
|
207
231
|
self,
|
|
208
232
|
device_id: str,
|
|
@@ -230,4 +254,4 @@ class SwitchBotAPI:
|
|
|
230
254
|
"command": command.value,
|
|
231
255
|
"parameter": parameters,
|
|
232
256
|
}
|
|
233
|
-
await self.
|
|
257
|
+
await self._request(f"devices/{device_id}/commands", callback="post", json=json)
|
|
File without changes
|
|
File without changes
|