TL;DR: Here’s a script to establish bindings between two Matter devices in Home Assistant.
Background:
Matter supports binding two devices directly to each other. Home Assistant plans to add support for it, but as of this writing it’s not yet available. A few months ago I hacked together a way to bind a couple devices. It works. But is super clunky. I needed to bind a few more devices, so I leveraged @lboue 's notes on how to format websocket messages to get the job done and put it into a script.
Making a fresh thread to share it here for visibility. Hopefully this lowers the barrier to using bindings while we wait for a more polished option. Feel free to spin the code into something else (eg: wrap it up into something in HACS and save us the need to expose the WS port, etc).
HOW-TO
Without further ado, here’s a lightly edited copy of the README:
Expose the WebSocket port of the Matter Add-On
Navigate to Add-Ons → Matter Server → Config → Network
Enter 5580
Close it back up when you’re done. You don’t really want to leave it open on your network.
Run the binding script:
pip3 install websocket-client
if you don’t have it already
Download this script: misc-home-assistant/matter-binding.py at b7a45b9a13a2997cbf04bbe88ff4e12741f0fe19 · mactalla/misc-home-assistant · GitHub
For each pair of devices to bind:
- Find each Node ID from Settings → Devices → (device you want) → Device Info → Node ID
- Run ./matter-binding.py --from (source node) --to (dest node)
- For endpoints other than 1, specify it with
:#
. eg: Inovelli switches have the Dimmer Switch that we can bind on Endpoint 2./matter-binding.py --from 17:2 --to 21
- For endpoints other than 1, specify it with
Limitations
While this script Works For Me and does attempt to be smart about updates (no changes if none are needed, re-use a suitable entry in the ACL or binding tables). It still has notable limitations:
- It has been tested only superficially.
- It does not support un-binding.
- It binds “everything” (ie: any matching command that the source can issue and the receiver will acknowledge will be bound).
- There is no support for binding only a subset.
- Use at your own risk, yadda yadda.
Future
Home Assistant has plans to add support for Binding in the future. Once that exists, this script should just be deleted and forgotten. It has no future