Page 1 of 1

ESP32-C6 Zigbee2MQTT State

Posted: Sun Dec 10, 2023 2:14 pm
by knowatimsayn
I'm trying to understand the connection between code in IDF, and the state.json values shown in Zigbee2MQTT.

I have an ESP32-C6 that successfully connects to my zigbee coordinator, including a custom set manufacturer name, model number and related config file so that it shows up properly as a supported device in Z2M:
Z2M_Connected.png
Z2M_Connected.png (10.79 KiB) Viewed 7397 times

Curently the state only reports linkquality:
Z2M_State.png
Z2M_State.png (13.3 KiB) Viewed 7397 times

What I'd like to do is report other parameters to state.json (ie sensor readings from something connected to the ESP32), so that they can be used in HomeAssistant.


Here's my zb_task code:
  1. static void esp_zb_task(void *pvParameters)
  2. {
  3.     // Custom mfg/model
  4.     char manufname[] = {9, 'E', 's', 'p', 'r', 'e', 's', 's', 'i', 'f'};
  5.     char modelid[] = {14, 'E', 'S', 'P', '3', '2', 'C', '6', '.', 'S', 'e', 'n', 's', 'o', 'r'};
  6.  
  7.     /* Initialize Zigbee stack */
  8.     esp_zb_cfg_t zb_nwk_cfg = ESP_ZB_ZED_CONFIG();
  9.     esp_zb_init(&zb_nwk_cfg);
  10.  
  11.     /* Create basic cluster */
  12.     esp_zb_attribute_list_t *esp_zb_basic_cluster = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_BASIC);
  13.     esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MANUFACTURER_NAME_ID, &manufname[0]);
  14.     esp_zb_basic_cluster_add_attr(esp_zb_basic_cluster, ESP_ZB_ZCL_ATTR_BASIC_MODEL_IDENTIFIER_ID, &modelid[0]);
  15.  
  16.     /* Create cluster lists for this endpoint */
  17.     esp_zb_cluster_list_t *esp_zb_cluster_list = esp_zb_zcl_cluster_list_create();
  18.     esp_zb_cluster_list_add_basic_cluster(esp_zb_cluster_list, esp_zb_basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
  19.    
  20.     esp_zb_ep_list_t *esp_zb_ep_list = esp_zb_ep_list_create();
  21.    
  22.  
  23.     /* add created endpoint (cluster_list) to endpoint list */
  24.     esp_zb_ep_list_add_ep(esp_zb_ep_list, esp_zb_cluster_list, HA_ESP_SENSOR_ENDPOINT, ESP_ZB_AF_HA_PROFILE_ID, ESP_ZB_HA_ON_OFF_OUTPUT_DEVICE_ID);
  25.      
  26.     esp_zb_device_register(esp_zb_ep_list);
  27.  
  28.     esp_zb_core_action_handler_register(zb_action_handler);
  29.     ESP_ERROR_CHECK(esp_zb_start(false));
  30.     esp_zb_main_loop_iteration();
  31. }

Re: ESP32-C6 Zigbee2MQTT State

Posted: Sun Dec 31, 2023 10:41 am
by eitell
Have you tried creating a converter on z2m for you device? I think this is necessary even though the device appears as supported:

https://www.zigbee2mqtt.io/advanced/sup ... our-device

Re: ESP32-C6 Zigbee2MQTT State

Posted: Sun Dec 31, 2023 9:47 pm
by greg c
Looks like you only have basic_cluster's. Setup some for the data you want to send. Then set the reporting for those clusters in z2m. I had to set this to get data into z2m.

Re: ESP32-C6 Zigbee2MQTT State

Posted: Tue Feb 13, 2024 9:35 pm
by stephmartin16
Hi, I am currently working on a project to connect my ESP32C6 to Zigbee2mqtt on my pi and I was wondering how you got them to pair. Did you have to create your own project on esp-idf framework or did you find something given by Espressif? Sorry this is a little unconventional way to replay but it was the only way I could reach out to you.