Skip to content

Commit

Permalink
Apply pre-commit auto fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 6, 2024
1 parent 5ab15e4 commit 520d411
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
17 changes: 6 additions & 11 deletions tests/test_linxura.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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,))
Expand All @@ -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
5 changes: 2 additions & 3 deletions zhaquirks/linxura/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -36,7 +36,6 @@
ZHA_SEND_EVENT,
)


DOUBLE = 2
HOLD = 3
# LINXURA = "Linxura"
Expand Down Expand Up @@ -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)
self.listener_event(ZHA_SEND_EVENT, action, event_args)
12 changes: 1 addition & 11 deletions zhaquirks/linxura/button.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -27,10 +19,8 @@
LONG_PRESS,
MODELS_INFO,
OUTPUT_CLUSTERS,
PRESS_TYPE,
PROFILE_ID,
SHORT_PRESS,
ZHA_SEND_EVENT,
)

# from __init__ import LINXURA, LinxuraIASCluster
Expand Down

0 comments on commit 520d411

Please sign in to comment.