Repository: zigpy/zha-device-handlers

Issue:
Ikea E1743 On/Off Switch Support
This is a feature/feasibility request to support the Ikea E1743 On/Off Switch that comes [separate](https://www.ikea.com/us/en/p/tradfri-wireless-dimmer-white-10408598/) or [bundled with a bulb](https://www.ikea.com/us/en/p/tradfri-dimmer-kit-90435932/).

I'd be happy to help with debugging/logs/even attempting to write a handler, but I'm not entirely sure where to start. I'm also willing to send someone one of the E1743's if that'd be helpulf.

For what it's worth, ZHA does does pair and reports battery level.

<img width="493" alt="image" src="https://user-images.githubusercontent.com/41883/68000283-b1931100-fc1c-11e9-9cb1-03ea8b3dee44.png">

Additional information that _appears_ to be important from looking at `fivebtnremote.py` (for example).
```
Manufacturer: IKEA of Sweden
Model: IKEA of Sweden TRADFRI on/off switch
<SimpleDescriptor endpoint=1 profile=260 device_type=2080 device_version=1 input_clusters=[0, 1, 3, 9, 32, 4096, 64636] output_clusters=[3, 4, 6, 8, 25, 258, 4096]>
```


Thanks!


Discussion:
interesting... this may just work ootb and it may not... have you gone into the event tool in HA and subscribed to zha_event to see if you get events for button pushes?
That’s what I was hoping: `zha_event`. In the event tool I don’t see `zha_event` as an option; I tried subscribing anyway, but nothing seems to come through when pushing the button (long or short).

For what it's worth here's a paste of what happens when it joins the network: https://hastebin.com/izuqulobuv.rb
you need to subscribe to the zha_event, it's a manual action, not an option. Find the event tab and scroll down a bit :)

Resolving patch:
diff --git a/zhaquirks/ikea/twobtnremote.py b/zhaquirks/ikea/twobtnremote.py
new file mode 100644
--- /dev/null
+++ b/zhaquirks/ikea/twobtnremote.py
@@ -0,0 +1,137 @@
+"""Device handler for IKEA of Sweden TRADFRI remote control."""
+from zigpy.profiles import zha
+from zigpy.quirks import CustomCluster, CustomDevice
+from zigpy.zcl.clusters.closures import WindowCovering
+from zigpy.zcl.clusters.general import (
+    Alarms,
+    Basic,
+    Groups,
+    Identify,
+    LevelControl,
+    OnOff,
+    Ota,
+    PollControl,
+    PowerConfiguration,
+)
+from zigpy.zcl.clusters.lightlink import LightLink
+
+from . import IKEA
+from .. import DoublingPowerConfigurationCluster
+from ..const import (
+    ARGS,
+    CLUSTER_ID,
+    COMMAND,
+    COMMAND_MOVE,
+    COMMAND_MOVE_ON_OFF,
+    COMMAND_OFF,
+    COMMAND_ON,
+    DEVICE_TYPE,
+    DIM_DOWN,
+    DIM_UP,
+    ENDPOINT_ID,
+    ENDPOINTS,
+    INPUT_CLUSTERS,
+    LONG_PRESS,
+    MODELS_INFO,
+    OUTPUT_CLUSTERS,
+    PROFILE_ID,
+    SHORT_PRESS,
+    TURN_OFF,
+    TURN_ON,
+)
+
+IKEA_CLUSTER_ID = 0xFC7C  # decimal = 64636
+
+
+class LightLinkCluster(CustomCluster, LightLink):
+    """Ikea LightLink cluster."""
+
+    async def bind(self):
+        """Bind LightLink cluster to coordinator."""
+        application = self._endpoint.device.application
+        try:
+            coordinator = application.get_device(application.ieee)
+        except KeyError:
+            return
+        status = await coordinator.add_to_group(0x0000)
+        return [status]
+
+
+class IkeaTradfriRemote2Btn(CustomDevice):
+    """Custom device representing IKEA of Sweden TRADFRI remote control."""
+
+    signature = {
+        # <SimpleDescriptor endpoint=1 profile=260 device_type=2080
+        # device_version=1
+        # input_clusters=[0, 1, 3, 9, 32, 4096, 64636]
+        # output_clusters=[3, 4, 6, 8, 25, 258, 4096]>
+        MODELS_INFO: [(IKEA, "TRADFRI on/off switch")],
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    PowerConfiguration.cluster_id,
+                    Identify.cluster_id,
+                    Alarms.cluster_id,
+                    PollControl.cluster_id,
+                    LightLink.cluster_id,
+                    IKEA_CLUSTER_ID,
+                ],
+                OUTPUT_CLUSTERS: [
+                    Identify.cluster_id,
+                    Groups.cluster_id,
+                    OnOff.cluster_id,
+                    LevelControl.cluster_id,
+                    Ota.cluster_id,
+                    WindowCovering.cluster_id,
+                    LightLink.cluster_id,
+                ],
+            }
+        },
+    }
+
+    replacement = {
+        ENDPOINTS: {
+            1: {
+                PROFILE_ID: zha.PROFILE_ID,
+                DEVICE_TYPE: zha.DeviceType.NON_COLOR_CONTROLLER,
+                INPUT_CLUSTERS: [
+                    Basic.cluster_id,
+                    DoublingPowerConfigurationCluster,
+                    Identify.cluster_id,
+                    Alarms.cluster_id,
+                    PollControl.cluster_id,
+                    LightLinkCluster,
+                    IKEA_CLUSTER_ID,
+                ],
+                OUTPUT_CLUSTERS: [
+                    Identify.cluster_id,
+                    Groups.cluster_id,
+                    OnOff.cluster_id,
+                    LevelControl.cluster_id,
+                    Ota.cluster_id,
+                    WindowCovering.cluster_id,
+                    LightLink.cluster_id,
+                ],
+            }
+        }
+    }
+
+    device_automation_triggers = {
+        (SHORT_PRESS, TURN_ON): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1},
+        (LONG_PRESS, DIM_UP): {
+            COMMAND: COMMAND_MOVE_ON_OFF,
+            CLUSTER_ID: 8,
+            ENDPOINT_ID: 1,
+            ARGS: [0, 83],
+        },
+        (SHORT_PRESS, TURN_OFF): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1},
+        (LONG_PRESS, DIM_DOWN): {
+            COMMAND: COMMAND_MOVE,
+            CLUSTER_ID: 8,
+            ENDPOINT_ID: 1,
+            ARGS: [1, 83],
+        },
+    }


Test patch: