Skip to content

Commit a4bfd71

Browse files
committed
Merge branch 'pr270' into dev
2 parents 9c63447 + 71c6176 commit a4bfd71

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

custom_components/zha_toolkit/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@
508508
vol.Optional(P.ENDPOINT): vol.Any(cv.byte, [cv.byte]),
509509
vol.Optional(P.CLUSTER): vol.Range(0, 0xFFFF),
510510
vol.Optional(P.MANF): vol.Range(0, 0xFFFF),
511+
vol.Optional(P.KWARGS): dict,
511512
vol.Optional(P.ARGS): vol.Any(
512513
int, list, cv.string
513514
), # Arguments to command

custom_components/zha_toolkit/params.py

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class USER_PARAMS_consts: # pylint: disable=too-few-public-methods
2020
TRIES = "tries"
2121
EXPECT_REPLY = "expect_reply"
2222
ARGS = "args"
23+
KWARGS = "kwargs"
2324
STATE_ID = "state_id"
2425
STATE_ATTR = "state_attr"
2526
ALLOW_CREATE = "allow_create"
@@ -105,6 +106,7 @@ class INTERNAL_PARAMS_consts: # pylint: disable=too-few-public-methods
105106
__slots__ = ()
106107
ALLOW_CREATE = "allow_create"
107108
ARGS = "args"
109+
KWARGS = "kwargs"
108110
ATTR_ID = "attr_id"
109111
ATTR_TYPE = "attr_type"
110112
ATTR_VAL = "attr_val"

custom_components/zha_toolkit/services.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -2399,6 +2399,12 @@ zcl_cmd:
23992399
example: [1, abcd, 3]
24002400
selector:
24012401
text:
2402+
kwargs:
2403+
name: Command Keyword Arguments
2404+
description: Keyword arguments for command
2405+
example: { "code": "cool_code" }
2406+
selector:
2407+
text:
24022408
tries:
24032409
name: Tries
24042410
description: Number of times the zigbee packet should be attempted

custom_components/zha_toolkit/utils.py

+4
Original file line numberDiff line numberDiff line change
@@ -873,6 +873,7 @@ def extractParams( # noqa: C901
873873
p.TRIES: 1,
874874
p.EXPECT_REPLY: True,
875875
p.ARGS: [],
876+
p.KWARGS: {},
876877
p.STATE_ID: None,
877878
p.STATE_ATTR: None,
878879
p.STATE_VALUE_TEMPLATE: None,
@@ -978,6 +979,9 @@ def extractParams( # noqa: C901
978979
LOGGER.debug("cmd converted arg %s", lval)
979980
params[p.ARGS] = cmd_args
980981

982+
if P.KWARGS in rawParams:
983+
params[P.KWARGS] = rawParams[P.KWARGS]
984+
981985
if P.MIN_INTRVL in rawParams:
982986
params[p.MIN_INTERVAL] = str2int(rawParams[P.MIN_INTRVL])
983987
if P.MAX_INTRVL in rawParams:

custom_components/zha_toolkit/zcl_cmd.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ async def zcl_cmd(app, listener, ieee, cmd, data, service, params, event_data):
5252
expect_reply = params[p.EXPECT_REPLY]
5353

5454
cmd_args = params[p.ARGS]
55+
kw_args = params[p.KWARGS]
5556

5657
# Direction 0 = Client to Server, as in protocol bit
5758
is_in_cluster = dir_int == 0
@@ -120,6 +121,7 @@ async def zcl_cmd(app, listener, ieee, cmd, data, service, params, event_data):
120121
manufacturer=manf,
121122
expect_reply=expect_reply,
122123
tries=tries,
124+
**kw_args,
123125
)
124126
else:
125127
if cluster_id not in endpoint.out_clusters:
@@ -134,7 +136,7 @@ async def zcl_cmd(app, listener, ieee, cmd, data, service, params, event_data):
134136

135137
# Note: client_command not tested
136138
event_data["cmd_reply"] = await cluster.client_command(
137-
cmd_id, *cmd_args, manufacturer=manf
139+
cmd_id, *cmd_args, manufacturer=manf, **kw_args
138140
)
139141
except Exception as e:
140142
caught_e = e

0 commit comments

Comments
 (0)