Browse Source

Add support for plug mini eu (#390)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Retha Runolfsson 2 months ago
parent
commit
b2e1d2235f

+ 6 - 0
switchbot/adv_parser.py

@@ -343,6 +343,12 @@ SUPPORTED_TYPES: dict[str | bytes, SwitchbotSupportedType] = {
         "func": process_light,
         "manufacturer_id": 2409,
     },
+    "?": {
+        "modelName": SwitchbotModel.PLUG_MINI_EU,
+        "modelFriendlyName": "Plug Mini (EU)",
+        "func": process_relay_switch_1pm,
+        "manufacturer_id": 2409,
+    },
 }
 
 _SWITCHBOT_MODEL_TO_CHAR = {

+ 1 - 0
switchbot/const/__init__.py

@@ -93,6 +93,7 @@ class SwitchbotModel(StrEnum):
     RELAY_SWITCH_2PM = "Relay Switch 2PM"
     STRIP_LIGHT_3 = "Strip Light 3"
     FLOOR_LAMP = "Floor Lamp"
+    PLUG_MINI_EU = "Plug Mini (EU)"
 
 
 __all__ = [

+ 1 - 0
switchbot/devices/relay_switch.py

@@ -128,6 +128,7 @@ class SwitchbotRelaySwitch(SwitchbotSequenceDevice, SwitchbotEncryptedDevice):
         if self._model in (
             SwitchbotModel.RELAY_SWITCH_1PM,
             SwitchbotModel.RELAY_SWITCH_2PM,
+            SwitchbotModel.PLUG_MINI_EU,
         ):
             if channel is None:
                 adv_data["voltage"] = self._get_adv_value("voltage") or 0

+ 39 - 0
tests/test_adv_parser.py

@@ -3366,6 +3366,19 @@ def test_humidifer_with_empty_data() -> None:
             "Color Bulb",
             SwitchbotModel.COLOR_BULB,
         ),
+        AdvTestCase(
+            b"\x94\xa9\x90T\x85^?\xa1\x00\x00\x04\xe6\x00\x00\x00\x00",
+            b"?\x00\x00\x00",
+            {
+                "isOn": True,
+                "power": 1254.0,
+                "sequence_number": 63,
+                "switchMode": True,
+            },
+            "?",
+            "Plug Mini (EU)",
+            SwitchbotModel.PLUG_MINI_EU,
+        ),
     ],
 )
 def test_adv_active(test_case: AdvTestCase) -> None:
@@ -3520,6 +3533,19 @@ def test_adv_active(test_case: AdvTestCase) -> None:
             "Color Bulb",
             SwitchbotModel.COLOR_BULB,
         ),
+        AdvTestCase(
+            b"\x94\xa9\x90T\x85^?\xa1\x00\x00\x04\xe6\x00\x00\x00\x00",
+            None,
+            {
+                "isOn": True,
+                "power": 1254.0,
+                "sequence_number": 63,
+                "switchMode": True,
+            },
+            "?",
+            "Plug Mini (EU)",
+            SwitchbotModel.PLUG_MINI_EU,
+        ),
     ],
 )
 def test_adv_passive(test_case: AdvTestCase) -> None:
@@ -3648,6 +3674,19 @@ def test_adv_passive(test_case: AdvTestCase) -> None:
             "Color Bulb",
             SwitchbotModel.COLOR_BULB,
         ),
+        AdvTestCase(
+            None,
+            b"?\x00\x00\x00",
+            {
+                "isOn": True,
+                "power": 1254.0,
+                "sequence_number": 63,
+                "switchMode": True,
+            },
+            "?",
+            "Plug Mini (EU)",
+            SwitchbotModel.PLUG_MINI_EU,
+        ),
     ],
 )
 def test_adv_with_empty_data(test_case: AdvTestCase) -> None:

+ 1 - 0
tests/test_relay_switch.py

@@ -13,6 +13,7 @@ common_params = [
     (b";\x00\x00\x00", SwitchbotModel.RELAY_SWITCH_1),
     (b"<\x00\x00\x00", SwitchbotModel.RELAY_SWITCH_1PM),
     (b">\x00\x00\x00", SwitchbotModel.GARAGE_DOOR_OPENER),
+    (b"?\x00\x00\x00", SwitchbotModel.PLUG_MINI_EU),
 ]