@@ -118,13 +118,13 @@ def test_parse_advertisement_data_curtain_firmware_six_position_100():
118118 assert result == SwitchBotAdvertisement (
119119 address = "aa:bb:cc:dd:ee:ff" ,
120120 data = {
121- "rawAdvData" : b"c \xd0 H \x00 \x12 \ x04" ,
121+ "rawAdvData" : b'c \xc0 G \x00 " \ x04' ,
122122 "data" : {
123123 "calibration" : True ,
124- "battery" : 72 ,
124+ "battery" : 71 ,
125125 "inMotion" : False ,
126126 "position" : 100 ,
127- "lightLevel" : 1 ,
127+ "lightLevel" : 2 ,
128128 "deviceChain" : 2 ,
129129 },
130130 "isEncrypted" : False ,
@@ -161,13 +161,13 @@ def test_parse_advertisement_data_curtain_firmware_six_position_100_other_rssi()
161161 assert result == SwitchBotAdvertisement (
162162 address = "aa:bb:cc:dd:ee:ff" ,
163163 data = {
164- "rawAdvData" : b"c \xd0 H \x00 \x12 \ x04" ,
164+ "rawAdvData" : b'c \xc0 Gc" \ x04' ,
165165 "data" : {
166166 "calibration" : True ,
167- "battery" : 72 ,
167+ "battery" : 71 ,
168168 "inMotion" : False ,
169- "position" : 100 ,
170- "lightLevel" : 1 ,
169+ "position" : 1 ,
170+ "lightLevel" : 2 ,
171171 "deviceChain" : 2 ,
172172 },
173173 "isEncrypted" : False ,
@@ -322,3 +322,89 @@ def test_new_bot_firmware():
322322 device = ble_device ,
323323 rssi = - 90 ,
324324 )
325+
326+
327+ def test_parse_advertisement_data_curtain_firmware_six_fully_closed ():
328+ """Test parse_advertisement_data with firmware six fully closed."""
329+ ble_device = BLEDevice ("aa:bb:cc:dd:ee:ff" , "any" )
330+ adv_data = generate_advertisement_data (
331+ local_name = "WoCurtain" ,
332+ manufacturer_data = {
333+ 89 : b"\xcc \xf4 \xc4 \xf9 \xac l" ,
334+ 2409 : b"\xcc \xf4 \xc4 \xf9 \xac l\xeb \x0f d\x12 \x04 " ,
335+ },
336+ service_data = {
337+ "00000d00-0000-1000-8000-00805f9b34fb" : b"c\xd0 Yd\x11 \x04 " ,
338+ "0000fd3d-0000-1000-8000-00805f9b34fb" : b"c\xc0 dd\x12 \x04 " ,
339+ },
340+ service_uuids = [
341+ "00001800-0000-1000-8000-00805f9b34fb" ,
342+ "00001801-0000-1000-8000-00805f9b34fb" ,
343+ "cba20d00-224d-11e6-9fb8-0002a5d5c51b" ,
344+ ],
345+ rssi = - 2 ,
346+ )
347+ result = parse_advertisement_data (ble_device , adv_data )
348+ assert result == SwitchBotAdvertisement (
349+ address = "aa:bb:cc:dd:ee:ff" ,
350+ data = {
351+ "rawAdvData" : b"c\xc0 dd\x12 \x04 " ,
352+ "data" : {
353+ "calibration" : True ,
354+ "battery" : 100 ,
355+ "inMotion" : False ,
356+ "position" : 0 ,
357+ "lightLevel" : 1 ,
358+ "deviceChain" : 2 ,
359+ },
360+ "isEncrypted" : False ,
361+ "model" : "c" ,
362+ "modelFriendlyName" : "Curtain" ,
363+ "modelName" : SwitchbotModel .CURTAIN ,
364+ },
365+ device = ble_device ,
366+ rssi = - 2 ,
367+ )
368+
369+
370+ def test_parse_advertisement_data_curtain_firmware_six_fully_open ():
371+ """Test parse_advertisement_data with firmware six fully open."""
372+ ble_device = BLEDevice ("aa:bb:cc:dd:ee:ff" , "any" )
373+ adv_data = generate_advertisement_data (
374+ local_name = "WoCurtain" ,
375+ manufacturer_data = {
376+ 89 : b"\xcc \xf4 \xc4 \xf9 \xac l" ,
377+ 2409 : b"\xcc \xf4 \xc4 \xf9 \xac l\xe2 \x0f \x00 \x12 \x04 " ,
378+ },
379+ service_data = {
380+ "00000d00-0000-1000-8000-00805f9b34fb" : b"c\xd0 Yd\x11 \x04 " ,
381+ "0000fd3d-0000-1000-8000-00805f9b34fb" : b"c\xc0 d\x00 \x12 \x04 " ,
382+ },
383+ service_uuids = [
384+ "00001800-0000-1000-8000-00805f9b34fb" ,
385+ "00001801-0000-1000-8000-00805f9b34fb" ,
386+ "cba20d00-224d-11e6-9fb8-0002a5d5c51b" ,
387+ ],
388+ rssi = - 2 ,
389+ )
390+ result = parse_advertisement_data (ble_device , adv_data )
391+ assert result == SwitchBotAdvertisement (
392+ address = "aa:bb:cc:dd:ee:ff" ,
393+ data = {
394+ "rawAdvData" : b"c\xc0 d\x00 \x12 \x04 " ,
395+ "data" : {
396+ "calibration" : True ,
397+ "battery" : 100 ,
398+ "inMotion" : False ,
399+ "position" : 100 ,
400+ "lightLevel" : 1 ,
401+ "deviceChain" : 2 ,
402+ },
403+ "isEncrypted" : False ,
404+ "model" : "c" ,
405+ "modelFriendlyName" : "Curtain" ,
406+ "modelName" : SwitchbotModel .CURTAIN ,
407+ },
408+ device = ble_device ,
409+ rssi = - 2 ,
410+ )
0 commit comments