Skip to content

Commit

Permalink
Merge pull request #169 from mdeweerd/dev
Browse files Browse the repository at this point in the history
Fix #168
  • Loading branch information
mdeweerd committed Jun 10, 2023
2 parents f8a8f52 + 1227d27 commit 6499f64
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 6 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ endpoint ID (a byte), the cluster ID (a two byte word), and the attribute
ID (a two byte word as well).

Attributes have different types, such as boolean, unsigned and signed byte,
arrays, timestamps, and more. Most of the time, the attribute type can be
generally determined automatically by tools like zha-toolkit and ZHA.
arrays, timestamps, and more. In most cases, the attribute type can be
determined automatically by tools like zha-toolkit and ZHA.

The Zigbee Cluster Library (ZCL) document defines standard attributes and
their organization in clusters. Manufacturers also have the freedom to add
Expand Down Expand Up @@ -1709,6 +1709,8 @@ allows you to get information about endpoints and services as well.
```yaml
service: zha_toolkit.zha_devices
data:
# Optional: Device to report on, by default all devices are in the report
ieee: sensor.my_zha_sensor
# Optional list of fields to write to the CSV, all non-list fields by default.
command_data: [name, ieee, rssi, lqi]
# Optional, field the list is sorted by (example: sort by signal strength)
Expand Down
6 changes: 5 additions & 1 deletion custom_components/zha_toolkit/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,11 @@
extra=vol.ALLOW_EXTRA,
),
S.ZHA_DEVICES: vol.Schema(
{},
{
vol.Optional(ATTR_IEEE): vol.Any(
cv.entity_id_or_uuid, t.EUI64.convert
),
},
extra=vol.ALLOW_EXTRA,
),
S.HANDLE_JOIN: vol.Schema(
Expand Down
5 changes: 3 additions & 2 deletions custom_components/zha_toolkit/binds.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,10 +219,11 @@ async def bind_ieee(
# when command_data is set to 0 or false, bind to coordinator
data = app.ieee

isCoordinatorTarget = str(data) == str(app.ieee)

dst_dev = await u.get_device(app, listener, data)

# Coordinator has nwk address 0
isCoordinatorTarget = dst_dev.nwk == 0x0000

zdo = src_dev.zdo
src_out_clusters = BINDABLE_OUT_CLUSTERS
src_in_clusters = BINDABLE_IN_CLUSTERS
Expand Down
11 changes: 10 additions & 1 deletion custom_components/zha_toolkit/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2142,8 +2142,17 @@ znp_backup:
selector:
boolean:
zha_devices:
description: Export IEEE device information to CSV file or Event
description: Export device information to CSV file or Event
fields:
ieee:
description: >-
Optional Entity name,\ndevice name, or IEEE address of the device to
provide details for. By dfault: all devices
example: 00:0d:6f:00:05:7d:2d:34
required: false
selector:
entity:
integration: zha
command_data:
description: List of columns for csv file
example: [ieee, lqi, name]
Expand Down
6 changes: 6 additions & 0 deletions custom_components/zha_toolkit/zha.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ async def zha_devices(
# 'endpoints'

devices = [device.zha_device_info for device in listener.devices.values()]

if ieee is not None:
ieee = str(ieee)
# Select only the device with the given address
devices = [d for d in devices if str(d["ieee"]) == ieee]

# Set default value for 'devices' in event_data,
# may be slimmed down. Ensures that devices is set in case
# an exception occurs.
Expand Down

0 comments on commit 6499f64

Please sign in to comment.