Переглянути джерело

fix climate panel adv parse (#409)

Retha Runolfsson 1 день тому
батько
коміт
187cdc2800
2 змінених файлів з 25 додано та 7 видалено
  1. 1 1
      switchbot/adv_parsers/climate_panel.py
  2. 24 6
      tests/test_adv_parser.py

+ 1 - 1
switchbot/adv_parsers/climate_panel.py

@@ -26,7 +26,7 @@ def process_climate_panel(
     humidity = mfr_data[10] & 0x7F
 
     pir_state = bool(mfr_data[15] & 0x80)
-    is_light = ((mfr_data[15] >> 2) & 0x03) == 0x10
+    is_light = ((mfr_data[15] >> 1) & 0x03) == 0x02
 
     result = {
         "sequence_number": seq_number,

+ 24 - 6
tests/test_adv_parser.py

@@ -3431,18 +3431,36 @@ def test_humidifer_with_empty_data() -> None:
             SwitchbotModel.K11_VACUUM,
         ),
         AdvTestCase(
-            b"\xb0\xe9\xfe\x8e\x98Oi_\x06\x9a,\x00\x00\x00\x00\xe4\x00\x08\x04\x00\x01\x00\x00",
+            b"\xb0\xe9\xfe\x848\x05\x06\x14\x05\x99-\x00\x00\x00\x00\xd4\x00\x0c\x04\x00",
             b"\x00 _\x00\x10\xf3\xd8@",
             {
-                "battery": 95,
-                "humidity": 44,
-                "sequence_number": 105,
+                "battery": 20,
+                "humidity": 45,
+                "sequence_number": 6,
+                "humidity_alarm": 0,
+                "isOn": False,
+                "is_light": True,
+                "motion_detected": True,
+                "temp_alarm": 0,
+                "temperature": 25.5,
+            },
+            b"\x00\x10\xf3\xd8",
+            "Climate Panel",
+            SwitchbotModel.CLIMATE_PANEL,
+        ),
+        AdvTestCase(
+            b"\xb0\xe9\xfe\x848\x05\x13\x14\t\x99-\x00\x00\x00\x00\xd2\x01\x14\x04\x00",
+            b"\x00 _\x00\x10\xf3\xd8@",
+            {
+                "battery": 20,
+                "humidity": 45,
+                "sequence_number": 19,
                 "humidity_alarm": 0,
                 "isOn": False,
                 "is_light": False,
                 "motion_detected": True,
                 "temp_alarm": 0,
-                "temperature": 26.6,
+                "temperature": 25.9,
             },
             b"\x00\x10\xf3\xd8",
             "Climate Panel",
@@ -3691,7 +3709,7 @@ def test_adv_active(test_case: AdvTestCase) -> None:
                 "sequence_number": 105,
                 "humidity_alarm": 0,
                 "isOn": False,
-                "is_light": False,
+                "is_light": True,
                 "motion_detected": True,
                 "temp_alarm": 0,
                 "temperature": 26.6,