diff --git a/README.md b/README.md index 0416571..4242e4d 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/makefile b/makefile new file mode 100644 index 0000000..8d91a38 --- /dev/null +++ b/makefile @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 716385e..eca652b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT" diff --git a/switchbot_api/__init__.py b/switchbot_api/__init__.py index b7143a6..75d6f1a 100644 --- a/switchbot_api/__init__.py +++ b/switchbot_api/__init__.py @@ -36,6 +36,8 @@ class Device: device_name: str device_type: str hub_device_id: str + group: bool + master: bool | None def __init__(self, **kwargs: Any) -> None: """Initialize.""" @@ -43,6 +45,8 @@ def __init__(self, **kwargs: Any) -> None: 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 diff --git a/tests/__snapshots__/test_client.ambr b/tests/__snapshots__/test_client.ambr index 22c6776..617270e 100644 --- a/tests/__snapshots__/test_client.ambr +++ b/tests/__snapshots__/test_client.ambr @@ -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',