switchbot-api 1.1.0__tar.gz → 1.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
- Name: switchbot-api
3
- Version: 1.1.0
2
+ Name: switchbot_api
3
+ Version: 1.2.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
@@ -29,3 +29,18 @@ print(await client.list_devices())
29
29
  print(await client.get_status('some-id'))
30
30
  await client.send_command('some-id', {COMMAND})
31
31
  ```
32
+
33
+ ## Development
34
+
35
+ ### Install
36
+
37
+ ```bash
38
+ poetry install
39
+ ```
40
+
41
+ ### Lint
42
+
43
+ ```bash
44
+ poetry run black switchbot_api/
45
+ poetry run mypy switchbot_api/
46
+ ```
@@ -11,4 +11,19 @@ client = SwitchBotAPI(token, secret)
11
11
  print(await client.list_devices())
12
12
  print(await client.get_status('some-id'))
13
13
  await client.send_command('some-id', {COMMAND})
14
+ ```
15
+
16
+ ## Development
17
+
18
+ ### Install
19
+
20
+ ```bash
21
+ poetry install
22
+ ```
23
+
24
+ ### Lint
25
+
26
+ ```bash
27
+ poetry run black switchbot_api/
28
+ poetry run mypy switchbot_api/
14
29
  ```
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "switchbot_api"
3
- version = "1.1.0"
3
+ version = "1.2.0"
4
4
  description = "An asynchronous library to use Switchbot API"
5
5
  authors = ["Ravaka Razafimanantsoa <contact@ravaka.dev>"]
6
6
  license = "MIT"
@@ -6,6 +6,7 @@ import hashlib
6
6
  import hmac
7
7
  import logging
8
8
  import time
9
+ from typing import TypeVar
9
10
  import uuid
10
11
 
11
12
  from aiohttp import ClientSession
@@ -13,7 +14,6 @@ from aiohttp import ClientSession
13
14
  _API_HOST = "https://api.switch-bot.com"
14
15
 
15
16
  _LOGGER = logging.getLogger(__name__)
16
- OBSERVED_DEVICE_TYPES = ["Remote", "Plug", "Plug Mini (US)", "Plug Mini (JP)"]
17
17
  NON_OBSERVED_REMOTE_TYPES = ["Others"]
18
18
 
19
19
 
@@ -84,11 +84,17 @@ class OthersCommands(Commands):
84
84
 
85
85
 
86
86
  class AirConditionerCommands(Commands):
87
- """xtending inherited Enum class "CommonCommands"pylint(invalid-enum-extensAir conditioner commands."""
87
+ """Air conditioner commands."""
88
88
 
89
89
  SET_ALL = "setAll" # parameter: {temperature},{mode},{fan speed},{power state}
90
90
 
91
91
 
92
+ class HumidifierCommands(Commands):
93
+ """Humidifier commands."""
94
+
95
+ SET_MODE = "setMode" # parameter: auto, set to Auto Mode, 101, set atomization efficiency to 34%,102, set atomization efficiency to 67%, 103, set atomization efficiency to 100%
96
+
97
+
92
98
  class TVCommands(Commands):
93
99
  """TV commands."""
94
100
 
@@ -136,6 +142,9 @@ class LightCommands(Commands):
136
142
  BRIGHTNESS_DOWN = "brightnessDown"
137
143
 
138
144
 
145
+ T = TypeVar("T", bound=CommonCommands)
146
+
147
+
139
148
  class SwitchBotAPI:
140
149
  """SwitchBot API."""
141
150
 
@@ -181,9 +190,7 @@ class SwitchBotAPI:
181
190
  """List devices."""
182
191
  body = await self._request_device("")
183
192
  _LOGGER.debug("Devices: %s", body)
184
- devices = [
185
- Device(**device) for device in body.get("deviceList") if device.get("deviceType") in OBSERVED_DEVICE_TYPES
186
- ]
193
+ devices = [Device(**device) for device in body.get("deviceList")]
187
194
  remotes = [
188
195
  Remote(**remote)
189
196
  for remote in body.get("infraredRemoteList")
@@ -199,7 +206,7 @@ class SwitchBotAPI:
199
206
  async def send_command(
200
207
  self,
201
208
  device_id: str,
202
- command: CommonCommands,
209
+ command: T,
203
210
  command_type: str = "command",
204
211
  parameters: dict | str = "default",
205
212
  ):
@@ -207,7 +214,7 @@ class SwitchBotAPI:
207
214
 
208
215
  Args:
209
216
  device_id (str): The ID of the device.
210
- command (CommonCommands): The command to be sent.
217
+ command (extends CommonCommands): The command to be sent.
211
218
  command_type (str, optional): The type of the command. Defaults to "command".
212
219
  parameters (dict | str, optional): The parameters for the command. Defaults to "default".
213
220
 
@@ -1,30 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- from setuptools import setup
3
-
4
- packages = \
5
- ['switchbot_api']
6
-
7
- package_data = \
8
- {'': ['*']}
9
-
10
- install_requires = \
11
- ['aiohttp>=3.8.4,<4.0.0']
12
-
13
- setup_kwargs = {
14
- 'name': 'switchbot-api',
15
- 'version': '1.1.0',
16
- 'description': 'An asynchronous library to use Switchbot API',
17
- 'long_description': '# py-switchbot-api\nAn asynchronous library to use Switchbot API. Allows to use both devices and remotes.\n\n## Usage\n\n```python\ntoken = "xxx"\nsecret = "yyy"\n\nclient = SwitchBotAPI(token, secret)\nprint(await client.list_devices())\nprint(await client.get_status(\'some-id\'))\nawait client.send_command(\'some-id\', {COMMAND})\n```',
18
- 'author': 'Ravaka Razafimanantsoa',
19
- 'author_email': 'contact@ravaka.dev',
20
- 'maintainer': 'None',
21
- 'maintainer_email': 'None',
22
- 'url': 'https://github.com/SeraphicCorp/py-switchbot-api',
23
- 'packages': packages,
24
- 'package_data': package_data,
25
- 'install_requires': install_requires,
26
- 'python_requires': '>=3.10,<4.0',
27
- }
28
-
29
-
30
- setup(**setup_kwargs)
File without changes