33from bleak .backends .device import BLEDevice
44
55from switchbot .models import SwitchBotAdvertisement
6+ from switchbot import SwitchbotModel
67
78
89def test_parse_advertisement_data_curtain ():
@@ -16,7 +17,6 @@ def test_parse_advertisement_data_curtain():
1617 assert result == SwitchBotAdvertisement (
1718 address = "aa:bb:cc:dd:ee:ff" ,
1819 data = {
19- "address" : "aa:bb:cc:dd:ee:ff" ,
2020 "rawAdvData" : b"c\xc0 X\x00 \x11 \x04 " ,
2121 "data" : {
2222 "calibration" : True ,
@@ -25,12 +25,11 @@ def test_parse_advertisement_data_curtain():
2525 "position" : 100 ,
2626 "lightLevel" : 1 ,
2727 "deviceChain" : 1 ,
28- "rssi" : 0 ,
2928 },
3029 "isEncrypted" : False ,
3130 "model" : "c" ,
3231 "modelFriendlyName" : "Curtain" ,
33- "modelName" : "WoCurtain" ,
32+ "modelName" : SwitchbotModel . CURTAIN ,
3433 },
3534 device = ble_device ,
3635 )
@@ -44,4 +43,27 @@ def test_parse_advertisement_data_empty():
4443 service_data = {"0000fd3d-0000-1000-8000-00805f9b34fb" : b"" },
4544 )
4645 result = parse_advertisement_data (ble_device , adv_data )
47- assert result is None
46+ assert result is None
47+
48+
49+ def test_new_bot_firmware ():
50+ """Test parsing adv data from new bot firmware."""
51+ ble_device = BLEDevice ("aa:bb:cc:dd:ee:ff" , "any" )
52+ adv_data = AdvertisementData (
53+ manufacturer_data = {89 : b"\xd8 .\xad \xcd \r \x85 " },
54+ service_data = {"00000d00-0000-1000-8000-00805f9b34fb" : b"H\x10 \xe1 " },
55+ service_uuids = ["CBA20D00-224D-11E6-9FB8-0002A5D5C51B" ],
56+ )
57+ result = parse_advertisement_data (ble_device , adv_data )
58+ assert result == SwitchBotAdvertisement (
59+ address = "aa:bb:cc:dd:ee:ff" ,
60+ data = {
61+ "rawAdvData" : b"H\x10 \xe1 " ,
62+ "data" : {"switchMode" : False , "isOn" : False , "battery" : 97 },
63+ "model" : "H" ,
64+ "isEncrypted" : False ,
65+ "modelFriendlyName" : "Bot" ,
66+ "modelName" : SwitchbotModel .BOT ,
67+ },
68+ device = ble_device ,
69+ )
0 commit comments