From 2c2ae73f56a158c9c7e48177c51ba6f00b54aec2 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 19 Dec 2025 10:14:33 +0800 Subject: [PATCH 1/6] update makefile for format code:del complex code --- makefile | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/makefile b/makefile index 8a70cbc..1955c2d 100644 --- a/makefile +++ b/makefile @@ -5,11 +5,8 @@ install: build: poetry build -format:pre_commit - poetry run black switchbot_api/ - poetry run mypy switchbot_api/ - poetry run ruff check --fix switchbot_api/__init__.py - poetry run ruff check --output-format=github . +format: + poetry run pre-commit run --all-files clean: rm -rf dist @@ -19,6 +16,3 @@ test:test_update test_update: pytest --snapshot-update - -pre_commit: - poetry run pre-commit run end-of-file-fixer --all-files From 06dff4967c1c8eb361078b5617b57350404bd02d Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 19 Dec 2025 10:18:53 +0800 Subject: [PATCH 2/6] added Model BatteryLevel --- switchbot_api/models.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/switchbot_api/models.py b/switchbot_api/models.py index 0c52eaa..234b5fb 100644 --- a/switchbot_api/models.py +++ b/switchbot_api/models.py @@ -68,3 +68,26 @@ def get_all_modes(cls) -> list[SmartRadiatorThermostatMode]: cls.COMFORT, cls.FAST_HEATING, ] + + +class BatteryLevel(Enum): + """Battery Level modes.""" + + High = "high" + Medium = "medium" + Low = "low" + Critical = "critical" + Unknown = "unknown" + + @classmethod + def get_battery_level(cls, value: int) -> BatteryLevel: + """Return a battery level.""" + if 100 >= value >= 60: + return cls.High + if 60 > value >= 20: + return cls.Medium + if 20 > value >= 10: + return cls.Low + if 10 > value >= 0: + return cls.Critical + return cls.Unknown From c0e9e6a07f841a26297154886ee6948c35aae875 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 19 Dec 2025 10:48:03 +0800 Subject: [PATCH 3/6] added supported device for light commands --- switchbot_api/commands.py | 42 ++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/switchbot_api/commands.py b/switchbot_api/commands.py index 4738f95..febd165 100644 --- a/switchbot_api/commands.py +++ b/switchbot_api/commands.py @@ -190,13 +190,15 @@ class RGBWLightCommands(Commands): # Supported Device list: # Strip Light + # RGBIC Neon Rope Light + # RGBIC Neon Wire Rope Light SET_BRIGHTNESS = "setBrightness" SET_COLOR = "setColor" @classmethod def get_supported_devices(cls) -> list[str]: """Get supported devices.""" - return ["Strip Light"] + return ["Strip Light", "RGBIC Neon Rope Light", "RGBIC Neon Wire Rope Light"] class RGBWWLightCommands(Commands): @@ -206,6 +208,8 @@ class RGBWWLightCommands(Commands): # Floor Lamp # Strip Light 3 # Color Bulb + # RGBICWW Floor Lamp + # RGBICWW Strip Light SET_BRIGHTNESS = "setBrightness" SET_COLOR = "setColor" SET_COLOR_TEMPERATURE = "setColorTemperature" @@ -213,7 +217,27 @@ class RGBWWLightCommands(Commands): @classmethod def get_supported_devices(cls) -> list[str]: """Get supported devices.""" - return ["Strip Light 3", "Floor Lamp", "Color Bulb"] + return [ + "Strip Light 3", + "Floor Lamp", + "Color Bulb", + "RGBICWW Floor Lamp", + "RGBICWW Strip Light", + ] + + +class CeilingLightCommands(Commands): + """Ceiling light commands.""" + + # 1-100 + SET_BRIGHTNESS = "setBrightness" + # 2700-6500 + SET_COLOR_TEMPERATURE = "setColorTemperature" + + @classmethod + def get_supported_devices(cls) -> list[str]: + """Get supported devices.""" + return ["Ceiling Light", "Ceiling Light Pro"] class DoorBellCommands(Commands): @@ -285,20 +309,6 @@ def get_supported_devices(cls) -> list[str]: return ["Robot Vacuum Cleaner S10", "S20"] -class CeilingLightCommands(Commands): - """Ceiling light commands.""" - - # 1-100 - SET_BRIGHTNESS = "setBrightness" - # 2700-6500 - SET_COLOR_TEMPERATURE = "setColorTemperature" - - @classmethod - def get_supported_devices(cls) -> list[str]: - """Get supported devices.""" - return ["Ceiling Light", "Ceiling Light Pro"] - - class BlindTiltCommands(Commands): """Blind Tilt commands.""" From 33e4ba6826e413af2c4efb079764593ab23b13c0 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 19 Dec 2025 10:52:03 +0800 Subject: [PATCH 4/6] added ArtFrameCommands --- switchbot_api/commands.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/switchbot_api/commands.py b/switchbot_api/commands.py index febd165..628a274 100644 --- a/switchbot_api/commands.py +++ b/switchbot_api/commands.py @@ -240,6 +240,18 @@ def get_supported_devices(cls) -> list[str]: return ["Ceiling Light", "Ceiling Light Pro"] +class ArtFrameCommands(Commands): + """AI Art Frame commands.""" + + PREVIOUS = "previous" + NEXT = "next" + + @classmethod + def get_supported_devices(cls) -> list[str]: + """Get supported devices.""" + return ["AI Art Frame"] + + class DoorBellCommands(Commands): """Door Bell commands.""" From 60391361e6419831e3f93b1e2eac892a6859eb9a Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 19 Dec 2025 11:13:07 +0800 Subject: [PATCH 5/6] added KeyPadCommands --- switchbot_api/commands.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/switchbot_api/commands.py b/switchbot_api/commands.py index 628a274..f2f25e5 100644 --- a/switchbot_api/commands.py +++ b/switchbot_api/commands.py @@ -418,4 +418,16 @@ def get_supported_devices(cls) -> list[str]: return ["Smart Radiator Thermostat"] +class KeyPadCommands(Commands): + """Keypad commands.""" + + DELETE_KEY = "deleteKey" + CREATE_KEY = "createKey" + + @classmethod + def get_supported_devices(cls) -> list[str]: + """Get supported devices.""" + return ["Keypad", "Keypad Touch", "Keypad Vision", "Keypad Vision pro"] + + T = TypeVar("T", bound=CommonCommands) From c825a3318dadc0a5cf0656afff4e24c4e06d60d5 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 19 Dec 2025 11:18:49 +0800 Subject: [PATCH 6/6] update version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 553096f..15694e0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "switchbot_api" -version = "2.8.0" +version = "2.9.0" description = "An asynchronous library to use Switchbot API" authors = ["Ravaka Razafimanantsoa "] license = "MIT"