Skip to content

Commit e3943c0

Browse files
Add K11+ for switchbot (#399)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ec39b4f commit e3943c0

File tree

4 files changed

+52
-1
lines changed

4 files changed

+52
-1
lines changed

switchbot/adv_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,12 @@ class SwitchbotSupportedType(TypedDict):
364364
"func": process_rgbic_light,
365365
"manufacturer_id": 2409,
366366
},
367+
b"\x00\x10\xfb\xa8": {
368+
"modelName": SwitchbotModel.K11_VACUUM,
369+
"modelFriendlyName": "K11+ Vacuum",
370+
"func": process_vacuum,
371+
"manufacturer_id": 2409,
372+
},
367373
}
368374

369375
_SWITCHBOT_MODEL_TO_CHAR = {

switchbot/const/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class SwitchbotModel(StrEnum):
9696
PLUG_MINI_EU = "Plug Mini (EU)"
9797
RGBICWW_STRIP_LIGHT = "RGBICWW Strip Light"
9898
RGBICWW_FLOOR_LAMP = "RGBICWW Floor Lamp"
99+
K11_VACUUM = "K11+ Vacuum"
99100

100101

101102
__all__ = [

tests/test_adv_parser.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3415,6 +3415,21 @@ def test_humidifer_with_empty_data() -> None:
34153415
"RGBICWW Strip Light",
34163416
SwitchbotModel.RGBICWW_STRIP_LIGHT,
34173417
),
3418+
AdvTestCase(
3419+
b"\xb0\xe9\xfe\xe4\xbf\xd8\x0b\x01\x11f\x00\x16M\x15",
3420+
b"\x00\x00M\x00\x10\xfb\xa8",
3421+
{
3422+
"battery": 77,
3423+
"mqtt_connected": True,
3424+
"sequence_number": 11,
3425+
"soc_version": "1.1.102",
3426+
"step": 6,
3427+
"work_status": 21,
3428+
},
3429+
b"\x00\x10\xfb\xa8",
3430+
"K11+ Vacuum",
3431+
SwitchbotModel.K11_VACUUM,
3432+
),
34183433
],
34193434
)
34203435
def test_adv_active(test_case: AdvTestCase) -> None:
@@ -3614,6 +3629,21 @@ def test_adv_active(test_case: AdvTestCase) -> None:
36143629
"RGBICWW Strip Light",
36153630
SwitchbotModel.RGBICWW_STRIP_LIGHT,
36163631
),
3632+
AdvTestCase(
3633+
b"\xb0\xe9\xfe\xe4\xbf\xd8\x0b\x01\x11f\x00\x16M\x15",
3634+
None,
3635+
{
3636+
"battery": 77,
3637+
"mqtt_connected": True,
3638+
"sequence_number": 11,
3639+
"soc_version": "1.1.102",
3640+
"step": 6,
3641+
"work_status": 21,
3642+
},
3643+
b"\x00\x10\xfb\xa8",
3644+
"K11+ Vacuum",
3645+
SwitchbotModel.K11_VACUUM,
3646+
),
36173647
],
36183648
)
36193649
def test_adv_passive(test_case: AdvTestCase) -> None:
@@ -3771,6 +3801,14 @@ def test_adv_passive(test_case: AdvTestCase) -> None:
37713801
"RGBICWW Strip Light",
37723802
SwitchbotModel.RGBICWW_STRIP_LIGHT,
37733803
),
3804+
AdvTestCase(
3805+
None,
3806+
b"\x00\x00M\x00\x10\xfb\xa8",
3807+
{},
3808+
b"\x00\x10\xfb\xa8",
3809+
"K11+ Vacuum",
3810+
SwitchbotModel.K11_VACUUM,
3811+
),
37743812
],
37753813
)
37763814
def test_adv_with_empty_data(test_case: AdvTestCase) -> None:

tests/test_vacuum.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
(b"3\x00\x00", ".", 2),
1616
(b"(\x00", "(", 1),
1717
(b"}\x00", "(", 1),
18+
(b"\x00\x00M\x00\x10\xfb\xa8", b"\x00\x10\xfb\xa8", 2),
1819
]
1920

2021

@@ -82,7 +83,12 @@ def make_advertisement_data(
8283
@pytest.mark.asyncio
8384
@pytest.mark.parametrize(
8485
("rawAdvData", "model"),
85-
[(b".\x00d", "."), (b"z\x00\x00", "z"), (b"3\x00\x00", "3")],
86+
[
87+
(b".\x00d", "."),
88+
(b"z\x00\x00", "z"),
89+
(b"3\x00\x00", "3"),
90+
(b"\x00\x00M\x00\x10\xfb\xa8", b"\x00\x10\xfb\xa8"),
91+
],
8692
)
8793
async def test_status_from_proceess_adv(rawAdvData: bytes, model: str) -> None:
8894
protocol_version = 2

0 commit comments

Comments
 (0)