Skip to content

Commit 507e9d3

Browse files
authored
add additional curtain tests (#137)
1 parent eca610a commit 507e9d3

File tree

1 file changed

+46
-7
lines changed

1 file changed

+46
-7
lines changed

tests/test_adv_parser.py

Lines changed: 46 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,31 +56,70 @@ def test_parse_advertisement_data_curtain():
5656
)
5757

5858

59+
def test_parse_advertisement_data_curtain_position_zero():
60+
"""Test parse_advertisement_data for curtain position zero."""
61+
ble_device = BLEDevice("aa:bb:cc:dd:ee:ff", "any")
62+
adv_data = generate_advertisement_data(
63+
local_name="WoCurtain",
64+
manufacturer_data={89: b"\xc1\xc7'}U\xab"},
65+
service_data={"00000d00-0000-1000-8000-00805f9b34fb": b"c\xd0\xced\x11\x04"},
66+
service_uuids=[
67+
"00001800-0000-1000-8000-00805f9b34fb",
68+
"00001801-0000-1000-8000-00805f9b34fb",
69+
"cba20d00-224d-11e6-9fb8-0002a5d5c51b",
70+
],
71+
rssi=-52,
72+
)
73+
result = parse_advertisement_data(ble_device, adv_data)
74+
assert result == SwitchBotAdvertisement(
75+
address="aa:bb:cc:dd:ee:ff",
76+
data={
77+
"rawAdvData": b"c\xd0\xced\x11\x04",
78+
"data": {
79+
"calibration": True,
80+
"battery": 78,
81+
"inMotion": False,
82+
"position": 0,
83+
"lightLevel": 1,
84+
"deviceChain": 1,
85+
},
86+
"isEncrypted": False,
87+
"model": "c",
88+
"modelFriendlyName": "Curtain",
89+
"modelName": SwitchbotModel.CURTAIN,
90+
},
91+
device=ble_device,
92+
rssi=-52,
93+
)
94+
95+
5996
def test_parse_advertisement_data_contact():
6097
"""Test parse_advertisement_data for the contact sensor."""
6198
ble_device = BLEDevice("aa:bb:cc:dd:ee:ff", "any")
6299
adv_data = generate_advertisement_data(
63100
manufacturer_data={2409: b"\xe7\xabF\xac\x8f\x92|\x0f\x00\x11\x04"},
64-
service_data={"0000fd3d-0000-1000-8000-00805f9b34fb": b'd@d\x05\x00u\x00\xf8\x12'},
101+
service_data={
102+
"0000fd3d-0000-1000-8000-00805f9b34fb": b"d@d\x05\x00u\x00\xf8\x12"
103+
},
65104
rssi=-80,
66105
)
67106
result = parse_advertisement_data(ble_device, adv_data)
68107
assert result == SwitchBotAdvertisement(
69108
address="aa:bb:cc:dd:ee:ff",
70109
data={
71-
"rawAdvData": b'd@d\x05\x00u\x00\xf8\x12',
110+
"rawAdvData": b"d@d\x05\x00u\x00\xf8\x12",
72111
"data": {
73112
"button_count": 2,
74-
'contact_open': True,
75-
'contact_timeout': True,
113+
"contact_open": True,
114+
"contact_timeout": True,
76115
"is_light": True,
77116
"battery": 100,
78-
'motion_detected': True,
79-
"tested": False
117+
"motion_detected": True,
118+
"tested": False,
80119
},
81120
"isEncrypted": False,
82121
"model": "d",
83-
"modelFriendlyName": 'Contact Sensor',
122+
"modelFriendlyName": "Contact Sensor",
84123
"modelName": SwitchbotModel.CONTACT_SENSOR,
85124
},
86125
device=ble_device,

0 commit comments

Comments
 (0)