Pārlūkot izejas kodu

fix(ceiling-light): decode basic info color mode bit (#549)

xtymmms1021 3 dienas atpakaļ
vecāks
revīzija
8eeae5f2f4
2 mainītis faili ar 9 papildinājumiem un 1 dzēšanām
  1. 1 1
      switchbot/devices/ceiling_light.py
  2. 8 0
      tests/test_ceiling_light.py

+ 1 - 1
switchbot/devices/ceiling_light.py

@@ -64,7 +64,7 @@ class SwitchbotCeilingLight(SwitchbotSequenceBaseLight):
 
         return {
             "isOn": bool(_data[1] & 0b10000000),
-            "color_mode": _data[1] & 0b01000000,
+            "color_mode": (_data[1] & 0b01000000) >> 6,
             "brightness": _data[2] & 0b01111111,
             "cw": self._state["cw"],
             "firmware": _version_info[2] / 10.0,

+ 8 - 0
tests/test_ceiling_light.py

@@ -109,6 +109,14 @@ async def test_get_basic_info_returns_none(basic_info, version_info):
             },
             [False, 14, 4246, 0, 2.1],
         ),
+        pytest.param(
+            {
+                "basic_info": b"\x01\xc0\x0e\x10\x96\x00\x01",
+                "version_info": b"\x01d\x15\x0f\x00\x00\x00\x00\x00\x00\x00\n\x00",
+            },
+            [True, 14, 4246, 1, 2.1],
+            id="night-color-mode",
+        ),
     ],
 )
 async def test_get_basic_info(info_data, result):