mdeweerd / zha-toolkit

🧰 Zigbee Home Assistant Toolkit - service for "rare" Zigbee operations using ZHA on Home Assistant
GNU General Public License v3.0
193 stars 29 forks source link

Binding manufacture cluster on more endpoints #154

Closed MattWestb closed 1 year ago

MattWestb commented 1 year ago

I have one new device IKEA Symfonisk 2 with updated firmware and i need binding cluster 0xfc80 on EP 2 and 3 to the coordinator for getting the command from them and implanting them in one device quirk. Device signature:

{
  "node_descriptor": "NodeDescriptor(logical_type=<LogicalType.EndDevice: 2>, complex_descriptor_available=0, user_descriptor_available=0, reserved=0, aps_flags=0, frequency_band=<FrequencyBand.Freq2400MHz: 8>, mac_capability_flags=<MACCapabilityFlags.AllocateAddress: 128>, manufacturer_code=4476, maximum_buffer_size=82, maximum_incoming_transfer_size=82, server_mask=11264, maximum_outgoing_transfer_size=82, descriptor_capability_field=<DescriptorCapability.NONE: 0>, *allocate_address=True, *is_alternate_pan_coordinator=False, *is_coordinator=False, *is_end_device=True, *is_full_function_device=False, *is_mains_powered=False, *is_receiver_on_when_idle=False, *is_router=False, *is_security_capable=False)",
  "endpoints": {
    "1": {
      "profile_id": 260,
      "device_type": "0x0006",
      "in_clusters": [
        "0x0000",
        "0x0001",
        "0x0003",
        "0x0020",
        "0x1000",
        "0xfc7c"
      ],
      "out_clusters": [
        "0x0003",
        "0x0004",
        "0x0006",
        "0x0008",
        "0x0019",
        "0x1000"
      ]
    },
    "2": {
      "profile_id": 260,
      "device_type": "0x0006",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0xfc80"
      ],
      "out_clusters": [
        "0x0003",
        "0x0004",
        "0xfc80"
      ]
    },
    "3": {
      "profile_id": 260,
      "device_type": "0x0006",
      "in_clusters": [
        "0x0000",
        "0x0003",
        "0xfc80"
      ],
      "out_clusters": [
        "0x0003",
        "0x0004",
        "0xfc80"
      ]
    }
  },
  "manufacturer": "IKEA of Sweden",
  "model": "SYMFONISK sound remote gen2",
  "class": "ikea.symfonisk.IkeaSYMFONISKgen2V2"
}

I trying bind IEEE with this command but wireshark is showing ZHA is not sending it.

service: zha_toolkit.bind_ieee
data:
  ieee: 1c:34:f1:ff:fe:78:57:15
  command_data: "0"
  cluster: 64640
  tries: 5

If is trying couster 6 is doing binding on EP 1 OK. ZHA log then trying binding:

2023-03-05 10:46:33.254 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] Received command 0x02 (TSN 24): toggle()
2023-03-05 10:46:33.256 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] No explicit handler for cluster command 0x02: toggle()
2023-03-05 10:46:33.749 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script
2023-03-05 10:46:33.750 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service
2023-03-05 10:46:33.754 INFO (MainThread) [custom_components.zha_toolkit] Running ZHA Toolkit service: <ServiceCall zha_toolkit.bind_ieee (c:01GTRJMVWHZ68FHRHQ63QQ47K5): ieee=1c:34:f1:ff:fe:78:57:15, command_data=0, cluster=64640, tries=5>
2023-03-05 10:46:33.843 DEBUG (MainThread) [custom_components.zha_toolkit] module is <module 'custom_components.zha_toolkit' from '/config/custom_components/zha_toolkit/__init__.py'>
2023-03-05 10:46:33.855 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Parameters '{'ieee': 1c:34:f1:ff:fe:78:57:15, 'command_data': '0', 'cluster': 64640, 'tries': 5}'
2023-03-05 10:46:33.857 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Final manf 'None'
2023-03-05 10:46:33.860 DEBUG (MainThread) [custom_components.zha_toolkit] 'ieee' parameter: '1c:34:f1:ff:fe:78:57:15' -> IEEE Addr: '1c:34:f1:ff:fe:78:57:15'
2023-03-05 10:46:33.862 DEBUG (MainThread) [custom_components.zha_toolkit] Default handler for bind_ieee
2023-03-05 10:46:33.862 DEBUG (MainThread) [custom_components.zha_toolkit] Handler: <function command_handler_default at 0x8d3f9b20>
2023-03-05 10:46:33.863 DEBUG (MainThread) [custom_components.zha_toolkit] running default command: <ServiceCall zha_toolkit.bind_ieee (c:01GTRJMVWHZ68FHRHQ63QQ47K5): ieee=1c:34:f1:ff:fe:78:57:15, command_data=0, cluster=64640, tries=5>
2023-03-05 10:46:33.873 DEBUG (MainThread) [custom_components.zha_toolkit.default] Trying to import custom_components.zha_toolkit.binds to call bind_ieee
2023-03-05 10:46:33.885 DEBUG (MainThread) [custom_components.zha_toolkit.utils] NWK addr 0x0000 -> 00:0d:6f:ff:fe:12:db:36
2023-03-05 10:46:33.886 DEBUG (MainThread) [custom_components.zha_toolkit.utils] IEEE for get_device: 00:0d:6f:ff:fe:12:db:36
2023-03-05 10:46:33.888 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: got endpoints [2, 3] for out-cluster 0xFC80
2023-03-05 10:46:33.892 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: got endpoints [2, 3] for in cluster 0xFC80
2023-03-05 10:46:33.893 DEBUG (MainThread) [custom_components.zha_toolkit] event_data {'zha_toolkit_version': 'dev', 'zigpy_version': '0.53.2', 'zigpy_rf_version': '0.34.9', 'ieee_org': 1c:34:f1:ff:fe:78:57:15, 'ieee': '1c:34:f1:ff:fe:78:57:15', 'command': 'bind_ieee', 'command_data': '0', 'start_time': '2023-03-05T09:46:33.860528+00:00', 'errors': [], 'params': {'cluster_id': 64640, 'dir': 0, 'tries': 5, 'expect_reply': True, 'args': [], 'read_before_write': True, 'read_after_write': True}, 'result': {}, 'success': False}
2023-03-05 10:46:34.626 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xBD72](SYMFONISK sound remote gen2): Device seen - marking the device available and resetting counter
2023-03-05 10:46:34.628 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0xBD72](SYMFONISK sound remote gen2): Update device availability - device available: True - new availability: True - changed: False

Can you pleas hinting my what i is doing wrong ?

Thanks in advance !!

MattWestb commented 1 year ago

Wast trying putting the coordinator IEEE as data:

service: zha_toolkit.bind_ieee
data:
  ieee: 1c:34:f1:ff:fe:78:57:15
  command_data: 00:0d:6f:ff:fe:12:db:36
  cluster: 64640
  tries: 5

And then ZHA is sending the bind request and the device is responding success and start sending commands from EP 2 and 3.

So i think the data 0 is not working for binding the coordinator as in the instruction.

Edit:

ZHA log:

2023-03-05 11:03:13.809 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] Decoded ZCL frame: OnOff:toggle()
2023-03-05 11:03:13.813 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] Received command 0x02 (TSN 25): toggle()
2023-03-05 11:03:13.815 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] No explicit handler for cluster command 0x02: toggle()
2023-03-05 11:03:14.197 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Running websocket_api script
2023-03-05 11:03:14.198 INFO (MainThread) [homeassistant.helpers.script.websocket_api_script] websocket_api script: Executing step call service
2023-03-05 11:03:14.202 INFO (MainThread) [custom_components.zha_toolkit] Running ZHA Toolkit service: <ServiceCall zha_toolkit.bind_ieee (c:01GTRKKCWKBHPTJA37CCJGYSMB): ieee=1c:34:f1:ff:fe:78:57:15, command_data=00:0d:6f:ff:fe:12:db:36, cluster=64640, tries=5>
2023-03-05 11:03:14.283 DEBUG (MainThread) [custom_components.zha_toolkit] module is <module 'custom_components.zha_toolkit' from '/config/custom_components/zha_toolkit/__init__.py'>
2023-03-05 11:03:14.295 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Parameters '{'ieee': 1c:34:f1:ff:fe:78:57:15, 'command_data': '00:0d:6f:ff:fe:12:db:36', 'cluster': 64640, 'tries': 5}'
2023-03-05 11:03:14.296 DEBUG (MainThread) [custom_components.zha_toolkit.utils] Final manf 'None'
2023-03-05 11:03:14.300 DEBUG (MainThread) [custom_components.zha_toolkit] 'ieee' parameter: '1c:34:f1:ff:fe:78:57:15' -> IEEE Addr: '1c:34:f1:ff:fe:78:57:15'
2023-03-05 11:03:14.301 DEBUG (MainThread) [custom_components.zha_toolkit] Default handler for bind_ieee
2023-03-05 11:03:14.302 DEBUG (MainThread) [custom_components.zha_toolkit] Handler: <function command_handler_default at 0x8babeec8>
2023-03-05 11:03:14.303 DEBUG (MainThread) [custom_components.zha_toolkit] running default command: <ServiceCall zha_toolkit.bind_ieee (c:01GTRKKCWKBHPTJA37CCJGYSMB): ieee=1c:34:f1:ff:fe:78:57:15, command_data=00:0d:6f:ff:fe:12:db:36, cluster=64640, tries=5>
2023-03-05 11:03:14.314 DEBUG (MainThread) [custom_components.zha_toolkit.default] Trying to import custom_components.zha_toolkit.binds to call bind_ieee
2023-03-05 11:03:14.333 DEBUG (MainThread) [custom_components.zha_toolkit.utils] IEEE for get_device: 00:0d:6f:ff:fe:12:db:36
2023-03-05 11:03:14.334 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: got endpoints [2, 3] for out-cluster 0xFC80
2023-03-05 11:03:14.336 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xbd72: binding 1c:34:f1:ff:fe:78:57:15/EP:2, out-cluster 0xFC80 to 00:0d:6f:ff:fe:12:db:36/EP:1
2023-03-05 11:03:14.338 DEBUG (MainThread) [zigpy.device] [0xbd72] Extending timeout for 0x0e request
2023-03-05 11:03:14.930 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xBD72), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=6, profile_id=0, cluster_id=32801, data=Serialized[b'\x0e\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=196, rssi=-54)
2023-03-05 11:03:14.935 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xbd72: binding ieee 00:0d:6f:ff:fe:12:db:36: [<Status.SUCCESS: 0>]
2023-03-05 11:03:14.936 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xbd72: binding 1c:34:f1:ff:fe:78:57:15/EP:3, out-cluster 0xFC80 to 00:0d:6f:ff:fe:12:db:36/EP:1
2023-03-05 11:03:14.943 DEBUG (MainThread) [zigpy.device] [0xbd72] Extending timeout for 0x10 request
2023-03-05 11:03:15.888 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xBD72), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=7, profile_id=0, cluster_id=32801, data=Serialized[b'\x10\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=204, rssi=-52)
2023-03-05 11:03:15.899 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xbd72: binding ieee 00:0d:6f:ff:fe:12:db:36: [<Status.SUCCESS: 0>]
2023-03-05 11:03:15.900 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: got endpoints [2, 3] for in cluster 0xFC80
2023-03-05 11:03:15.902 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: binding 1c:34:f1:ff:fe:78:57:15/EP:2, in-cluster: 0xFC80 to 00:0d:6f:ff:fe:12:db:36/EP:1
2023-03-05 11:03:15.908 DEBUG (MainThread) [zigpy.device] [0xbd72] Extending timeout for 0x12 request
2023-03-05 11:03:16.732 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x2F6F](TRADFRI motion sensor): Device seen - marking the device available and resetting counter
2023-03-05 11:03:16.733 DEBUG (MainThread) [homeassistant.components.zha.core.device] [0x2F6F](TRADFRI motion sensor): Update device availability - device available: True - new availability: True - changed: False
2023-03-05 11:03:16.904 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xBD72), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=8, profile_id=0, cluster_id=32801, data=Serialized[b'\x12\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=204, rssi=-54)
2023-03-05 11:03:16.912 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: binding ieee 00:0d:6f:ff:fe:12:db:36: [<Status.SUCCESS: 0>]
2023-03-05 11:03:16.913 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: binding 1c:34:f1:ff:fe:78:57:15/EP:3, in-cluster: 0xFC80 to 00:0d:6f:ff:fe:12:db:36/EP:1
2023-03-05 11:03:16.916 DEBUG (MainThread) [zigpy.device] [0xbd72] Extending timeout for 0x14 request
2023-03-05 11:03:17.230 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xBD72), src_ep=1, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=1, source_route=None, extended_timeout=False, tsn=9, profile_id=260, cluster_id=6, data=Serialized[b'\x11\x1a\x02'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=204, rssi=-54)
2023-03-05 11:03:17.234 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] Received ZCL frame: b'\x11\x1a\x02'
2023-03-05 11:03:17.250 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] Decoded ZCL frame header: ZCLHeader(frame_control=FrameControl(frame_type=<FrameType.CLUSTER_COMMAND: 1>, is_manufacturer_specific=0, direction=<Direction.Server_to_Client: 0>, disable_default_response=1, reserved=0, *is_cluster=True, *is_general=False, *is_reply=False), tsn=26, command_id=2, *direction=<Direction.Server_to_Client: 0>, *is_reply=False)
2023-03-05 11:03:17.256 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] Decoded ZCL frame: OnOff:toggle()
2023-03-05 11:03:17.259 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] Received command 0x02 (TSN 26): toggle()
2023-03-05 11:03:17.269 DEBUG (MainThread) [zigpy.zcl] [0xBD72:1:0x0006] No explicit handler for cluster command 0x02: toggle()
2023-03-05 11:03:18.282 DEBUG (MainThread) [zigpy.application] Received a packet: ZigbeePacket(src=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0xBD72), src_ep=0, dst=AddrModeAddress(addr_mode=<AddrMode.NWK: 2>, address=0x0000), dst_ep=0, source_route=None, extended_timeout=False, tsn=10, profile_id=0, cluster_id=32801, data=Serialized[b'\x14\x00'], tx_options=<TransmitOptions.NONE: 0>, radius=0, non_member_radius=0, lqi=200, rssi=-52)
2023-03-05 11:03:18.287 DEBUG (MainThread) [custom_components.zha_toolkit.binds] 0xBD72: binding ieee 00:0d:6f:ff:fe:12:db:36: [<Status.SUCCESS: 0>]
2023-03-05 11:03:18.288 DEBUG (MainThread) [custom_components.zha_toolkit] event_data {'zha_toolkit_version': 'dev', 'zigpy_version': '0.53.2', 'zigpy_rf_version': '0.34.9', 'ieee_org': 1c:34:f1:ff:fe:78:57:15, 'ieee': '1c:34:f1:ff:fe:78:57:15', 'command': 'bind_ieee', 'command_data': '00:0d:6f:ff:fe:12:db:36', 'start_time': '2023-03-05T10:03:14.299793+00:00', 'errors': [], 'params': {'cluster_id': 64640, 'dir': 0, 'tries': 5, 'expect_reply': True, 'args': [], 'read_before_write': True, 'read_after_write': True}, 'result': {2: {'src_endpoint_id': 2, 'dst_endpoint_id': 1, 'cluster_id': 64640, 'result': [<Status.SUCCESS: 0>]}, 3: {'src_endpoint_id': 3, 'dst_endpoint_id': 1, 'cluster_id': 64640, 'result': [<Status.SUCCESS: 0>]}}, 'success': True}
mdeweerd commented 1 year ago

Thank you @MattWestb for reporting this with precision.

The code did check for 0 but in this case it is a string that is "0" so it does not match the number 0.

I updated the code to match "0" as well.

It is likely that if you do not specify command_data or if you leave empty that it also worked.

I do not release a new version specifically for this, but it will be in a future release.

MattWestb commented 1 year ago

Thanks for you great work with this tool !!

I was struggling and was getting it working more or less mistake then your instructions is very good and i was first thinking it was one bug.

Was testing without data in the GUI but the system dont like it and throwing one error.

mdeweerd commented 1 year ago

Ok, I see - I changed the code so that the "command_data" is not longer required for that service.