Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions switchbot/adv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,12 @@ class SwitchbotSupportedType(TypedDict):
"func": process_rgbic_light,
"manufacturer_id": 2409,
},
b"\x00\x10\xfb\xa8": {
"modelName": SwitchbotModel.K11_VACUUM,
"modelFriendlyName": "K11+ Vacuum",
"func": process_vacuum,
"manufacturer_id": 2409,
},
}

_SWITCHBOT_MODEL_TO_CHAR = {
Expand Down
1 change: 1 addition & 0 deletions switchbot/const/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ class SwitchbotModel(StrEnum):
PLUG_MINI_EU = "Plug Mini (EU)"
RGBICWW_STRIP_LIGHT = "RGBICWW Strip Light"
RGBICWW_FLOOR_LAMP = "RGBICWW Floor Lamp"
K11_VACUUM = "K11+ Vacuum"


__all__ = [
Expand Down
38 changes: 38 additions & 0 deletions tests/test_adv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -3415,6 +3415,21 @@ def test_humidifer_with_empty_data() -> None:
"RGBICWW Strip Light",
SwitchbotModel.RGBICWW_STRIP_LIGHT,
),
AdvTestCase(
b"\xb0\xe9\xfe\xe4\xbf\xd8\x0b\x01\x11f\x00\x16M\x15",
b"\x00\x00M\x00\x10\xfb\xa8",
{
"battery": 77,
"mqtt_connected": True,
"sequence_number": 11,
"soc_version": "1.1.102",
"step": 6,
"work_status": 21,
},
b"\x00\x10\xfb\xa8",
"K11+ Vacuum",
SwitchbotModel.K11_VACUUM,
),
],
)
def test_adv_active(test_case: AdvTestCase) -> None:
Expand Down Expand Up @@ -3614,6 +3629,21 @@ def test_adv_active(test_case: AdvTestCase) -> None:
"RGBICWW Strip Light",
SwitchbotModel.RGBICWW_STRIP_LIGHT,
),
AdvTestCase(
b"\xb0\xe9\xfe\xe4\xbf\xd8\x0b\x01\x11f\x00\x16M\x15",
None,
{
"battery": 77,
"mqtt_connected": True,
"sequence_number": 11,
"soc_version": "1.1.102",
"step": 6,
"work_status": 21,
},
b"\x00\x10\xfb\xa8",
"K11+ Vacuum",
SwitchbotModel.K11_VACUUM,
),
],
)
def test_adv_passive(test_case: AdvTestCase) -> None:
Expand Down Expand Up @@ -3771,6 +3801,14 @@ def test_adv_passive(test_case: AdvTestCase) -> None:
"RGBICWW Strip Light",
SwitchbotModel.RGBICWW_STRIP_LIGHT,
),
AdvTestCase(
None,
b"\x00\x00M\x00\x10\xfb\xa8",
{},
b"\x00\x10\xfb\xa8",
"K11+ Vacuum",
SwitchbotModel.K11_VACUUM,
),
],
)
def test_adv_with_empty_data(test_case: AdvTestCase) -> None:
Expand Down
8 changes: 7 additions & 1 deletion tests/test_vacuum.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
(b"3\x00\x00", ".", 2),
(b"(\x00", "(", 1),
(b"}\x00", "(", 1),
(b"\x00\x00M\x00\x10\xfb\xa8", b"\x00\x10\xfb\xa8", 2),
]


Expand Down Expand Up @@ -82,7 +83,12 @@ def make_advertisement_data(
@pytest.mark.asyncio
@pytest.mark.parametrize(
("rawAdvData", "model"),
[(b".\x00d", "."), (b"z\x00\x00", "z"), (b"3\x00\x00", "3")],
[
(b".\x00d", "."),
(b"z\x00\x00", "z"),
(b"3\x00\x00", "3"),
(b"\x00\x00M\x00\x10\xfb\xa8", b"\x00\x10\xfb\xa8"),
],
)
async def test_status_from_proceess_adv(rawAdvData: bytes, model: str) -> None:
protocol_version = 2
Expand Down