From feaf79c8d4be062148ab6b7caf68b9a9e8ea59c7 Mon Sep 17 00:00:00 2001 From: Raido Kuli Date: Mon, 27 Oct 2025 08:56:22 +0200 Subject: [PATCH 1/2] Fix long release dim down for Ikea 2 button remote (Rodret) --- zhaquirks/ikea/twobtnremote.py | 58 ++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/zhaquirks/ikea/twobtnremote.py b/zhaquirks/ikea/twobtnremote.py index 4279465e4f..ac555c6b09 100644 --- a/zhaquirks/ikea/twobtnremote.py +++ b/zhaquirks/ikea/twobtnremote.py @@ -1,7 +1,11 @@ """Device handler for IKEA of Sweden TRADFRI remote control.""" +from typing import Any, Optional, Union + from zigpy.profiles import zha, zll -from zigpy.quirks import CustomDevice +from zigpy.quirks import CustomCluster, CustomDevice +import zigpy.types as t +from zigpy.zcl import foundation from zigpy.zcl.clusters.closures import WindowCovering from zigpy.zcl.clusters.general import ( Alarms, @@ -40,6 +44,7 @@ SHORT_PRESS, TURN_OFF, TURN_ON, + ZHA_SEND_EVENT, ) from zhaquirks.ikea import ( IKEA, @@ -48,6 +53,45 @@ PowerConfig1AAACluster, ) +COMMAND_LONG_RELESE_DIM_UP = "long_release_dim_up" +COMMAND_LONG_RELESE_DIM_DOWN = "long_release_dim_down" + + +class IkeaRemoteLongReleaseControl(CustomCluster, LevelControl): + """Ikea Remote Long Release Control cluster.""" + + def __init__(self, *args, **kwargs): + """Initialize instance.""" + super().__init__(*args, **kwargs) + self._dim_direction_down = None + + def handle_cluster_request( + self, + hdr: foundation.ZCLHeader, + args: list[Any], + *, + dst_addressing: Optional[ + Union[t.Addressing.Group, t.Addressing.IEEE, t.Addressing.NWK] + ] = None, + ) -> None: + """Handle cluster specific commands. + + We just want to keep track of direction, to associate it with the stop command. + """ + + cmd_name = self.server_commands[hdr.command_id].name + if cmd_name == COMMAND_MOVE_ON_OFF: + self._dim_direction_down = False + elif cmd_name == COMMAND_MOVE: + self._dim_direction_down = True + elif cmd_name in (COMMAND_STOP_ON_OFF, COMMAND_STOP): + action = ( + COMMAND_LONG_RELESE_DIM_DOWN + if self._dim_direction_down + else COMMAND_LONG_RELESE_DIM_UP + ) + self.listener_event(ZHA_SEND_EVENT, action, []) + class IkeaTradfriRemote2Btn(CustomDevice): """Custom device representing IKEA of Sweden TRADFRI remote control.""" @@ -102,7 +146,7 @@ class IkeaTradfriRemote2Btn(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - LevelControl.cluster_id, + IkeaRemoteLongReleaseControl, Ota.cluster_id, WindowCovering.cluster_id, LightLink.cluster_id, @@ -120,7 +164,7 @@ class IkeaTradfriRemote2Btn(CustomDevice): PARAMS: {"move_mode": 0}, }, (LONG_RELEASE, DIM_UP): { - COMMAND: COMMAND_STOP_ON_OFF, + COMMAND: COMMAND_LONG_RELESE_DIM_UP, CLUSTER_ID: 8, ENDPOINT_ID: 1, }, @@ -132,7 +176,7 @@ class IkeaTradfriRemote2Btn(CustomDevice): PARAMS: {"move_mode": 1}, }, (LONG_RELEASE, DIM_DOWN): { - COMMAND: COMMAND_STOP, + COMMAND: COMMAND_LONG_RELESE_DIM_DOWN, CLUSTER_ID: 8, ENDPOINT_ID: 1, }, @@ -191,7 +235,7 @@ class IkeaTradfriRemote2BtnZLL(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - LevelControl.cluster_id, + IkeaRemoteLongReleaseControl, Ota.cluster_id, WindowCovering.cluster_id, LightLink.cluster_id, @@ -253,7 +297,7 @@ class IkeaRodretRemote2Btn(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - LevelControl.cluster_id, + IkeaRemoteLongReleaseControl, Ota.cluster_id, LightLink.cluster_id, ], @@ -315,7 +359,7 @@ class IkeaRodretRemote2BtnNew(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - LevelControl.cluster_id, + IkeaRemoteLongReleaseControl, Ota.cluster_id, LightLink.cluster_id, ], From 1a9f468aff88a9e53e1e6d83121c1562fa33e267 Mon Sep 17 00:00:00 2001 From: Raido Kuli Date: Mon, 27 Oct 2025 21:24:22 +0200 Subject: [PATCH 2/2] Rename IkeaRemoteLongReleaseControl -> IkeaLevelControl --- zhaquirks/ikea/twobtnremote.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/zhaquirks/ikea/twobtnremote.py b/zhaquirks/ikea/twobtnremote.py index ac555c6b09..168855bb76 100644 --- a/zhaquirks/ikea/twobtnremote.py +++ b/zhaquirks/ikea/twobtnremote.py @@ -57,8 +57,8 @@ COMMAND_LONG_RELESE_DIM_DOWN = "long_release_dim_down" -class IkeaRemoteLongReleaseControl(CustomCluster, LevelControl): - """Ikea Remote Long Release Control cluster.""" +class IkeaLevelControl(CustomCluster, LevelControl): + """Ikea Level Control cluster.""" def __init__(self, *args, **kwargs): """Initialize instance.""" @@ -146,7 +146,7 @@ class IkeaTradfriRemote2Btn(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - IkeaRemoteLongReleaseControl, + IkeaLevelControl, Ota.cluster_id, WindowCovering.cluster_id, LightLink.cluster_id, @@ -235,7 +235,7 @@ class IkeaTradfriRemote2BtnZLL(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - IkeaRemoteLongReleaseControl, + IkeaLevelControl, Ota.cluster_id, WindowCovering.cluster_id, LightLink.cluster_id, @@ -297,7 +297,7 @@ class IkeaRodretRemote2Btn(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - IkeaRemoteLongReleaseControl, + IkeaLevelControl, Ota.cluster_id, LightLink.cluster_id, ], @@ -359,7 +359,7 @@ class IkeaRodretRemote2BtnNew(CustomDevice): Identify.cluster_id, Groups.cluster_id, OnOff.cluster_id, - IkeaRemoteLongReleaseControl, + IkeaLevelControl, Ota.cluster_id, LightLink.cluster_id, ],