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 @@ -101,6 +101,12 @@ class SwitchbotSupportedType(TypedDict):
"func": process_wosensorth,
"manufacturer_id": 2409,
},
"4": {
"modelName": SwitchbotModel.METER_PRO,
"modelFriendlyName": "Meter",
"func": process_wosensorth,
"manufacturer_id": 2409,
},
"v": {
"modelName": SwitchbotModel.HUB2,
"modelFriendlyName": "Hub 2",
Expand Down
1 change: 1 addition & 0 deletions switchbot/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class SwitchbotModel(StrEnum):
CONTACT_SENSOR = "WoContact"
LIGHT_STRIP = "WoStrip"
METER = "WoSensorTH"
METER_PRO = "WoSensorTHP"
IO_METER = "WoIOSensorTH"
MOTION_SENSOR = "WoPresence"
COLOR_BULB = "WoBulb"
Expand Down
59 changes: 59 additions & 0 deletions tests/test_adv_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,3 +1560,62 @@ def test_parsing_lock_passive_old_firmware():
rssi=-67,
active=False,
)


def test_meter_pro_active() -> None:
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")
adv_data = generate_advertisement_data(
manufacturer_data={2409: b"\xb0\xe9\xfeR\xdd\x84\x06d\x08\x97,\x00\x05"},
service_data={"0000fd3d-0000-1000-8000-00805f9b34fb": b"4\x00d"},
rssi=-67,
)
result = parse_advertisement_data(ble_device, adv_data)
assert result == SwitchBotAdvertisement(
address="aa:bb:cc:dd:ee:ff",
data={
"data": {
"battery": 100,
"fahrenheit": False,
"humidity": 44,
"temp": {"c": 23.8, "f": 74.84},
"temperature": 23.8,
},
"isEncrypted": False,
"model": "4",
"modelFriendlyName": "Meter",
"modelName": SwitchbotModel.METER_PRO,
"rawAdvData": b"4\x00d",
},
device=ble_device,
rssi=-67,
active=True,
)


def test_meter_pro_passive() -> None:
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")
adv_data = generate_advertisement_data(
manufacturer_data={2409: b"\xb0\xe9\xfeR\xdd\x84\x06d\x08\x97,\x00\x05"},
rssi=-67,
)
result = parse_advertisement_data(ble_device, adv_data, SwitchbotModel.METER_PRO)
assert result == SwitchBotAdvertisement(
address="aa:bb:cc:dd:ee:ff",
data={
"data": {
"battery": None,
"fahrenheit": False,
"humidity": 44,
"temp": {"c": 23.8, "f": 74.84},
"temperature": 23.8,
},
"isEncrypted": False,
"model": "4",
"modelFriendlyName": "Meter",
"modelName": SwitchbotModel.METER_PRO,
"rawAdvData": None,
},
device=ble_device,
rssi=-67,
active=False,
)
Loading