Skip to content

Commit

Permalink
Merge pull request #9 from mdeweerd/dev
Browse files Browse the repository at this point in the history
- Add numeric attribute type to scan result
- define conf_report and scan_device in services.yaml (add options to ui)
  • Loading branch information
mdeweerd authored Feb 8, 2022
2 parents 08cbd12 + 6737034 commit 145569d
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 2 deletions.
7 changes: 5 additions & 2 deletions custom_components/zha_toolkit/scan_device.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ async def scan_cluster(cluster, is_server=True):
cmds_gen = "commands_received"
return {
"cluster_id": f"0x{cluster.cluster_id:04x}",
"title": cluster.name,
"name": cluster.ep_attribute,
"attributes": await discover_attributes_extended(cluster),
cmds_rec: await discover_commands_received(cluster, is_server),
Expand Down Expand Up @@ -157,10 +158,12 @@ async def discover_attributes_extended(cluster, manufacturer=None):
access_acl & foundation.AttributeAccessControl.READ != 0
):
to_read.append(attr_id)

attr_type_hex = f"0x{attr_rec.datatype:02x}"
if attr_type:
attr_type = [attr_type[1].__name__, attr_type[2].__name__]
attr_type = [attr_type_hex, attr_type[1].__name__, attr_type[2].__name__]
else:
attr_type = f"0x{attr_rec.datatype:02x}"
attr_type = attr_type_hex
try:
access = re.sub(
"^.*\\.",
Expand Down
145 changes: 145 additions & 0 deletions custom_components/zha_toolkit/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ execute:
- handle_join
- ieee_ping
- leave
- misc_reinitialize
- ota_notify
- rejoin
- remove_all_groups
Expand Down Expand Up @@ -72,36 +73,42 @@ execute:
number:
min: 1
max: 0xFFFF
mode: box
cmd:
description: Command Id (zcl_cmd)
selector:
number:
min: 0
max: 255
mode: box
endpoint:
description: target endpoint
selector:
number:
min: 1
max: 255
mode: box
cluster:
description: target cluster
selector:
number:
min: 0
max: 0xFFFF
mode: box
attribute:
description: target attribute id (or name, accepted in most cases)
selector:
number:
min: 0
max: 0xFFFF
mode: box
attr_type:
description: Attribute type (to write, ...)
selector:
number:
min: 0
max: 0xFFFF
mode: box
attr_val:
description: Attribute value to write
selector:
Expand All @@ -112,30 +119,35 @@ execute:
number:
min: 0
max: 0xFFFF
mode: box
max_interval:
description: Maximum report interval (seconds)
selector:
number:
min: 0
max: 0xFFFF
mode: box
reportable_change:
description: Minimum change before reporting
selector:
number:
min: 0
max: 65535
mode: box
dir:
description: Direction indicator, according to command
selector:
number:
min: 0
max: 1
mode: box
tries:
description: Number of times the zigbee packet should be attempted
selector:
number:
min: 0
max: 255
mode: box
state_id:
description: When defined, name of state to write the read attribute value to
example: sensor.example
Expand Down Expand Up @@ -207,32 +219,37 @@ attr_read:
number:
min: 1
max: 0xFFFF
mode: box
endpoint:
description: target endpoint
selector:
number:
min: 1
max: 255
mode: box
cluster:
description: target cluster
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
attribute:
description: target attribute id (or name, accepted in most cases)
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
tries:
description: Number of times the zigbee packet should be attempted
selector:
number:
min: 0
max: 255
mode: box
state_id:
description: When defined, name of state to write the read attribute value to
example: sensor.example
Expand Down Expand Up @@ -292,33 +309,38 @@ attr_write:
number:
min: 1
max: 0xFFFF
mode: box
endpoint:
description: target endpoint
selector:
number:
min: 1
max: 255
mode: box
cluster:
description: target cluster
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
attribute:
description: target attribute id (or name, accepted in most cases)
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
attr_type:
description: Attribute type (to write, ...)
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
attr_val:
description: Attribute value to write
required: true
Expand All @@ -330,6 +352,7 @@ attr_write:
number:
min: 0
max: 255
mode: box
state_id:
description: When defined, name of state to write the read attribute value to
example: sensor.example
Expand Down Expand Up @@ -435,12 +458,104 @@ bind_ieee:
number:
min: 0
max: 0xFFFF
mode: box
tries:
description: Number of times the zigbee packet should be attempted
selector:
number:
min: 0
max: 255
mode: box
event_success:
description: Event name in case of success
example: my_read_success_trigger_event
selector:
text:
event_fail:
description: Event name in case of failure
example: my_read_fail_trigger_event
selector:
text:
event_done:
description: Event name when the service call did all its work (either success or failure). Has event data with relevant attributes.
example: my_read_done_trigger_event
selector:
text:
expect_reply:
description: "Wait for/expect a reply (not used yet)"
selector:
boolean:
conf_report:
description: "Configure attribute reporting\nYou can set a high value for tries (100 or more) for sleepy devices."
fields:
ieee:
description: "Entity name,\ndevice name, or\nIEEE address of the node to execute command"
example: "00:0d:6f:00:05:7d:2d:34"
required: true
selector:
entity:
integration: zha
manf:
description: Manufacturer id
selector:
number:
min: 1
max: 0xFFFF
mode: box
endpoint:
description: target endpoint
selector:
number:
min: 1
max: 255
mode: box
cluster:
description: target cluster
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
attribute:
description: target attribute id (or name, accepted in most cases)
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
min_interval:
description: Minimum report interval (seconds)
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
max_interval:
description: Maximum report interval (seconds)
required: true
selector:
number:
min: 0
max: 0xFFFF
mode: box
reportable_change:
description: Minimum change before reporting
required: true
selector:
number:
min: 0
max: 65535
mode: box
tries:
description: Number of times the zigbee packet should be attempted
selector:
number:
min: 0
max: 255
mode: box
event_success:
description: Event name in case of success
example: my_read_success_trigger_event
Expand Down Expand Up @@ -503,6 +618,7 @@ handle_join:
number:
min: 1
max: 0xFFFF
mode: box
misc_reinitialize:
description: Reinitialize device
fields:
Expand All @@ -513,6 +629,35 @@ misc_reinitialize:
selector:
entity:
integration: zha
scan_device:
description: Scan device (result written to file in /config/scans)
fields:
ieee:
description: "Entity name,\ndevice name, or\nIEEE address of the node to execute command"
example: "00:0d:6f:00:05:7d:2d:34"
required: true
selector:
entity:
integration: zha
event_success:
description: Event name in case of success
example: my_read_success_trigger_event
selector:
text:
event_fail:
description: Event name in case of failure
example: my_read_fail_trigger_event
selector:
text:
event_done:
description: Event name when the service call did all its work (either success or failure). Has event data with relevant attributes.
example: my_read_done_trigger_event
selector:
text:
expect_reply:
description: "Wait for/expect a reply (not used yet)"
selector:
boolean:
znp_backup:
description: Backup coordinator data (znp, bellows/ezsp)
fields:
Expand Down

0 comments on commit 145569d

Please sign in to comment.