Skip to content

Commit 4c00d30

Browse files
committed
Add support for the Meter Pro
1 parent a6cbf55 commit 4c00d30

File tree

3 files changed

+66
-0
lines changed

3 files changed

+66
-0
lines changed

switchbot/adv_parser.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ class SwitchbotSupportedType(TypedDict):
101101
"func": process_wosensorth,
102102
"manufacturer_id": 2409,
103103
},
104+
"4": {
105+
"modelName": SwitchbotModel.METER_PRO,
106+
"modelFriendlyName": "Meter",
107+
"func": process_wosensorth,
108+
"manufacturer_id": 2409,
109+
},
104110
"v": {
105111
"modelName": SwitchbotModel.HUB2,
106112
"modelFriendlyName": "Hub 2",

switchbot/const.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class SwitchbotModel(StrEnum):
4242
CONTACT_SENSOR = "WoContact"
4343
LIGHT_STRIP = "WoStrip"
4444
METER = "WoSensorTH"
45+
METER_PRO = "WoSensorTHP"
4546
IO_METER = "WoIOSensorTH"
4647
MOTION_SENSOR = "WoPresence"
4748
COLOR_BULB = "WoBulb"

tests/test_adv_parser.py

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,3 +1560,62 @@ def test_parsing_lock_passive_old_firmware():
15601560
rssi=-67,
15611561
active=False,
15621562
)
1563+
1564+
1565+
def test_meter_pro_active() -> None:
1566+
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")
1567+
adv_data = generate_advertisement_data(
1568+
manufacturer_data={2409: b"\xb0\xe9\xfeR\xdd\x84\x06d\x08\x97,\x00\x05"},
1569+
service_data={"0000fd3d-0000-1000-8000-00805f9b34fb": b"4\x00d"},
1570+
rssi=-67,
1571+
)
1572+
result = parse_advertisement_data(ble_device, adv_data)
1573+
assert result == SwitchBotAdvertisement(
1574+
address="aa:bb:cc:dd:ee:ff",
1575+
data={
1576+
"data": {
1577+
"battery": 100,
1578+
"fahrenheit": False,
1579+
"humidity": 44,
1580+
"temp": {"c": 23.8, "f": 74.84},
1581+
"temperature": 23.8,
1582+
},
1583+
"isEncrypted": False,
1584+
"model": "4",
1585+
"modelFriendlyName": "Meter",
1586+
"modelName": SwitchbotModel.METER_PRO,
1587+
"rawAdvData": b"4\x00d",
1588+
},
1589+
device=ble_device,
1590+
rssi=-67,
1591+
active=True,
1592+
)
1593+
1594+
1595+
def test_meter_pro_passive() -> None:
1596+
ble_device = generate_ble_device("aa:bb:cc:dd:ee:ff", "any")
1597+
adv_data = generate_advertisement_data(
1598+
manufacturer_data={2409: b"\xb0\xe9\xfeR\xdd\x84\x06d\x08\x97,\x00\x05"},
1599+
rssi=-67,
1600+
)
1601+
result = parse_advertisement_data(ble_device, adv_data, SwitchbotModel.METER_PRO)
1602+
assert result == SwitchBotAdvertisement(
1603+
address="aa:bb:cc:dd:ee:ff",
1604+
data={
1605+
"data": {
1606+
"battery": None,
1607+
"fahrenheit": False,
1608+
"humidity": 44,
1609+
"temp": {"c": 23.8, "f": 74.84},
1610+
"temperature": 23.8,
1611+
},
1612+
"isEncrypted": False,
1613+
"model": "4",
1614+
"modelFriendlyName": "Meter",
1615+
"modelName": SwitchbotModel.METER_PRO,
1616+
"rawAdvData": None,
1617+
},
1618+
device=ble_device,
1619+
rssi=-67,
1620+
active=False,
1621+
)

0 commit comments

Comments
 (0)