Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,29 @@ await client.send_command('some-id', {COMMAND})
### Install

```bash
poetry install
make install
```

### Lint

```bash
poetry run black switchbot_api/
poetry run mypy switchbot_api/
make format
```

### Test

```bash
make test
```

### build wheel

```bash
make build
```

### Clean

```bash
make clean
```
22 changes: 22 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

install:
poetry install

build:
poetry build

format:pre_commit
poetry run black switchbot_api/
poetry run mypy switchbot_api/

clean:
rm -rf dist

test:test_update
poetry run pytest --cov vehicle tests

test_update:
pytest --snapshot-update

pre_commit:
poetry run pre-commit run end-of-file-fixer --all-files
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "switchbot_api"
version = "2.5.0"
version = "2.6.0"
description = "An asynchronous library to use Switchbot API"
authors = ["Ravaka Razafimanantsoa <contact@ravaka.dev>"]
license = "MIT"
Expand Down
4 changes: 4 additions & 0 deletions switchbot_api/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ class Device:
device_name: str
device_type: str
hub_device_id: str
group: bool
master: bool | None

def __init__(self, **kwargs: Any) -> None:
"""Initialize."""
self.device_id = kwargs["deviceId"]
self.device_name = kwargs["deviceName"]
self.device_type = kwargs.get("deviceType", "-")
self.hub_device_id = kwargs["hubDeviceId"]
self.group = kwargs.get("group", False)
self.master = kwargs.get("master")


@dataclass
Expand Down
8 changes: 8 additions & 0 deletions tests/__snapshots__/test_client.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,33 @@
'device_id': 'D82812821F08',
'device_name': 'Hub 2 08',
'device_type': 'Hub 2',
'group': False,
'hub_device_id': '',
'master': None,
}),
dict({
'device_id': 'E2562C1DCC1A',
'device_name': 'Curtain 1A',
'device_type': 'Curtain3',
'group': False,
'hub_device_id': 'D82812821F08',
'master': True,
}),
dict({
'device_id': 'FCE84BB8B04F',
'device_name': 'Curtain 4F',
'device_type': 'Curtain',
'group': False,
'hub_device_id': '',
'master': True,
}),
dict({
'device_id': 'FF711F51601E',
'device_name': 'Curtain 1E',
'device_type': 'Curtain3',
'group': False,
'hub_device_id': 'D82812821F08',
'master': True,
}),
dict({
'device_id': '01-202501201703-63754985',
Expand Down
Loading