NRF connect: 2.6.1 zigbee - Binding OnOff cluster via Home assistant - how to send 'on' command?

Setup:

  • windows 11
  • VS studio code
  • Toolchain and SDK v2.6.1
  • hardware: nRF52840DK  / PCA10056 (bought June 2024)
  • Using sdk/zigbee-Template as the base for the project.

Goal:

  • Mains powered Zigbee controller with multiple switches to turn on/off multiple devices in a room.
  • Using Home Assistant to bind a device/group to a switch on the controller.

What works:

  • adding an OnOff cluster. 
  • the device and cluster are recognized by Home Assistant
  • I can bind the device to a lightbulb via Home Assistant.
  • Every switch will have it's own endpoint switch one is endpoint 11.



The problem:

In the Switch example I found the following code to send an On or Off command. This example binds the switch directly to a lamp. In my situation the switch and the light are binded first to the coördinator. Then (using home assistant / zigbee2mqtt) the switch binds with the light.

Using Shell commands I can see that the switch knows which bindings exist. How can I modify the code below so that I can control the light?



/**@brief Function for sending ON/OFF requests to the light bulb.
 *
 * @param[in]   bufid    Non-zero reference to Zigbee stack buffer that will be
 *                       used to construct on/off request.
 * @param[in]   cmd_id   ZCL command id.
 */
static void light_switch_send_on_off(zb_bufid_t bufid, zb_uint16_t cmd_id)
{
	LOG_INF("Send ON/OFF command: %d", cmd_id);

	ZB_ZCL_ON_OFF_SEND_REQ(bufid,
			       bulb_ctx.short_addr, 
			       ZB_APS_ADDR_MODE_16_ENDP_PRESENT,
			       bulb_ctx.endpoint,
			       LIGHT_SWITCH_ENDPOINT,
			       ZB_AF_HA_PROFILE_ID,
			       ZB_ZCL_DISABLE_DEFAULT_RESPONSE,
			       cmd_id,
			       NULL);
}

Related