ZHA Binding

I’m confused. There is actually a binding tab in the ZigBee device management interface. It says binding and then provides options to bind to a device and bind to a ZigBee group.

I think the documentation on ZHA even indicates that binding is possible.

“ZHA support for binding and unbinding. Binding is an action in Zigbee which defines relations between two Zigbee devices, specific endpoints, and cluster id. It provides a mechanism for attaching an endpoint on one Zigbee node to one or more endpoints on another Zigbee node or Zigbee group (a group of Zigbee devices).”

Yes you can. My Ikea bulb and Ikea button are ‘bound’, and I still can operate them through HA. But I can’t answer OP’s question, since I use Zigbee2MQTT

Side question. Did you start with zigbee2mqtt or migrate from zha to it. I’ve heard of a lot of success with zigbee2mqtt in binding and other areas and have considered migrating over and wondered if it’s worth it.

I started with Zigbee2MQTT when then CC2531/CC2530 was the only supported adapter, and ZHA did not support these yet. (beginning of 2019). Never saw the need to switch to ZHA.

You learn something new every day.

Am I right in understanding that this is a direct zigbee binding from device to device, so it bypasses Home Assistant ?

If HA is up, AND you have two devices bound, who ‘wins’ ? For example, if you directly bind a switch to (say) 4 bulbs, and for sake of example, HA has no automations based on that switch, what happens when you press the button and HA is running ?

Also, given my zigbee coordinator is running ZHA, which is intrinsically linked into HA, how might the zigbee network still even be up if HA is down ?

Very interested to learn more about this.

Nobody wins. If I press the button to on the light, or to increase brightness, it shows in HA, If I use HA to on the light, or to increase brightness, it just works.

This is kind of house the insteon pairing worked before. I could link the switches together and then link it all to home assistant. I haven’t figured out how to do it with ZigBee or zwave yet. I thought it would be as simple as going to binding but I do that and it flat out doesn’t work with zha.

I just tried another button and still can’t get it to bind. I grabbed zha toolkit and checked the bindings for each of the devices and nothing is there. I don’t think the binding feature is even functional in zha but now I’m wondering when it started failing

It appears there was an issue with Zigbee Binding on the v6.1 of HaOS and v6.2 came out last night to apparently fix that. I gave the generic steps a try and it works. So I can finally say i wasn’t doing anything wrong besides not reading the bug reports hahah

And its broken again with v7.2.

User error. My best guess is that the device was already bound and that is why it wasn’t working but i kept trying for 2 days and it finally worked.

1 Like

Just resurrecting this thread.

Whats the use case for binding vs using automations ?

Could I bind (say) an ikea remote dimmer to a tuya bulb and would the tuya bulb understand the command to dim ? Or does this rely on both devices conforming properly to the zigbee spec ?

For me it’s that the lights work even when home assistant is down when you bind a switch or a button to a light then it sends the command to turn off or on or dim directly to the light without going through the hub.

I had recently run into migrating home assistant to a different device and it was down for 3 days and I’m that time I couldn’t turn off the lights. Lol.

Could you explain how you did that for those of us new to ZHA toolkit?

Also, could you identify in ZHA toolkit how many bindings a device can have. ZHA docs states it is device dependent and for some devices it’s only one. This seems important, as in that scenario if the device is bound to the ZHA coordinator it’s a waste of time trying to bind it to any other device!

I honestly do not remember how I got the zha toolkit to report how many bindings were there. I think there is a bind_get service but outside of that I can’t remember. I was able to bind the devices in ZHA addon within home assistant. You can click on manage devices and then bindings.

I was able to bind Philips Hue RWL022 dimmer switches and ROM001 buttons to lights and groups of lights without any problem. Didn’t need the ZHA tooklit. There’s a post about it here:

Don’t know if the process is similar for other manufacturer’s devices. As far as Hue goes, I believe it’s the RWL021 dimmer switch that can only bind to one device.

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