Receive zigbee attribute write data in callback
Posted: Tue Jul 18, 2023 5:46 am
Hello,
I'm developing a Zigbee device using esp32-h2 & esp-idf v5.1 . I compiled and tested the HA Sample Light with zigbee2mqtt as a coordinator.
In ON/OFF Cluster I need ESP_ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF attribute. so I created a on/off cluster in custom way.
Here is the code
After creating the endpoint & Register I register the call back esp_zb_device_add_set_attr_value_cb(attr_cb);
ON/OFF attributer Commands like ON, OFF, TOGGLE from Coordinator, I'm able to receive in "attr_cb" callback. But ESP_ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF commands I'm not able to receive.
Is anything need to do for that?
Thanks in advance
I'm developing a Zigbee device using esp32-h2 & esp-idf v5.1 . I compiled and tested the HA Sample Light with zigbee2mqtt as a coordinator.
In ON/OFF Cluster I need ESP_ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF attribute. so I created a on/off cluster in custom way.
Here is the code
Code: Select all
uint8_t on_off = 0,start_onoff =0;
esp_zb_attribute_list_t *esp_zb_onoff_cluster_cus = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_ON_OFF);
esp_zb_on_off_cluster_add_attr(esp_zb_onoff_cluster_cus, ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID, &on_off);
esp_zb_on_off_cluster_add_attr(esp_zb_onoff_cluster_cus, ESP_ZB_ZCL_ATTR_ON_OFF_START_UP_ON_OFF, &start_onoff);
Code: Select all
void attr_cb(uint8_t status, uint8_t endpoint, uint16_t cluster_id, uint16_t attr_id, void *new_value)
{
ESP_LOGI(TAG, "Data received on on/off Cluster attr_id %d EP %d\n",attr_id,endpoint);
if (cluster_id == ESP_ZB_ZCL_CLUSTER_ID_ON_OFF) {
uint8_t value = *(uint8_t *)new_value;
if (attr_id == ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID) {
/* implemented light on/off control */
ESP_LOGI(TAG, "on/off light set to %hd Endpoint %d", value,endpoint);
SET_RELAY1_LED_STATUS(value);
}
else{
ESP_LOGI(TAG, "Data received on on/off Cluster attr_id %d value %hd EP %d\n",attr_id,value,endpoint);
}
} else {
/* Implement some actions if needed when other cluster changed */
ESP_LOGI(TAG, "cluster:0x%x, attribute:0x%x changed ", cluster_id, attr_id);
}
}
Is anything need to do for that?
Thanks in advance