From 8ccd5f6d240b6a2310911fbe29e00c04e85f14a0 Mon Sep 17 00:00:00 2001 From: sreknob Date: Tue, 4 Feb 2020 00:24:20 -0500 Subject: [PATCH 1/4] zha support for ICTCG1Controller This adds zha support for the ICTC-G-1 controller. The device is VERY chatty with zha_event so the sometimes the behaviour is a little wonky. The dimmer I tested with isn't the latest firmware so I will try and update it and see if that makes any difference. Note that I used Light.HOLD_BRIGHTNESS_DOWN and Light.HOLD_BRIGHTNESS_UP twice as there are two different args, depending on the rate at which you rotate the dimmer - slow or fast. This is still separate from "quick" right and left. I tried with no args (just "move" and "move_with_on_off" but then I got no dimming at all with rotation - maybe an issue with args processing? --- apps/controllerx/devices/ikea.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/controllerx/devices/ikea.py b/apps/controllerx/devices/ikea.py index 605e9862..7e317e39 100644 --- a/apps/controllerx/devices/ikea.py +++ b/apps/controllerx/devices/ikea.py @@ -174,6 +174,17 @@ def get_z2m_actions_mapping(self): "rotate_stop": Light.RELEASE, } + def get_zha_actions_mapping(self): + return { + "move_1_70": Light.HOLD_BRIGHTNESS_DOWN, + "move_1_195": Light.HOLD_BRIGHTNESS_DOWN, + "move_to_level_with_on_off_0_1": Light.OFF, + "move_with_on_off_0_70": Light.HOLD_BRIGHTNESS_UP, + "move_with_on_off_0_195": Light.HOLD_BRIGHTNESS_UP, + "move_to_level_with_on_off_255_1": Light.ON_FULL_BRIGHTNESS, + "stop": Light.RELEASE, + } + class E1744LightController(LightController): # Different states reported from the controller: From 6c5b49adb18de8ca42d775e4fe5f4cca1d9837e4 Mon Sep 17 00:00:00 2001 From: sreknob Date: Tue, 4 Feb 2020 09:13:57 -0500 Subject: [PATCH 2/4] fix on_full sets on_full to max rather than min brightness --- apps/controllerx/core/type/light_controller.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/controllerx/core/type/light_controller.py b/apps/controllerx/core/type/light_controller.py index 1f1b0417..18375625 100644 --- a/apps/controllerx/core/type/light_controller.py +++ b/apps/controllerx/core/type/light_controller.py @@ -251,10 +251,11 @@ async def toggle(self): @action async def on_full(self, attribute): + await self.on() attribute = await self.get_attribute(attribute) stepper = self.manual_steppers[attribute] await self.change_light_state( - stepper.minmax.min, attribute, Stepper.UP, stepper, + stepper.minmax.max, attribute, Stepper.UP, stepper, ) async def get_attribute(self, attribute): From 750a80c4912d743ca542c34ca0962772c800a2b1 Mon Sep 17 00:00:00 2001 From: sreknob Date: Tue, 4 Feb 2020 09:18:35 -0500 Subject: [PATCH 3/4] Update test for test_on_full to max brightness --- tests/core/type/light_controller_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/core/type/light_controller_test.py b/tests/core/type/light_controller_test.py index 6deda7db..3fa89b42 100644 --- a/tests/core/type/light_controller_test.py +++ b/tests/core/type/light_controller_test.py @@ -200,13 +200,13 @@ async def test_toggle(sut, mocker): @pytest.mark.asyncio async def test_on_full(sut, mocker): attribute = "test_attribute" - min_ = 1 + max_ = 10 change_light_state_patch = mocker.patch.object(sut, "change_light_state") - stepper = MinMaxStepper(min_, 10, 10) + stepper = MinMaxStepper(1, max_, 10) sut.manual_steppers = {attribute: stepper} await sut.on_full(attribute) change_light_state_patch.assert_called_once_with( - min_, attribute, Stepper.UP, stepper + max_, attribute, Stepper.UP, stepper ) From c81d7a2cde6c208724fe7cb265afa1c13f9d9aa1 Mon Sep 17 00:00:00 2001 From: sreknob Date: Wed, 5 Feb 2020 10:31:36 -0500 Subject: [PATCH 4/4] ICTCG1Controller zha update - Use same mapping definitions as z2m for ON/OFF functions - Use medium speed right turn for Light.ON to mimic native behaviour of directly bound controller --- apps/controllerx/devices/ikea.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/controllerx/devices/ikea.py b/apps/controllerx/devices/ikea.py index 7e317e39..d3a63b9f 100644 --- a/apps/controllerx/devices/ikea.py +++ b/apps/controllerx/devices/ikea.py @@ -178,10 +178,10 @@ def get_zha_actions_mapping(self): return { "move_1_70": Light.HOLD_BRIGHTNESS_DOWN, "move_1_195": Light.HOLD_BRIGHTNESS_DOWN, - "move_to_level_with_on_off_0_1": Light.OFF, + "move_to_level_with_on_off_0_1": "rotate_left_quick", "move_with_on_off_0_70": Light.HOLD_BRIGHTNESS_UP, - "move_with_on_off_0_195": Light.HOLD_BRIGHTNESS_UP, - "move_to_level_with_on_off_255_1": Light.ON_FULL_BRIGHTNESS, + "move_with_on_off_0_195": Light.ON, + "move_to_level_with_on_off_255_1": "rotate_right_quick", "stop": Light.RELEASE, }