ZHA Binding

I just got my first binding to actually work (an IKEA STYRBAR remote control, firmware 0x00010024, with a group of TADFRI lightbulbs 1055lm). I wanted to share it for those who did not succeed at first and stumbled upon this thread, as was the case for me.

Update: I was wrong about having to unbind the coordinator first. It was not necessary after all. It’s such a trial-and-error land here, that I missed another important point. So, unbinding the coordinator might be necessary on some isolated devices (or, to reduce network traffic expclicitely), but it was not necessary in my case. What was important to do, was: tap on the remote just after clicking on “Bind”. That way, the remote wakes up and receives the command. If you don’t, it will not receive it.

I am correcting my list and adding another information about debugging below.

  1. Go to the device panel of the Remote Control → threedots → Manage Zigbee Device
  2. If you want to connect only one device and not a group: Select the Device (e.g., Lamp) from the upper select menu
  3. Or, If you want to bind a group of devices: If not yet created, go to View Network → select the Groups Tab → Create new Zigbee Group (I called mine G01), and add one or more lamps / devices to it; then return to the Manage Zigbee Device for the remote, and select it from the group select menu.
  4. Both for device or Group: Select one or more Clusters from the list below the groups (this is a really confusing UX bug: It looks like the clusters are only related to groups, but that is not the case, they also apply to the device binding!).
    For example, for a dimmable light, you may select both “OnOff” and “LevelControl”. Note that if you are binding two devices of the same manufacturer, you can also bind a cluster specific to that vendor (such as the Ikea functionality, ManufacturerSpecificCluster 0xfc57 from Ikea remote to Ikea lamp).
    This can enable the standard behavior that would come when you “natively” bind those two devices instead of adding them to HA.
  5. Click Bind or Bind Group depending on choice
  6. Immediately after clicking, do something with the source device to wake it up. For example, click one of the buttons of a remote; in the case of a motion sensor, have somebody dance in front of it.
  7. ZHA will create a binding for each device/group+cluster combination you selected
  8. Verification / Debugging:
    The current “Binding” Tab in the “Manage Zigbee Device” Panel of HA/ZHA has a bug: It does not really show the current bindings. There is currently no way to show this information in the UI, unfortunately. So you’re left with testing the remote, or you can use the add-on zha-toolkit (see GitHub - mdeweerd/zha-toolkit: 🧰 Zigbee Home Assistant Toolkit - service for "rare" Zigbee operations using ZHA on Home Assistant ) and issue the following command in Developer Tools / Actions (after installing and activating the toolkit and restarting HA):

(replace xx.xx.xx.xx.xx. with the IEEE address of the source device. It is shown under Device Info when you click on the arrow near Zigbee Info):

action: zha_toolkit.binds_get
data:
  ieee: xx:xx:xx:xx:xx:xx:xx:xx
  tries: 100
  expect_reply: true

Immediately after clicking “Perform action” you should wake up the device, like above.

Hope it helps anyone trying to achieve some bindings. It’s good to have lights go on even when I’m updating HA.

Notes:

  • The UI does not show the bindings as selected when re-opening the control. You’ll have to note down somewhere who you bound with whom.
  • The Remote is still visible in HA, and it is still reporting events on the UI.
  • To remove a Binding you have to do the same, you did to bind, but click unbind instead.
  • I’ve had some devices not working with the binding, although the zha-toolkit showed that the binding was there.
  • Some devices - for example multi-power strips where you can command each single plug on it - have multiple endpoints. You can bind to a specific endpoint, but that does not work with the UI. You’ll have to do it with zha-toolkit at the moment, and specify the endpoint there. Example of binding a device (as always, don’t forget to wake it up…):
action: zha_toolkit.bind_ieee
data:
  ieee:  xx:xx:xx:xx:xx:xx:xx:xx # (IEEE of remote)
  command_data: yy:yy:yy:yy:yy:yy:yy # (IEEE of target device)
  cluster: 6  # (e.g., the OnOff cluster (*)) 
  dst_endpoint: 3 # The endpoint. Here: the third plug..
  expect_reply: true
  tries: 100

(*) The supported clusters on each device are available in ZHA under “Manage Zigbee Device” → Clusters (pop open the menu).
The “cluster” key for the zha_toolkit action takes the integer value of it. So in case of 0x0006 (OnOff), it’s simply 6; ;or 8 (0x0008) for “LevelControl”. In case of a higher one, such as 0xfc57, make sure to convert it properly (eg with a a programming calculator) to the corresponding integer (in the latter example, 64599).

1 Like

@lopezio if you want to help further then edit the section about groups and bindings then submit those changes to the ZHA documentation on GitHub → https://www.home-assistant.io/integrations/zha#zigbee-groups-and-binding-devices

Hi @Hedda Thank You. At the current state of things, I think it would be more appropriate to submit a bugfix / layout proposal for the “Manage Zigbee Device” Panel directly in ZHA. As written above in my redacted post, its current layout is confusing, and there is functionality missing, such as querying (at least on demand with an “update” button) the current state of bindings of a device, thus offering “trash” symbols for each of it to remove it. Also, it is missing the possibility to specify the destination endpoint, which in some cases can be crucial. Last but not least, the cluster choice should be clearly offered for both device and group bindings. Writing workarounds is probably best kept here. If I have the time, I’ll have a look at the code and / or make such a submission. Best Regards, Lorenzo

Update: Just submitted here (should anyone feel the urge to vote it up… ;)):

1 Like

@lopezio That would be awesome! Especially now that the developer of the ZHA-Toolkit looks to have taken a break from that project it would be great of some of the more commonly used features/functiona from it could be implemented into ZHA in a UX friendly way. I also wish there was more UX consistancy b Zigbee and the Z-Wave JS integration as they otherwise share so much functionallity