From 520d41145184174d194e0ff09d06b27120f459cf Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 6 Oct 2024 05:37:54 +0000 Subject: [PATCH] Apply pre-commit auto fixes --- tests/test_linxura.py | 17 ++++++----------- zhaquirks/linxura/__init__.py | 5 ++--- zhaquirks/linxura/button.py | 12 +----------- 3 files changed, 9 insertions(+), 25 deletions(-) diff --git a/tests/test_linxura.py b/tests/test_linxura.py index 89b389ee0b..90359e846e 100644 --- a/tests/test_linxura.py +++ b/tests/test_linxura.py @@ -2,16 +2,10 @@ import pytest from zigpy.zcl.clusters.security import IasZone -from unittest.mock import MagicMock -from zigpy.zcl.foundation import ZCLHeader -from zigpy.zcl import foundation -import zhaquirks.linxura from tests.common import ClusterListener import zhaquirks -from zhaquirks.linxura import LinxuraIASCluster - - +import zhaquirks.linxura zhaquirks.setup() @@ -146,18 +140,18 @@ async def test_Linxura_button(zigpy_device_from_quirk, quirk): assert ias_zone_listener4.attribute_updates[2][0] == ias_zone_status_attr_id assert ias_zone_listener4.attribute_updates[2][1] == 3 + # @pytest.mark.parametrize("quirk", (zhaquirks.linxura.button.LinxuraButton,)) # async def test_handle_cluster_request(zigpy_device_from_quirk, quirk): # device = zigpy_device_from_quirk(quirk) # cluster = device.endpoints[1].ias_zone - + # # hdr = ZCLHeader.command_id # Simulate command ID 0 (used in handle_cluster_request) # hdr = ZCLHeader # args = [1] # Simulate single press state # cluster.handle_cluster_request(hdr, args) # # Validate event listener triggers the right event - # Test Edge Cases @pytest.mark.parametrize("quirk", (zhaquirks.linxura.button.LinxuraButton,)) @@ -172,5 +166,6 @@ async def test_edge_case_request(zigpy_device_from_quirk, quirk): ias_zone_status_attr_id = IasZone.AttributeDefs.zone_status.id cluster.update_attribute(ias_zone_status_attr_id, 4) - assert len(ias_zone_listener.attribute_updates) == 1 # No update should occur for state >= 4 - + assert ( + len(ias_zone_listener.attribute_updates) == 1 + ) # No update should occur for state >= 4 diff --git a/zhaquirks/linxura/__init__.py b/zhaquirks/linxura/__init__.py index 5ee67a8339..9179bde803 100644 --- a/zhaquirks/linxura/__init__.py +++ b/zhaquirks/linxura/__init__.py @@ -9,10 +9,10 @@ from zigpy.quirks import CustomCluster, CustomDevice from zigpy.types import Addressing from zigpy.zcl import foundation -from zigpy.zcl.foundation import ZCLHeader from zigpy.zcl.clusters.general import Basic import zigpy.zcl.clusters.security from zigpy.zcl.clusters.security import IasZone +from zigpy.zcl.foundation import ZCLHeader from zhaquirks.const import ( ARGS, @@ -36,7 +36,6 @@ ZHA_SEND_EVENT, ) - DOUBLE = 2 HOLD = 3 # LINXURA = "Linxura" @@ -77,4 +76,4 @@ def handle_cluster_request( ARGS: args, } action = f"button_{CLICK_TYPES[state]}" - self.listener_event(ZHA_SEND_EVENT, action, event_args) \ No newline at end of file + self.listener_event(ZHA_SEND_EVENT, action, event_args) diff --git a/zhaquirks/linxura/button.py b/zhaquirks/linxura/button.py index 01deb1a550..6aab08d7f8 100644 --- a/zhaquirks/linxura/button.py +++ b/zhaquirks/linxura/button.py @@ -1,24 +1,16 @@ """Linxura button device.""" -from typing import Any, Optional, Union - from zigpy.profiles import zha -from zigpy.quirks import CustomCluster, CustomDevice -from zigpy.types import Addressing -from zigpy.zcl import foundation -from zigpy.zcl.foundation import ZCLHeader +from zigpy.quirks import CustomDevice from zigpy.zcl.clusters.general import Basic -import zigpy.zcl.clusters.security from zigpy.zcl.clusters.security import IasZone from zhaquirks.const import ( - ARGS, CLUSTER_ID, COMMAND, COMMAND_BUTTON_DOUBLE, COMMAND_BUTTON_HOLD, COMMAND_BUTTON_SINGLE, - COMMAND_ID, DEVICE_TYPE, DOUBLE_PRESS, ENDPOINT_ID, @@ -27,10 +19,8 @@ LONG_PRESS, MODELS_INFO, OUTPUT_CLUSTERS, - PRESS_TYPE, PROFILE_ID, SHORT_PRESS, - ZHA_SEND_EVENT, ) # from __init__ import LINXURA, LinxuraIASCluster