From a7f16d3cfd2f1b5b5bcf0961ca46c02e797fe827 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 10 Apr 2026 10:06:34 +0800 Subject: [PATCH 1/7] added --- switchbot_api/models.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/switchbot_api/models.py b/switchbot_api/models.py index 7dbf0b8..63fb2aa 100644 --- a/switchbot_api/models.py +++ b/switchbot_api/models.py @@ -12,6 +12,24 @@ class PowerState(Enum): OFF = "off" +class EntityType(Enum): + """Entity Type.""" + + BINARY_SENSOR = "binary_sensor" + BUTTON = "button" + CLIMATE = "climate" + COVER = "cover" + FAN = "fan" + HUMIDIFIER="humidifier" + IMAGE = "image" + LIGHT = "light" + LOCK ="lock" + SENSOR = "sensor" + SWITCH= "switch" + VACUUM = "vacuum" + + + class BatteryCirculatorFanMode(StrEnum): """Fan mode types [Battery Circulator Fan] API.""" From cbb08bd3bf4b06c4970d948893c9314533e89698 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 10 Apr 2026 15:25:01 +0800 Subject: [PATCH 2/7] added DeviceSupportMap --- switchbot_api/__init__.py | 4 + switchbot_api/models.py | 186 +++++++++++++++++++++++++++++++++++--- switchbot_api/utils.py | 6 ++ 3 files changed, 183 insertions(+), 13 deletions(-) diff --git a/switchbot_api/__init__.py b/switchbot_api/__init__.py index d0768be..2ad7bc1 100644 --- a/switchbot_api/__init__.py +++ b/switchbot_api/__init__.py @@ -62,6 +62,8 @@ AirPurifierMode, BatteryCirculatorFanMode, BatteryLevel, + DeviceSupportMap, + EntityType, PowerState, SmartRadiatorThermostatMode, VacuumCleanMode, @@ -86,7 +88,9 @@ "CurtainCommands", "DVDCommands", "Device", + "DeviceSupportMap", "DoorBellCommands", + "EntityType", "FanCommands", "HumidifierCommands", "HumidifierV2Commands", diff --git a/switchbot_api/models.py b/switchbot_api/models.py index 63fb2aa..b5f34dc 100644 --- a/switchbot_api/models.py +++ b/switchbot_api/models.py @@ -15,19 +15,179 @@ class PowerState(Enum): class EntityType(Enum): """Entity Type.""" - BINARY_SENSOR = "binary_sensor" - BUTTON = "button" - CLIMATE = "climate" - COVER = "cover" - FAN = "fan" - HUMIDIFIER="humidifier" - IMAGE = "image" - LIGHT = "light" - LOCK ="lock" - SENSOR = "sensor" - SWITCH= "switch" - VACUUM = "vacuum" - + BINARY_SENSOR = "binary_sensors" + BUTTON = "buttons" + CLIMATE = "climates" + COVER = "covers" + FAN = "fans" + HUMIDIFIER = "humidifiers" + IMAGE = "images" + LIGHT = "lights" + LOCK = "locks" + SENSOR = "sensors" + SWITCH = "switches" + VACUUM = "vacuums" + + +DeviceSupportMap: dict[str, dict[str, bool | list[EntityType]]] = { + "Smart Radiator Thermostat": { + "webhook": False, + "entity_list": [EntityType.CLIMATE, EntityType.SENSOR], + }, + "Relay Switch 1PM": { + "webhook": False, + "entity_list": [EntityType.SWITCH, EntityType.SENSOR], + }, + "Relay Switch 1": {"webhook": False, "entity_list": [EntityType.SWITCH]}, + "Relay Switch 2PM": { + "webhook": False, + "entity_list": [EntityType.SWITCH, EntityType.SENSOR], + }, + "K10+": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "K10+ Pro": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner S1": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner S1 Plus": { + "webhook": True, + "entity_list": [EntityType.VACUUM], + }, + "K20+ Pro": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner K10+ Pro Combo": { + "webhook": True, + "entity_list": [EntityType.VACUUM], + }, + "Robot Vacuum Cleaner S10": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner S20": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "S20": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner K11 Plus": { + "webhook": True, + "entity_list": [EntityType.VACUUM], + }, + "Smart Lock": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Lite": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Pro": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Ultra": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Vision": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Vision Pro": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Pro Wifi": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Lock Vision": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Lock Vision Pro": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Motion Sensor": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Contact Sensor": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Presence Sensor": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Hub 3": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Water Detector": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Battery Circulator Fan": { + "webhook": False, + "entity_list": [EntityType.FAN, EntityType.SENSOR], + }, + "Standing Fan": { + "webhook": False, + "entity_list": [EntityType.FAN, EntityType.SENSOR], + }, + "Circulator Fan": {"webhook": False, "entity_list": [EntityType.FAN]}, + "Curtain": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Curtain3": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Roller Shade": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Blind Tilt": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Strip Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Strip Light 3": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Floor Lamp": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Color Bulb": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBICWW Floor Lamp": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBICWW Strip Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Ceiling Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Ceiling Light Pro": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBIC Neon Rope Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBIC Neon Wire Rope Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Candle Warmer Lamp": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Humidifier2": {"webhook": False, "entity_list": [EntityType.HUMIDIFIER]}, + "Humidifier": { + "webhook": False, + "entity_list": [EntityType.HUMIDIFIER, EntityType.SENSOR], + }, + "Home Climate Panel": { + "webhook": False, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "AI Art Frame": { + "webhook": False, + "entity_list": [EntityType.BUTTON, EntityType.SENSOR, EntityType.IMAGE], + }, + "WeatherStation": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "Meter": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "MeterPlus": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "WoIOSensor": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "Hub 2": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "MeterPro": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "MeterPro(CO2)": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "Plug": {"webhook": False, "entity_list": [EntityType.SWITCH]}, + "Plug Mini (US)": { + "webhook": False, + "entity_list": [EntityType.SENSOR, EntityType.SWITCH], + }, + "Plug Mini (JP)": { + "webhook": False, + "entity_list": [EntityType.SENSOR, EntityType.SWITCH], + }, + "Plug Mini (EU)": { + "webhook": False, + "entity_list": [EntityType.SENSOR, EntityType.SWITCH], + }, +} class BatteryCirculatorFanMode(StrEnum): diff --git a/switchbot_api/utils.py b/switchbot_api/utils.py index f8e068b..96f1905 100644 --- a/switchbot_api/utils.py +++ b/switchbot_api/utils.py @@ -3,6 +3,7 @@ import aiohttp from aiohttp import ClientResponse +from . import DeviceSupportMap from .exceptions import SwitchBotDeviceRequestError @@ -26,3 +27,8 @@ async def get_file_stream_from_cloud(url: str, timeout: float = 5) -> bytes: except Exception as e: msg = f"{e}" raise SwitchBotDeviceRequestError(msg) from e + + +def assert_device_is_supported(device_model: str) -> bool: + """Determine whether the device is included in the supported list.""" + return device_model in DeviceSupportMap From f616370b98b3be6a1330c3eb56289220eacc27ce Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 10 Apr 2026 15:25:46 +0800 Subject: [PATCH 3/7] update version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 1dec4f5..d0c2f88 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "switchbot_api" -version = "2.11.0" +version = "2.12.0" description = "An asynchronous library to use Switchbot API" authors = ["Ravaka Razafimanantsoa "] license = "MIT" From 10b77fb15958926bad65b9684804bd81ddcedc9f Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 10 Apr 2026 10:06:34 +0800 Subject: [PATCH 4/7] added --- switchbot_api/models.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/switchbot_api/models.py b/switchbot_api/models.py index 7dbf0b8..63fb2aa 100644 --- a/switchbot_api/models.py +++ b/switchbot_api/models.py @@ -12,6 +12,24 @@ class PowerState(Enum): OFF = "off" +class EntityType(Enum): + """Entity Type.""" + + BINARY_SENSOR = "binary_sensor" + BUTTON = "button" + CLIMATE = "climate" + COVER = "cover" + FAN = "fan" + HUMIDIFIER="humidifier" + IMAGE = "image" + LIGHT = "light" + LOCK ="lock" + SENSOR = "sensor" + SWITCH= "switch" + VACUUM = "vacuum" + + + class BatteryCirculatorFanMode(StrEnum): """Fan mode types [Battery Circulator Fan] API.""" From 9ceb472607b318adbcb394efc3afb61222aa83e4 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 10 Apr 2026 15:25:01 +0800 Subject: [PATCH 5/7] added DeviceSupportMap --- switchbot_api/__init__.py | 4 + switchbot_api/models.py | 186 +++++++++++++++++++++++++++++++++++--- switchbot_api/utils.py | 6 ++ 3 files changed, 183 insertions(+), 13 deletions(-) diff --git a/switchbot_api/__init__.py b/switchbot_api/__init__.py index d41a234..0908323 100644 --- a/switchbot_api/__init__.py +++ b/switchbot_api/__init__.py @@ -62,6 +62,8 @@ AirPurifierMode, BatteryCirculatorFanMode, BatteryLevel, + DeviceSupportMap, + EntityType, PowerState, SmartRadiatorThermostatMode, VacuumCleanMode, @@ -86,7 +88,9 @@ "CurtainCommands", "DVDCommands", "Device", + "DeviceSupportMap", "DoorBellCommands", + "EntityType", "FanCommands", "HumidifierCommands", "HumidifierV2Commands", diff --git a/switchbot_api/models.py b/switchbot_api/models.py index 63fb2aa..b5f34dc 100644 --- a/switchbot_api/models.py +++ b/switchbot_api/models.py @@ -15,19 +15,179 @@ class PowerState(Enum): class EntityType(Enum): """Entity Type.""" - BINARY_SENSOR = "binary_sensor" - BUTTON = "button" - CLIMATE = "climate" - COVER = "cover" - FAN = "fan" - HUMIDIFIER="humidifier" - IMAGE = "image" - LIGHT = "light" - LOCK ="lock" - SENSOR = "sensor" - SWITCH= "switch" - VACUUM = "vacuum" - + BINARY_SENSOR = "binary_sensors" + BUTTON = "buttons" + CLIMATE = "climates" + COVER = "covers" + FAN = "fans" + HUMIDIFIER = "humidifiers" + IMAGE = "images" + LIGHT = "lights" + LOCK = "locks" + SENSOR = "sensors" + SWITCH = "switches" + VACUUM = "vacuums" + + +DeviceSupportMap: dict[str, dict[str, bool | list[EntityType]]] = { + "Smart Radiator Thermostat": { + "webhook": False, + "entity_list": [EntityType.CLIMATE, EntityType.SENSOR], + }, + "Relay Switch 1PM": { + "webhook": False, + "entity_list": [EntityType.SWITCH, EntityType.SENSOR], + }, + "Relay Switch 1": {"webhook": False, "entity_list": [EntityType.SWITCH]}, + "Relay Switch 2PM": { + "webhook": False, + "entity_list": [EntityType.SWITCH, EntityType.SENSOR], + }, + "K10+": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "K10+ Pro": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner S1": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner S1 Plus": { + "webhook": True, + "entity_list": [EntityType.VACUUM], + }, + "K20+ Pro": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner K10+ Pro Combo": { + "webhook": True, + "entity_list": [EntityType.VACUUM], + }, + "Robot Vacuum Cleaner S10": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner S20": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "S20": {"webhook": True, "entity_list": [EntityType.VACUUM]}, + "Robot Vacuum Cleaner K11 Plus": { + "webhook": True, + "entity_list": [EntityType.VACUUM], + }, + "Smart Lock": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Lite": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Pro": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Ultra": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Vision": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Vision Pro": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Smart Lock Pro Wifi": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Lock Vision": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Lock Vision Pro": { + "webhook": False, + "entity_list": [EntityType.LOCK, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Motion Sensor": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Contact Sensor": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Presence Sensor": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Hub 3": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Water Detector": { + "webhook": True, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "Battery Circulator Fan": { + "webhook": False, + "entity_list": [EntityType.FAN, EntityType.SENSOR], + }, + "Standing Fan": { + "webhook": False, + "entity_list": [EntityType.FAN, EntityType.SENSOR], + }, + "Circulator Fan": {"webhook": False, "entity_list": [EntityType.FAN]}, + "Curtain": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Curtain3": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Roller Shade": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Blind Tilt": { + "webhook": False, + "entity_list": [EntityType.COVER, EntityType.SENSOR, EntityType.BINARY_SENSOR], + }, + "Strip Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Strip Light 3": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Floor Lamp": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Color Bulb": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBICWW Floor Lamp": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBICWW Strip Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Ceiling Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Ceiling Light Pro": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBIC Neon Rope Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "RGBIC Neon Wire Rope Light": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Candle Warmer Lamp": {"webhook": False, "entity_list": [EntityType.LIGHT]}, + "Humidifier2": {"webhook": False, "entity_list": [EntityType.HUMIDIFIER]}, + "Humidifier": { + "webhook": False, + "entity_list": [EntityType.HUMIDIFIER, EntityType.SENSOR], + }, + "Home Climate Panel": { + "webhook": False, + "entity_list": [EntityType.BINARY_SENSOR, EntityType.SENSOR], + }, + "AI Art Frame": { + "webhook": False, + "entity_list": [EntityType.BUTTON, EntityType.SENSOR, EntityType.IMAGE], + }, + "WeatherStation": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "Meter": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "MeterPlus": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "WoIOSensor": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "Hub 2": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "MeterPro": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "MeterPro(CO2)": {"webhook": False, "entity_list": [EntityType.SENSOR]}, + "Plug": {"webhook": False, "entity_list": [EntityType.SWITCH]}, + "Plug Mini (US)": { + "webhook": False, + "entity_list": [EntityType.SENSOR, EntityType.SWITCH], + }, + "Plug Mini (JP)": { + "webhook": False, + "entity_list": [EntityType.SENSOR, EntityType.SWITCH], + }, + "Plug Mini (EU)": { + "webhook": False, + "entity_list": [EntityType.SENSOR, EntityType.SWITCH], + }, +} class BatteryCirculatorFanMode(StrEnum): diff --git a/switchbot_api/utils.py b/switchbot_api/utils.py index f8e068b..96f1905 100644 --- a/switchbot_api/utils.py +++ b/switchbot_api/utils.py @@ -3,6 +3,7 @@ import aiohttp from aiohttp import ClientResponse +from . import DeviceSupportMap from .exceptions import SwitchBotDeviceRequestError @@ -26,3 +27,8 @@ async def get_file_stream_from_cloud(url: str, timeout: float = 5) -> bytes: except Exception as e: msg = f"{e}" raise SwitchBotDeviceRequestError(msg) from e + + +def assert_device_is_supported(device_model: str) -> bool: + """Determine whether the device is included in the supported list.""" + return device_model in DeviceSupportMap From 78f97764f7fbf4839d0518c73f5fd3cc87befc54 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Fri, 10 Apr 2026 15:34:07 +0800 Subject: [PATCH 6/7] rebase --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index e6f6889..edc88e9 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "switchbot_api" -version = "2.11.1" +version = "2.12.0" description = "An asynchronous library to use Switchbot API" authors = ["Ravaka Razafimanantsoa "] license = "MIT" From 4edf22923cad0e57a0f93c2b34c4f114a648b090 Mon Sep 17 00:00:00 2001 From: XiaoLing-git Date: Tue, 14 Apr 2026 17:17:28 +0800 Subject: [PATCH 7/7] add model for lock --- switchbot_api/__init__.py | 4 ++++ switchbot_api/models.py | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/switchbot_api/__init__.py b/switchbot_api/__init__.py index 0908323..9055019 100644 --- a/switchbot_api/__init__.py +++ b/switchbot_api/__init__.py @@ -63,7 +63,9 @@ BatteryCirculatorFanMode, BatteryLevel, DeviceSupportMap, + DoorState, EntityType, + LockState, PowerState, SmartRadiatorThermostatMode, VacuumCleanMode, @@ -90,6 +92,7 @@ "Device", "DeviceSupportMap", "DoorBellCommands", + "DoorState", "EntityType", "FanCommands", "HumidifierCommands", @@ -97,6 +100,7 @@ "KeyPadCommands", "LightCommands", "LockCommands", + "LockState", "LockV2Commands", "LockV3Commands", "OthersCommands", diff --git a/switchbot_api/models.py b/switchbot_api/models.py index b5f34dc..ff5995e 100644 --- a/switchbot_api/models.py +++ b/switchbot_api/models.py @@ -286,3 +286,22 @@ def get_battery_level(cls, value: int) -> BatteryLevel: if 10 > value >= 0: return cls.Critical return cls.Unknown + + +class DoorState(Enum): + """Door State.""" + + OPEN = "open" + CLOSED = "close" + + +class LockState(Enum): + """Lock State.""" + + LOCKED = "locked" + UNLOCKED = "unlocked" + LOCKING = "locking" + UNLOCKING = "unlocking" + JAMMED = "jammed" + LATCH_BOLT_LOCKED = "latchBoltLocked" + HALF_LOCKED = "halfLocked"