File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ from switchbot .adv_parser import parse_advertisement_data
2+ from bleak .backends .scanner import AdvertisementData
3+ from bleak .backends .device import BLEDevice
4+
5+ from switchbot .models import SwitchBotAdvertisement
6+
7+
8+ def test_parse_advertisement_data_curtain ():
9+ """Test parse_advertisement_data for curtain."""
10+ ble_device = BLEDevice ("aa:bb:cc:dd:ee:ff" , "any" )
11+ adv_data = AdvertisementData (
12+ manufacturer_data = {2409 : b"\xe7 \xab F\xac \x8f \x92 |\x0f \x00 \x11 \x04 " },
13+ service_data = {"0000fd3d-0000-1000-8000-00805f9b34fb" : b"c\xc0 X\x00 \x11 \x04 " },
14+ )
15+ result = parse_advertisement_data (ble_device , adv_data )
16+ assert result == SwitchBotAdvertisement (
17+ address = "aa:bb:cc:dd:ee:ff" ,
18+ data = {
19+ "address" : "aa:bb:cc:dd:ee:ff" ,
20+ "rawAdvData" : b"c\xc0 X\x00 \x11 \x04 " ,
21+ "data" : {
22+ "calibration" : True ,
23+ "battery" : 88 ,
24+ "inMotion" : False ,
25+ "position" : 100 ,
26+ "lightLevel" : 1 ,
27+ "deviceChain" : 1 ,
28+ "rssi" : 0 ,
29+ },
30+ "isEncrypted" : False ,
31+ "model" : "c" ,
32+ "model_friendly_name" : "Curtain" ,
33+ "modelName" : "WoCurtain" ,
34+ },
35+ device = ble_device ,
36+ )
You can’t perform that action at this time.
0 commit comments