Skip to content

Commit 502c689

Browse files
authored
Merge pull request #13 from kzosabe/release-0.1.2
Release 0.1.2
2 parents 8742a8a + 6442618 commit 502c689

12 files changed

Lines changed: 442 additions & 154 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
0.1.1, 2021-09-05
1+
0.1.2, 2021-09-11
22
-------------------------
33

4-
- Add [object interface](README.md#Object interface)
5-
- Add Python 3.6.x support
4+
- Support ~/.config/switchbot-client config file
5+
- Add object interface for all devices
6+
- Add Python >=3.6.0 support
7+
- Rename devices_control to devices_commands
68

79
0.1.1, 2021-09-05
810
-------------------------
911

10-
- Add basic implementation
12+
- Add [object interface](https://github.com/kzosabe/switchbot-client#object-interface)
13+
- Add Python >=3.6.2 support
14+
15+
0.1.0, 2021-09-04
16+
-------------------------
17+
18+
- Add basic implementation

README.md

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# switchbot-client
22

3-
An unofficial Python client implementation of the SwitchBot API.
4-
53
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/switchbot-client.svg)](https://pypi.org/project/switchbot-client/)
64
[![PyPI - Library Version](https://img.shields.io/pypi/v/switchbot-client.svg)](https://pypi.org/project/switchbot-client/)
75
[![PyPI - Downloads](https://img.shields.io/pypi/dm/switchbot-client)](https://pypi.org/project/switchbot-client)
86
[![License](https://img.shields.io/badge/license-MIT%2FApache--2.0-informational?style=flat-square)](README.md#License)
97
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
108

9+
An unofficial Python client implementation of the SwitchBot API.
1110

1211
## Table of Contents
1312

@@ -37,8 +36,10 @@ python3 your_script.py
3736

3837
```python
3938
# your_script.py
39+
from switchbot_client import SwitchBotAPIClient
40+
4041
client = SwitchBotAPIClient()
41-
result = client.devices()
42+
print(client.devices())
4243
```
4344

4445
### Constructor Arguments
@@ -50,9 +51,27 @@ from switchbot_client import SwitchBotAPIClient
5051

5152
your_token = "your_switchbot_open_token"
5253
client = SwitchBotAPIClient(token=your_token)
53-
result = client.devices()
54+
print(client.devices())
5455
```
5556

57+
### Config file
58+
59+
If `~/.config/switchbot-client/config.yml` exists and has a `token` entry,
60+
this client will automatically use the value.
61+
62+
```shell
63+
mkdir -p ~/.config/switchbot-client
64+
echo "token: your_switchbot_open_token" >> ~/.config/switchbot-client/config.yml
65+
python3 your_script.py
66+
```
67+
68+
```python
69+
# your_script.py
70+
from switchbot_client import SwitchBotAPIClient
71+
72+
client = SwitchBotAPIClient()
73+
print(client.devices())
74+
```
5675

5776
## Usage
5877

@@ -101,7 +120,7 @@ from switchbot_client import SwitchBotAPIClient, ControlCommand
101120

102121
client = SwitchBotAPIClient()
103122
device_id = "12345" # My Light(virtual infrared remote devices)
104-
print(client.devices_control(device_id, ControlCommand.VirtualInfrared.TURN_ON))
123+
print(client.devices_commands(device_id, ControlCommand.VirtualInfrared.TURN_ON))
105124
```
106125

107126
```
@@ -127,6 +146,7 @@ SwitchBotAPIResponse(status_code=100, message='success', body=[{'sceneId': '1234
127146
```
128147

129148
You can get a list of all the scenes associated with your SwitchBot account.
149+
Note that only manual scenes are returned from this api.
130150

131151
### Execute Scene
132152
```python
@@ -143,7 +163,7 @@ The specified scene can be executed immediately.
143163

144164
### Object interface
145165

146-
Devices can be manipulated via an easy-to-use object wrapped API(currently only some device types are supported).
166+
Devices can be manipulated via an easy-to-use object wrapped API.
147167

148168
```python
149169
from switchbot_client import SwitchBotAPIClient
@@ -180,7 +200,7 @@ def control_all_infrared_remotes_by_type(type: str, command: str):
180200
devices = filter(lambda d: d["remoteType"] == type, infrared_remotes)
181201

182202
for d in devices:
183-
client.devices_control(d["deviceId"], command)
203+
client.devices_commands(d["deviceId"], command)
184204

185205

186206
def call_this_function_when_i_go_out():

poetry.lock

Lines changed: 66 additions & 35 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "switchbot-client"
3-
version = "0.1.1"
3+
version = "0.1.2"
44
description = "A Python client library for SwitchBot API."
55
license = "Apache-2.0 or MIT"
66
authors = [
@@ -20,15 +20,16 @@ classifiers = [
2020
]
2121

2222
[tool.poetry.dependencies]
23-
python = "^3.6.2"
24-
requests = "^2.18"
23+
python = "^3.6"
24+
requests = "^2.0"
25+
PyYAML = "^5.1"
2526

2627
[tool.poetry.dev-dependencies]
27-
black = "^21.8b0"
28-
pylint = "^2.6"
29-
pytest = "^6.2"
30-
pytest-cov = "^2.10.1"
31-
pytest-mock = "^3.4.0"
28+
black = ">=18.5b1"
29+
pylint = "^2.0"
30+
pytest = "^6.0"
31+
pytest-cov = "^2.0"
32+
pytest-mock = "^3.0"
3233

3334
[build-system]
3435
requires = ["poetry-core>=1.0.0"]

switchbot_client/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
from switchbot_client.client import SwitchBotAPIClient, SwitchBotAPIResponse
2-
from switchbot_client.enums import ControlCommand
2+
from switchbot_client.enums import DeviceType, RemoteType, ControlCommand

0 commit comments

Comments
 (0)