From 4023e318ea8f94e2c97e79ba4ce74e7e9af8e84e Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 10 Nov 2024 08:19:07 -0500 Subject: [PATCH 1/4] fix device triggers definition --- zhaquirks/sinope/__init__.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/zhaquirks/sinope/__init__.py b/zhaquirks/sinope/__init__.py index ff59f319da..7990b36452 100644 --- a/zhaquirks/sinope/__init__.py +++ b/zhaquirks/sinope/__init__.py @@ -52,7 +52,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_ON, - VALUE: ButtonAction.Pressed_on, + VALUE: int(ButtonAction.Pressed_on), }, }, (SHORT_PRESS, TURN_OFF): { @@ -63,7 +63,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_OFF, - VALUE: ButtonAction.Pressed_off, + VALUE: int(ButtonAction.Pressed_off), }, }, (SHORT_RELEASE, TURN_ON): { @@ -74,7 +74,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_ON, - VALUE: ButtonAction.Released_on, + VALUE: int(ButtonAction.Released_on), }, }, (SHORT_RELEASE, TURN_OFF): { @@ -85,7 +85,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_OFF, - VALUE: ButtonAction.Released_off, + VALUE: int(ButtonAction.Released_off), }, }, (DOUBLE_PRESS, TURN_ON): { @@ -96,7 +96,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_ON, - VALUE: ButtonAction.Double_on, + VALUE: int(ButtonAction.Double_on), }, }, (DOUBLE_PRESS, TURN_OFF): { @@ -107,7 +107,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_OFF, - VALUE: ButtonAction.Double_off, + VALUE: int(ButtonAction.Double_off), }, }, (LONG_PRESS, TURN_ON): { @@ -118,7 +118,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_ON, - VALUE: ButtonAction.Long_on, + VALUE: int(ButtonAction.Long_on), }, }, (LONG_PRESS, TURN_OFF): { @@ -129,7 +129,7 @@ class ButtonAction(t.enum8): ATTRIBUTE_ID: 84, ATTRIBUTE_NAME: ATTRIBUTE_ACTION, BUTTON: TURN_OFF, - VALUE: ButtonAction.Long_off, + VALUE: int(ButtonAction.Long_off), }, }, } From cce9083bb8eb261b6bfb08e8677b454f18c044a8 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 10 Nov 2024 08:51:27 -0500 Subject: [PATCH 2/4] tests --- tests/test_sinope.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_sinope.py b/tests/test_sinope.py index 3f377a858d..bcdf880043 100644 --- a/tests/test_sinope.py +++ b/tests/test_sinope.py @@ -239,3 +239,15 @@ async def test_sinope_light_switch_reporting(zigpy_device_from_quirk, quirk): assert len(request_mock.mock_calls) == 1 assert len(bind_mock.mock_calls) == 1 + + +@pytest.mark.parametrize("quirk", (SinopeTechnologieslight,)) +async def test_sinope_light_device_triggers_def(zigpy_device_from_quirk, quirk): + """Test that configuring reporting for action_report works.""" + device: Device = zigpy_device_from_quirk(quirk) + + for config in device.device_automation_triggers.values(): + # from pudb import set_trace; set_trace(); + val = config.get("args", {}).get("value") + if val is not None: + assert type(val) is int, type(val) From f6d5f138a02dd4d8462c95d67da159b1e487d6b6 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 10 Nov 2024 08:51:46 -0500 Subject: [PATCH 3/4] remove debug --- tests/test_sinope.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_sinope.py b/tests/test_sinope.py index bcdf880043..27e864f6ce 100644 --- a/tests/test_sinope.py +++ b/tests/test_sinope.py @@ -247,7 +247,6 @@ async def test_sinope_light_device_triggers_def(zigpy_device_from_quirk, quirk): device: Device = zigpy_device_from_quirk(quirk) for config in device.device_automation_triggers.values(): - # from pudb import set_trace; set_trace(); val = config.get("args", {}).get("value") if val is not None: assert type(val) is int, type(val) From ad0c3319e19c37515e6c8b36099dc93d7e6a4e19 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 10 Nov 2024 08:53:44 -0500 Subject: [PATCH 4/4] comment --- tests/test_sinope.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_sinope.py b/tests/test_sinope.py index 27e864f6ce..72b3e69abd 100644 --- a/tests/test_sinope.py +++ b/tests/test_sinope.py @@ -243,7 +243,11 @@ async def test_sinope_light_switch_reporting(zigpy_device_from_quirk, quirk): @pytest.mark.parametrize("quirk", (SinopeTechnologieslight,)) async def test_sinope_light_device_triggers_def(zigpy_device_from_quirk, quirk): - """Test that configuring reporting for action_report works.""" + """Test device automation triggers. + + Make sure that values are actual ints and not instances of an enum class. + """ + device: Device = zigpy_device_from_quirk(quirk) for config in device.device_automation_triggers.values():