diff --git a/README.md b/README.md index 7d7af7a..3acfb2b 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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) diff --git a/custom_components/zha_toolkit/__init__.py b/custom_components/zha_toolkit/__init__.py index 4d04f46..de70cf5 100644 --- a/custom_components/zha_toolkit/__init__.py +++ b/custom_components/zha_toolkit/__init__.py @@ -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( diff --git a/custom_components/zha_toolkit/binds.py b/custom_components/zha_toolkit/binds.py index fcb0fa1..14913fd 100644 --- a/custom_components/zha_toolkit/binds.py +++ b/custom_components/zha_toolkit/binds.py @@ -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 diff --git a/custom_components/zha_toolkit/services.yaml b/custom_components/zha_toolkit/services.yaml index addb8ef..c56c992 100644 --- a/custom_components/zha_toolkit/services.yaml +++ b/custom_components/zha_toolkit/services.yaml @@ -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] diff --git a/custom_components/zha_toolkit/zha.py b/custom_components/zha_toolkit/zha.py index 44610ac..aff7a42 100644 --- a/custom_components/zha_toolkit/zha.py +++ b/custom_components/zha_toolkit/zha.py @@ -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.