Repository: zigpy/zha-device-handlers

Issue:
[Device Support Request] IKEA Remote N2 Styrbar
I would like to sue the new Ikea Remote Control n2 Styrbar with ZHA under Homeassistant. Curently i am only able to pair it but there is only the battery status. Buttons are not available for automations. The older IKEA 5 button remote is working fine. 

I would like to use the IKEA Styrbar N2 remote control via ZHA  in home assistant. 

**Device signature - this can be acquired by removing the device from ZHA and pairing it again from the add devices screen. Be sure to add the entire content of the log panel after pairing the device to a code block below this line.**

> `{
  "node_descriptor": "NodeDescriptor(byte1=2, byte2=64, mac_capability_flags=128, manufacturer_code=4476, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=0, *allocate_address=True, *complex_descriptor_available=False, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False, *is_valid=True, *logical_type=<LogicalType.EndDevice: 2>, *user_descriptor_available=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0820",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x0020",
        "0x1000",
        "0xfc57"
      ],
      "out_clusters": [
        "0x0003",
        "0x0006",
        "0x0008",
        "0x0019",
        "0x1000"
      ]
    }
  },
  "manufacturer": "IKEA of Sweden",
  "model": "Remote Control N2",
  "class": "zigpy.device.Device"
}`


**Additional context**
Add any other context or screenshots about the feature request here.
[https://zigbee.blakadder.com/Ikea_E2002.html](url)
[Device Support Request] IKEA TRADFRI W2045 - Solved!
Hi,

I have purchased a IKEA light bulb switch bombo, the bulb is supported (LED194G9) but the switch (type W2045 19972) apparently not. 

https://www.ikea.com/nl/nl/p/tradfri-set-met-afstandsbediening-kleur-en-wit-spectrum-60462432/

I could not find any other requests on the type numbers.
I am fairly new to this stuff, is this the right way to ask for a device addition to ZHA? 

Regards,
Peter



Discussion:
Shi... !!

Im waiting for IKEA to opening in Vienna for baying it but but its in hard lock down for one months so cant getting it then its in the store.

I think the official name name is E2000/E2001 what i remember from FCC papers.

The basic Z3L function shall working then its on ZB3 device with binding to one group and controlling light but for getting the "other HA" events working its need one quirk for extracting the events from it.

Perhaps @TheJulianJES have getting on and can helping.
Please listen to ``zha_event`` in the Home Assistant Developer section.
Then press each button on the remote (normally, double-click, long-press) and label which button press responds to which ``zha_event``.
i have pressed all buttons and get some zha event output. It seems like the up and down have normal press on - off  and long press and stop events. unfortunately the left and right buttons are not giving a clear event? 
attached the output from zha events. i had pressed all different buttons multiple times. I hope the attached will give you the required info.


`{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:8f:e2:a4",
        "unique_id": "84:2e:14:ff:fe:8f:e2:a4:1:0x0006",
        "device_id": "246f8386dd8892687eb5087806c109ac",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "on",
        "args": []
    },
[Ikea Remote N2 zha events.txt](https://github.com/zigpy/zha-device-handlers/files/6361396/Ikea.Remote.N2.zha.events.txt)

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:8f:e2:a4",
        "unique_id": "84:2e:14:ff:fe:8f:e2:a4:1:0x0006",
        "device_id": "246f8386dd8892687eb5087806c109ac",
        "endpoint_id": 1,
        "cluster_id": 6,
        "command": "off",
        "args": []
    },

Ereignis 1231 ausgelöst 23:30:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:8f:e2:a4",
        "unique_id": "84:2e:14:ff:fe:8f:e2:a4:1:0x0008",
        "device_id": "246f8386dd8892687eb5087806c109ac",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "stop",
        "args": []
    },

Ereignis 1230 ausgelöst 23:30:
{
    "event_type": "zha_event",
    "data": {
        "device_ieee": "84:2e:14:ff:fe:8f:e2:a4",
        "unique_id": "84:2e:14:ff:fe:8f:e2:a4:1:0x0008",
        "device_id": "246f8386dd8892687eb5087806c109ac",
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "move_with_on_off",
        "args": [
            0,
            83
        ]
 
[Ikea Remote N2 zha events.txt](https://github.com/zigpy/zha-device-handlers/files/6361359/Ikea.Remote.N2.zha.events.txt)



Resolving patch:
diff --git a/zhaquirks/ikea/fourbtnremote.py b/zhaquirks/ikea/fourbtnremote.py
new file mode 100644
--- /dev/null
+++ b/zhaquirks/ikea/fourbtnremote.py
@@ -0,0 +1,151 @@
+"""Device handler for IKEA of Sweden TRADFRI remote control."""
+from zigpy.profiles import zha
+from zigpy.quirks import CustomDevice
+from zigpy.zcl.clusters.general import (
+    Basic,
+    Identify,
+    LevelControl,
+    OnOff,
+    Ota,
+    PollControl,
+    PowerConfiguration,
+)
+from zigpy.zcl.clusters.lightlink import LightLink
+
+from zhaquirks import DoublingPowerConfigurationCluster
+from zhaquirks.const import (
+    ARGS,
+    CLUSTER_ID,
+    COMMAND,
+    COMMAND_HOLD,
+    COMMAND_MOVE,
+    COMMAND_MOVE_ON_OFF,
+    COMMAND_OFF,
+    COMMAND_ON,
+    COMMAND_PRESS,
+    COMMAND_STOP,
+    DEVICE_TYPE,
+    DIM_DOWN,
+    DIM_UP,
+    ENDPOINT_ID,
+    ENDPOINTS,
+    INPUT_CLUSTERS,
+    LEFT,
+    LONG_PRESS,
+    LONG_RELEASE,
+    MODELS_INFO,
+    OUTPUT_CLUSTERS,
+    PROFILE_ID,
+    RIGHT,
+    SHORT_PRESS,
+    TURN_OFF,
+    TURN_ON,
+)
+from zhaquirks.ikea import IKEA, ScenesCluster
+
+WWAH_CLUSTER_ID = 0xFC57  # decimal = 64599
+
+
+class IkeaTradfriRemote(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, 32, 4096, 64599]
+        # output_clusters=[3, 6, 8, 25, 4096]>
+        MODELS_INFO: [(IKEA, "Remote Control N2")],
+        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,
+                    PollControl.cluster_id,
+                    LightLink.cluster_id,
+                    WWAH_CLUSTER_ID,
+                ],
+                OUTPUT_CLUSTERS: [
+                    Identify.cluster_id,
+                    OnOff.cluster_id,
+                    LevelControl.cluster_id,
+                    Ota.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,
+                    PollControl.cluster_id,
+                    LightLink.cluster_id,
+                    WWAH_CLUSTER_ID,
+                ],
+                OUTPUT_CLUSTERS: [
+                    Identify.cluster_id,
+                    ScenesCluster,
+                    OnOff.cluster_id,
+                    LevelControl.cluster_id,
+                    Ota.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],
+        },
+        (LONG_RELEASE, DIM_UP): {COMMAND: COMMAND_STOP, CLUSTER_ID: 8, ENDPOINT_ID: 1},
+        (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],
+        },
+        (LONG_RELEASE, DIM_DOWN): {
+            COMMAND: COMMAND_STOP,
+            CLUSTER_ID: 8,
+            ENDPOINT_ID: 1,
+        },
+        (SHORT_PRESS, LEFT): {
+            COMMAND: COMMAND_PRESS,
+            CLUSTER_ID: 5,
+            ENDPOINT_ID: 1,
+            ARGS: [257, 13, 0],
+        },
+        (LONG_PRESS, LEFT): {
+            COMMAND: COMMAND_HOLD,
+            CLUSTER_ID: 5,
+            ENDPOINT_ID: 1,
+            ARGS: [3329, 0],
+        },
+        (SHORT_PRESS, RIGHT): {
+            COMMAND: COMMAND_PRESS,
+            CLUSTER_ID: 5,
+            ENDPOINT_ID: 1,
+            ARGS: [256, 13, 0],
+        },
+        (LONG_PRESS, RIGHT): {
+            COMMAND: COMMAND_HOLD,
+            CLUSTER_ID: 5,
+            ENDPOINT_ID: 1,
+            ARGS: [3328, 0],
+        },
+    }


Test patch: