Skip to content

Commit 7c6d7b3

Browse files
authored
Merge pull request #2 from kzosabe/publish-first-version
Publish first version
2 parents cf011aa + 1938094 commit 7c6d7b3

13 files changed

Lines changed: 352 additions & 184 deletions

File tree

.github/workflows/main.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Delivery
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
branches:
8+
- main
9+
jobs:
10+
test:
11+
name: Run tests with pytest
12+
runs-on: ubuntu-latest
13+
strategy:
14+
matrix:
15+
python-version: [3.7, 3.8, 3.9]
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v2
19+
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v1
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- name: Install poetry
26+
run: |
27+
python -m pip install --upgrade pip
28+
python -m pip install poetry
29+
echo "$HOME/.local/bin" >> $GITHUB_PATH
30+
31+
- name: Load cached venv
32+
id: cached-poetry-dependencies
33+
uses: actions/cache@v2
34+
with:
35+
path: .venv
36+
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
37+
38+
- name: Install dependencies
39+
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
40+
run: poetry install --no-interaction --no-root
41+
42+
- name: Run Tests
43+
run: ./scripts/run_tests.sh

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
__pycache__/
22
*.py[cod]
33
*$py.class
4+
build/
5+
dist/
6+
.idea
47
!.keep

LICENSE-APACHE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
Apache License
23
Version 2.0, January 2004
34
http://www.apache.org/licenses/
@@ -198,4 +199,4 @@
198199
distributed under the License is distributed on an "AS IS" BASIS,
199200
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200201
See the License for the specific language governing permissions and
201-
limitations under the License.
202+
limitations under the License.

LICENSE-MIT

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
MIT License
2-
3-
Copyright (c) 2021 Arnav Yash Chandra <arnavyash2004@outlook.com>
4-
51
Permission is hereby granted, free of charge, to any person obtaining a copy
62
of this software and associated documentation files (the "Software"), to deal
73
in the Software without restriction, including without limitation the rights

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,47 @@ SwitchBotAPIResponse(status_code=100, message='success', body={})
139139
The specified scene can be executed immediately.
140140

141141

142+
### Examples
143+
144+
```python
145+
from switchbot_client.enums import ControlCommand
146+
from switchbot_client import SwitchBotAPIClient
147+
148+
149+
def control_all_infrared_remotes_by_type(type: str, command: str):
150+
client = SwitchBotAPIClient()
151+
devices = client.devices()
152+
infrared_remotes = devices.body["infraredRemoteList"]
153+
devices = filter(lambda d: d["remoteType"] == type, infrared_remotes)
154+
155+
for d in devices:
156+
client.devices_control(d["deviceId"], command)
157+
158+
159+
def call_this_function_when_i_go_out():
160+
print("turn off all lights and air conditioners...")
161+
control_all_infrared_remotes_by_type(
162+
"Light", ControlCommand.VirtualInfrared.TURN_OFF
163+
)
164+
control_all_infrared_remotes_by_type(
165+
"Air Conditioner", ControlCommand.VirtualInfrared.TURN_OFF
166+
)
167+
print("done")
168+
```
169+
142170
## License
143171

144172
Licensed under either of
145173

146-
- Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
147-
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
174+
* Apache License, Version 2.0
175+
([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
176+
* MIT license
177+
([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
148178

149179
at your option.
180+
181+
## Contribution
182+
183+
Unless you explicitly state otherwise, any contribution intentionally submitted
184+
for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
185+
dual licensed as above, without any additional terms or conditions.

0 commit comments

Comments
 (0)