Browse Source

Fix meter being seen as blub with passive only (#155)

J. Nick Koston 2 years ago
parent
commit
6e43198ebc
2 changed files with 2 additions and 33 deletions
  1. 2 1
      switchbot/adv_parser.py
  2. 0 32
      tests/test_adv_parser.py

+ 2 - 1
switchbot/adv_parser.py

@@ -82,11 +82,13 @@ SUPPORTED_TYPES: dict[str, SwitchbotSupportedType] = {
         "modelName": SwitchbotModel.METER,
         "modelFriendlyName": "Meter",
         "func": process_wosensorth,
+        "manufacturer_id": 2409,
     },
     "i": {
         "modelName": SwitchbotModel.METER,
         "modelFriendlyName": "Meter Plus",
         "func": process_wosensorth,
+        "manufacturer_id": 2409,
     },
     "g": {
         "modelName": SwitchbotModel.PLUG_MINI,
@@ -103,7 +105,6 @@ SUPPORTED_TYPES: dict[str, SwitchbotSupportedType] = {
         "modelFriendlyName": "Color Bulb",
         "func": process_color_bulb,
         "manufacturer_id": 2409,
-        "manufacturer_data_length": 11,
     },
     "q": {
         "modelName": SwitchbotModel.CEILING_LIGHT,

+ 0 - 32
tests/test_adv_parser.py

@@ -645,38 +645,6 @@ def test_bulb_active():
     )
 
 
-def test_bulb_passive():
-    """Test parsing bulb as passive."""
-    ble_device = BLEDevice("aa:bb:cc:dd:ee:ff", "any")
-    adv_data = generate_advertisement_data(
-        manufacturer_data={2409: b"\x84\xf7\x03\xb4\xcbz\x03\xe4!\x00\x00"},
-        service_data={},
-        tx_power=-127,
-        rssi=-50,
-    )
-    result = parse_advertisement_data(ble_device, adv_data, SwitchbotModel.BOT)
-    assert result == SwitchBotAdvertisement(
-        address="aa:bb:cc:dd:ee:ff",
-        data={
-            "data": {
-                "brightness": 100,
-                "color_mode": 1,
-                "delay": False,
-                "isOn": True,
-                "loop_index": 0,
-                "preset": False,
-                "sequence_number": 3,
-                "speed": 0,
-            },
-            "isEncrypted": False,
-            "model": "u",
-            "modelFriendlyName": "Color Bulb",
-            "modelName": SwitchbotModel.COLOR_BULB,
-            "rawAdvData": None,
-        },
-        device=ble_device,
-        rssi=-50,
-    )
 
 
 def test_lightstrip_passive():