From 848330223309c1fcea993cc8d44242841d7121fe Mon Sep 17 00:00:00 2001 From: zerzhang <916250497@qq.com> Date: Thu, 6 Nov 2025 11:10:28 +0800 Subject: [PATCH] add support for s20 --- .../components/switchbot/__init__.py | 2 ++ homeassistant/components/switchbot/const.py | 2 ++ tests/components/switchbot/__init__.py | 25 +++++++++++++++++++ tests/components/switchbot/test_vacuum.py | 2 ++ 4 files changed, 31 insertions(+) diff --git a/homeassistant/components/switchbot/__init__.py b/homeassistant/components/switchbot/__init__.py index 84af2e2761d340..04f69548a4244e 100644 --- a/homeassistant/components/switchbot/__init__.py +++ b/homeassistant/components/switchbot/__init__.py @@ -75,6 +75,7 @@ SupportedModels.HUBMINI_MATTER.value: [Platform.SENSOR], SupportedModels.CIRCULATOR_FAN.value: [Platform.FAN, Platform.SENSOR], SupportedModels.S10_VACUUM.value: [Platform.VACUUM, Platform.SENSOR], + SupportedModels.S20_VACUUM.value: [Platform.VACUUM, Platform.SENSOR], SupportedModels.K10_VACUUM.value: [Platform.VACUUM, Platform.SENSOR], SupportedModels.K10_PRO_VACUUM.value: [Platform.VACUUM, Platform.SENSOR], SupportedModels.K10_PRO_COMBO_VACUUM.value: [Platform.VACUUM, Platform.SENSOR], @@ -123,6 +124,7 @@ SupportedModels.ROLLER_SHADE.value: switchbot.SwitchbotRollerShade, SupportedModels.CIRCULATOR_FAN.value: switchbot.SwitchbotFan, SupportedModels.S10_VACUUM.value: switchbot.SwitchbotVacuum, + SupportedModels.S20_VACUUM.value: switchbot.SwitchbotVacuum, SupportedModels.K10_VACUUM.value: switchbot.SwitchbotVacuum, SupportedModels.K10_PRO_VACUUM.value: switchbot.SwitchbotVacuum, SupportedModels.K10_PRO_COMBO_VACUUM.value: switchbot.SwitchbotVacuum, diff --git a/homeassistant/components/switchbot/const.py b/homeassistant/components/switchbot/const.py index 3925aa4a58928a..b2677fee38c970 100644 --- a/homeassistant/components/switchbot/const.py +++ b/homeassistant/components/switchbot/const.py @@ -59,6 +59,7 @@ class SupportedModels(StrEnum): GARAGE_DOOR_OPENER = "garage_door_opener" CLIMATE_PANEL = "climate_panel" SMART_THERMOSTAT_RADIATOR = "smart_thermostat_radiator" + S20_VACUUM = "s20_vacuum" CONNECTABLE_SUPPORTED_MODEL_TYPES = { @@ -79,6 +80,7 @@ class SupportedModels(StrEnum): SwitchbotModel.CIRCULATOR_FAN: SupportedModels.CIRCULATOR_FAN, SwitchbotModel.K20_VACUUM: SupportedModels.K20_VACUUM, SwitchbotModel.S10_VACUUM: SupportedModels.S10_VACUUM, + SwitchbotModel.S20_VACUUM: SupportedModels.S20_VACUUM, SwitchbotModel.K10_VACUUM: SupportedModels.K10_VACUUM, SwitchbotModel.K10_PRO_VACUUM: SupportedModels.K10_PRO_VACUUM, SwitchbotModel.K10_PRO_COMBO_VACUUM: SupportedModels.K10_PRO_COMBO_VACUUM, diff --git a/tests/components/switchbot/__init__.py b/tests/components/switchbot/__init__.py index 86de074202c6b5..16550d955e97a3 100644 --- a/tests/components/switchbot/__init__.py +++ b/tests/components/switchbot/__init__.py @@ -1223,3 +1223,28 @@ def make_advertisement( connectable=True, tx_power=-127, ) + + +S20_VACUUM_SERVICE_INFO = BluetoothServiceInfoBleak( + name="S20 Vacuum", + manufacturer_data={2409: b"\xb0\xe9\xfe\xc3\x1a!:\x01\x11\x1e\x00\x00d\x03"}, + service_data={ + "0000fd3d-0000-1000-8000-00805f9b34fb": b"\x00\x00d\x00\x10\xe0P", + }, + service_uuids=["cba20d00-224d-11e6-9fb8-0002a5d5c51b"], + address="AA:BB:CC:DD:EE:FF", + rssi=-60, + source="local", + advertisement=generate_advertisement_data( + local_name="S20 Vacuum", + manufacturer_data={2409: b"\xb0\xe9\xfe\xc3\x1a!:\x01\x11\x1e\x00\x00d\x03"}, + service_data={ + "0000fd3d-0000-1000-8000-00805f9b34fb": b"\x00\x00d\x00\x10\xe0P", + }, + service_uuids=["cba20d00-224d-11e6-9fb8-0002a5d5c51b"], + ), + device=generate_ble_device("AA:BB:CC:DD:EE:FF", "S20 Vacuum"), + time=0, + connectable=True, + tx_power=-127, +) diff --git a/tests/components/switchbot/test_vacuum.py b/tests/components/switchbot/test_vacuum.py index 5cc579db99c2c8..34af12e0ea6ded 100644 --- a/tests/components/switchbot/test_vacuum.py +++ b/tests/components/switchbot/test_vacuum.py @@ -21,6 +21,7 @@ K11_PLUS_VACUUM_SERVICE_INFO, K20_VACUUM_SERVICE_INFO, S10_VACUUM_SERVICE_INFO, + S20_VACUUM_SERVICE_INFO, ) from tests.common import MockConfigEntry @@ -36,6 +37,7 @@ ("k10_vacuum", K10_VACUUM_SERVICE_INFO), ("k10_pro_vacuum", K10_PRO_VACUUM_SERVICE_INFO), ("k11+_vacuum", K11_PLUS_VACUUM_SERVICE_INFO), + ("s20_vacuum", S20_VACUUM_SERVICE_INFO), ], ) @pytest.mark.parametrize(