Skip to content

Commit

Permalink
Fix default handling for ZCLCommandButtonMetadata
Browse files Browse the repository at this point in the history
  • Loading branch information
dmulcahey committed Aug 3, 2024
1 parent 3406c48 commit d27fc08
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion tests/test_quirks_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,10 @@ async def test_quirks_v2_command_button(device_mock):
"on_off_control_foo": OnOff.OnOffControl.Accept_Only_When_On
},
)
.command_button(
OnOff.ServerCommandDefs.on_with_timed_off.name,
OnOff.cluster_id,
)
.add_to_registry()
)

Expand All @@ -634,7 +638,6 @@ async def test_quirks_v2_command_button(device_mock):

assert quirked_device.endpoints[1].in_clusters.get(OnOff.cluster_id) is not None

# pylint: disable=line-too-long
button: EntityMetadata = quirked_device.exposes_metadata[
(1, OnOff.cluster_id, ClusterType.Server)
][0]
Expand All @@ -655,6 +658,13 @@ async def test_quirks_v2_command_button(device_mock):
)
assert button != quirked_device

button = quirked_device.exposes_metadata[(1, OnOff.cluster_id, ClusterType.Server)][
2
]

assert button.kwargs == {}
assert button.args == ()


async def test_quirks_v2_also_applies_to(device_mock):
"""Test adding the same quirk for multiple manufacturers and models."""
Expand Down
4 changes: 2 additions & 2 deletions zigpy/quirks/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -784,8 +784,8 @@ def command_button(
initially_disabled=initially_disabled,
translation_key=translation_key,
command_name=command_name,
args=command_args,
kwargs=command_kwargs,
args=command_args if command_args is not None else (),
kwargs=command_kwargs if command_kwargs is not None else frozendict(),
)
)
return self
Expand Down

0 comments on commit d27fc08

Please # to comment.