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 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" diff --git a/switchbot_api/commands.py b/switchbot_api/commands.py index 4738f95..f2f25e5 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,39 @@ 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 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): @@ -285,20 +321,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.""" @@ -396,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) 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