How to bind to specific cluster

I’ve been trying to set up binding using ZHA with an in-wall remote device but it seems that I can only bind the whole device to another, rather than specific clusters/endpoints to the individual devices/groups I want it to control.

The C4 has 4 buttons, which in the Ubisys app I was able to change what they did (specifically which cluster they sent when pressed, which I am also unclear how to do with ZHA). I had Level 1 cluster connected to the D1 dimmer and Level 2 cluster set to the Tradfri driver.

When I tried selecting the manage clusters for the device and then selecting a cluster and device to bind, it appears to bind at the root level, meaning all 4 buttons send their commands to that device, rather than the selected cluster. Screenshot shows how I have attempted to do it. Should I be trying to do this in a different way to set each item to bind without needing to configure it via automations that mean it won’t work if HASS is down? I also want to use the config/binding correctly as it allows the switch to work as a live dimmer for the lights on the remove dimmer which worked well with the Ubisys gateway so I know the config can be done, I just seem to be getting it wrong.

Thanks!

While not exactly the answer you are looking for, you can probably accomplish this with Node Red, and “events: all” and “call services”.

Just a bit of prep work:
click on your name at the bottom left of the home assistant side bar and then toggle “Advanced Mode” to on.

Then click on “Developer Tools”
Then “Events”
Under “Listen to events” type:

*

and then click “START LISTENING”

push the first button you want to automate. You should see something like this: (note I am doing this with a different device, so what you will see should/may be very different, but you can use the same process):

{
    "event_type": "zha_event",
    "data": {
        "device_ieee": <sanitized>,
        "unique_id": <sanitized>,
        "endpoint_id": 1,
        "cluster_id": 8,
        "command": "step_with_on_off",
        "args": [
            0,
            43,
            5
        ]
    },
    "origin": "LOCAL",
    "time_fired": <sanitized>,
    "context": {
        "id": <sanitized>,
        "parent_id": null,
        "user_id": null
    }
}

I put in to remove identifying information. The important part is what is in the “command”.

The next thing you need to do is open home assistant in a new tab, and issue the cluster command the same way you were doing, that you want to control with the button you just pressed. Make sure you are still listening to *

you should see something like this:

{
    "event_type": "call_service",
    "data": {
        "domain": "zha",
        "service": "issue_zigbee_cluster_command",
        "service_data": {
            "ieee": "00:00:00:00:00:00:00:00",
            "endpoint_id": 1,
            "cluster_id": 257,
            "cluster_type": "out",
            "command": 6,
            "command_type": "server",
            "args": [
                0
            ]
        }
    },
    "origin": "LOCAL",
    "time_fired": <sanitized>,
    "context": {
        "id": <sanitized>,
        "parent_id": null,
        "user_id": <sanitized>
    }
}

The important part is the part in the data squiggly brackets.

with these two things you can head over to Node Red (you may need to install this if you haven’t).

In node red drag in the “events: all” box
double click on it
give it a name (doesn’t matter)
under “Event Type” select:

zha_event

next up, add a “switch” box
connect the two nodes with a line
double click on the switch box
give it a name (doesn’t matter)
under Property make sure “msg.” is selected
and then type

payload.event.command

this will refer to the command in the first code block from the remote (for me this was “step_with_on_off”, for you it may be different)
underneath that select “==” from the drop down menu, select “az” from the next drop down menu, and in the dialog box type the command, for me with the command “step_with_on_off”, I would type:

step_with_on_off

to add additional commands, click the “+add” button near the bottom.

scroll back up and add the node “call service”
connect this to the right side of the switch with a line
double click on it
give it a name (doesn’t matter)
in domain select:

zha

in service select:

issue_zigbee_cluster_command

leave “Entity Id” blank
under “Data”, click the “…” at the right of the dialog box, copy paste everything from the cluster command after "service_data: " until the comma before “origin” into that, then click “format json”, so for me this looked like:

{
    "ieee": "00:00:00:00:00:00:00:00",
    "endpoint_id": 1,
    "cluster_id": 257,
    "cluster_type": "out",
    "command": 6,
    "command_type": "server",
    "args": [
        0
    ]
}

click deploy at the top right of node red, and then see if your button works (it should) repeat this for all buttons, adding statements to the switch if needed.

Let me know if that works or if you need any help :slight_smile:

1 Like

So this is what I considered as my backup, but the main reason I prefer the bindings (in this case) is that it ensures the light switch acts like a light switch even if the controller is down because they can comms directly. Plus it is super fast, feels like a wired switch fast. Your method does work great for automation triggers though (something more complex than ZigBee’s concept of scenes. like turning off everything including TVs, etc.)

It seems it is possible when using ZigBee over MQTT instead of ZHA but moving the network is a huge headache I don’t need! haha. I am not sure how “common” the two platforms are and the docs for the MQTT option I couldn’t see a way to attempt that on the ZHA style implementation. And it is beyond my nerd skills to try and contribute something with my current understanding of the various components and how they interact.

3 Likes

Apologies for resurrecting an old thread, but wondering if you ever managed to achieve such bindings with ZHA? That’s what I’m running and I finally have a wall “scene controller” that supports binding, and I’m scratching my head over how to do it.

Like you, this is very important to me. I’m replacing some old LightWaveRF kit that had exactly this functionality. I’d much prefer to be able to do it in ZHA, but if I have to move to the MQTT solution so be it I guess…

No luck with ZHA, it can only bind at the whole device level (I currently have 4 switches that all talk to the same light!).

I was considering moving to the MQTT version of ZigBee though because it seems to support cluster based binding, I just haven’t had the time to reset everything and shift across to try it out and see if it legit works. (I don’t think there’s a direct move option?)

1 Like

FYI, the ZHA docs now have some basic information explain binding and unbinding:

https://www.home-assistant.io/integrations/zha#binding-and-unbinding

For changing the existing docs and submitting a new PR with improvements see:

https://github.com/home-assistant/home-assistant.io/blob/135275ac92bd5ccb97c05034495c77969a828818/source/_integrations/zha.markdown

Great if you guys could help improve the ZHA docs by submitting PRs like this:

https://github.com/home-assistant/home-assistant.io/pull/16336