From 64cebbe9db11eac1df7a73811fc04e957e44581d Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 13 Jun 2025 14:23:13 +0800 Subject: [PATCH 01/10] add group&master attr for Device and Remote --- pyproject.toml | 2 +- switchbot_api/__init__.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 716385e..d0a8645 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "switchbot_api" -version = "2.5.0" +version = "2.5.1" 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..b571358 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 @@ -53,6 +57,8 @@ class Remote: device_name: str device_type: str hub_device_id: str + group: bool + master: bool def __init__(self, **kwargs: Any) -> None: """Initialize.""" @@ -60,6 +66,8 @@ def __init__(self, **kwargs: Any) -> None: self.device_name = kwargs["deviceName"] self.device_type = kwargs.get("remoteType", "-") self.hub_device_id = kwargs["hubDeviceId"] + self.group = kwargs.get("group", False) + self.master = kwargs.get("master") class PowerState(Enum): From 219d3884780533ba2380944f2fbba609f3e6bd16 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 13 Jun 2025 14:53:53 +0800 Subject: [PATCH 02/10] del useless code --- switchbot_api/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/switchbot_api/__init__.py b/switchbot_api/__init__.py index b571358..0ab7431 100644 --- a/switchbot_api/__init__.py +++ b/switchbot_api/__init__.py @@ -66,8 +66,6 @@ def __init__(self, **kwargs: Any) -> None: self.device_name = kwargs["deviceName"] self.device_type = kwargs.get("remoteType", "-") self.hub_device_id = kwargs["hubDeviceId"] - self.group = kwargs.get("group", False) - self.master = kwargs.get("master") class PowerState(Enum): From 0070833d3fa0a6db665052102a31a9d5e5d04e71 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 13 Jun 2025 14:54:51 +0800 Subject: [PATCH 03/10] del useless code --- switchbot_api/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/switchbot_api/__init__.py b/switchbot_api/__init__.py index 0ab7431..75d6f1a 100644 --- a/switchbot_api/__init__.py +++ b/switchbot_api/__init__.py @@ -57,8 +57,6 @@ class Remote: device_name: str device_type: str hub_device_id: str - group: bool - master: bool def __init__(self, **kwargs: Any) -> None: """Initialize.""" From fba844088dc309a12b829d7811ee84ceb99562d8 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 13 Jun 2025 16:43:30 +0800 Subject: [PATCH 04/10] reformat test code --- tests/__snapshots__/test_client.ambr | 8 ++++++++ 1 file changed, 8 insertions(+) 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', From d6a6031a00cc5b1ff0b168766edfa7abe0616b8d Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 13 Jun 2025 16:56:20 +0800 Subject: [PATCH 05/10] 1. added makefile \n 2.update readme.md --- README.md | 23 ++++++++++++++++++++--- makefile | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 makefile diff --git a/README.md b/README.md index 0416571..c26e165 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 format +``` + +### Clean + +```bash +make clean +``` \ No newline at end of file diff --git a/makefile b/makefile new file mode 100644 index 0000000..9421220 --- /dev/null +++ b/makefile @@ -0,0 +1,19 @@ + +install: + poetry install + +build: + poetry build + +format: + 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 From b37eb2aeac0c65271da2031ceba3015e92fb2d6c Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 13 Jun 2025 16:58:00 +0800 Subject: [PATCH 06/10] update readme.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c26e165..a45e4cd 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ make test ### build wheel ```bash -make format +make build ``` ### Clean From b4b066e0ce672436561fbed98a79d9558d1fa0e5 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 13 Jun 2025 17:06:18 +0800 Subject: [PATCH 07/10] update makefile --- README.md | 2 +- makefile | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index a45e4cd..4242e4d 100644 --- a/README.md +++ b/README.md @@ -43,4 +43,4 @@ make build ```bash make clean -``` \ No newline at end of file +``` diff --git a/makefile b/makefile index 9421220..b6e19d4 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,7 @@ install: build: poetry build -format: +format:pro_commit poetry run black switchbot_api/ poetry run mypy switchbot_api/ @@ -17,3 +17,6 @@ test:test_update test_update: pytest --snapshot-update + +pro_commit: + poetry run pre-commit run end-of-file-fixer --all-files From 944a2aacb95cba12719a02ad271708f0b32d712b Mon Sep 17 00:00:00 2001 From: Samuel Xiao <40679757+XiaoLing-git@users.noreply.github.com> Date: Tue, 17 Jun 2025 10:05:18 +0800 Subject: [PATCH 08/10] Update makefile Co-authored-by: Ravaka Razafimanantsoa <3774520+SeraphicRav@users.noreply.github.com> --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index b6e19d4..ffab462 100644 --- a/makefile +++ b/makefile @@ -18,5 +18,5 @@ test:test_update test_update: pytest --snapshot-update -pro_commit: +pre_commit: poetry run pre-commit run end-of-file-fixer --all-files From e727762c05f048e6ff014b6af8f1baa0b89ded46 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Tue, 17 Jun 2025 10:08:50 +0800 Subject: [PATCH 09/10] update makefile --- makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/makefile b/makefile index b6e19d4..8d91a38 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,7 @@ install: build: poetry build -format:pro_commit +format:pre_commit poetry run black switchbot_api/ poetry run mypy switchbot_api/ @@ -18,5 +18,5 @@ test:test_update test_update: pytest --snapshot-update -pro_commit: +pre_commit: poetry run pre-commit run end-of-file-fixer --all-files From a987f327d1ada8b1a785e8a6d9e6595fb2cce9fc Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Tue, 17 Jun 2025 10:11:10 +0800 Subject: [PATCH 10/10] update makefile --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d0a8645..eca652b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "switchbot_api" -version = "2.5.1" +version = "2.6.0" description = "An asynchronous library to use Switchbot API" authors = ["Ravaka Razafimanantsoa "] license = "MIT"