Skip to content

ESP32 C6 Zigbee custom switch (state reporting setting) question #11818

@luxert

Description

@luxert

Board

ESP32 C6

Device Description

ESP32 C6 devkit

Hardware Configuration

None

Version

v3.1.1

Type

Question

IDE Name

Arduino IDE 2.x

Operating System

Windows11

Flash frequency

80Mhz

PSRAM enabled

no

Upload speed

921600

Description

I am testing an ESP32-C6 Zigbee switch.
I paired it with a commercial wall switch, and the wall switch works fine when I send on/off commands from the C6.
However, I would like to receive the status on the C6 when the user physically toggles the wall switch.
Therefore, I modified the switch creation as follows.

STZigbeeSwitch::STZigbeeSwitch(uint8_t endpoint) : ZigbeeEP(endpoint)
{
    _device_id = ESP_ZB_HA_ON_OFF_SWITCH_DEVICE_ID;
    _instance = this;

    _cluster_list = esp_zb_zcl_cluster_list_create();

    // basic Cluster
    esp_zb_on_off_switch_cfg_t switch_cfg = ESP_ZB_DEFAULT_ON_OFF_SWITCH_CONFIG();

    // Basic Cluster (Server Role)
    esp_zb_attribute_list_t *basic_cluster = esp_zb_basic_cluster_create(&switch_cfg.basic_cfg);
    esp_zb_cluster_list_add_basic_cluster(_cluster_list, basic_cluster, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

    // Identify Cluster (Server Role)
    esp_zb_attribute_list_t *identify_server = esp_zb_identify_cluster_create(&switch_cfg.identify_cfg);
    esp_zb_cluster_list_add_identify_cluster(_cluster_list, identify_server, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

    // Identify Cluster (Client Role)
    esp_zb_attribute_list_t *identify_client = esp_zb_zcl_attr_list_create(ESP_ZB_ZCL_CLUSTER_ID_IDENTIFY);
    esp_zb_cluster_list_add_identify_cluster(_cluster_list, identify_client, ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE);

    // On/Off Cluster (Client Role) - Send CMD
    esp_zb_attribute_list_t *on_off_client = esp_zb_on_off_cluster_create(nullptr);
    esp_zb_cluster_list_add_on_off_cluster(_cluster_list, on_off_client, ESP_ZB_ZCL_CLUSTER_CLIENT_ROLE);

    // On/Off Cluster (Server Role) - Recv report
    esp_zb_attribute_list_t *on_off_server = esp_zb_on_off_cluster_create(nullptr);
    esp_zb_cluster_list_add_on_off_cluster(_cluster_list, on_off_server, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);

    // Endpoint Setting
    _ep_config = {
        .endpoint = _endpoint,
        .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID,
        .app_device_id = ESP_ZB_HA_ON_OFF_SWITCH_DEVICE_ID,
        .app_device_version = 0};
}

And I executed the following code to configure the reporting settings.

esp_zb_zcl_config_report_cmd_t report_cmd = {0};
        uint8_t report_change = 1;

        report_cmd.zcl_basic_cmd.dst_endpoint = endPoint; // Wall switch endpoint(1)
        report_cmd.zcl_basic_cmd.src_endpoint = 5; // My C6 Switch endpoint
        report_cmd.address_mode = ESP_ZB_APS_ADDR_MODE_64_ENDP_PRESENT;
        report_cmd.clusterID = ESP_ZB_ZCL_CLUSTER_ID_ON_OFF;
        memcpy(report_cmd.zcl_basic_cmd.dst_addr_u.addr_long, ieee_addr, sizeof(esp_zb_ieee_addr_t));

        esp_zb_zcl_config_report_record_t records[] = {
            {.direction = ESP_ZB_ZCL_REPORT_DIRECTION_SEND,
             .attributeID = ESP_ZB_ZCL_ATTR_ON_OFF_ON_OFF_ID,
             .attrType = ESP_ZB_ZCL_ATTR_TYPE_BOOL,
             .min_interval = 5,
             .max_interval = 30,
             .reportable_change = (void *)&report_change},
        };
        report_cmd.record_number = sizeof(records) / sizeof(esp_zb_zcl_config_report_record_t);

        report_cmd.record_field = records;

        esp_zb_lock_acquire(portMAX_DELAY);
        esp_zb_zcl_config_report_cmd_req(&report_cmd);
        esp_zb_lock_release();

However, the following error is reported.

zb_configure_report_resp_handler(): CONFIGURE REPORT RESP response: status(135), cluster(0x6), direction(0x0), attribute(0x0)

I referred to the thermostat example, which has both server and client roles.
I’m not sure what I did wrong.
Does anyone happen to know?

Sketch

Included in the main text

Debug Message

zb_configure_report_resp_handler(): CONFIGURE REPORT RESP response: status(135), cluster(0x6), direction(0x0), attribute(0x0)

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Metadata

Metadata

Assignees

Labels

Area: ZigbeeIssues and Feature Request about ZigbeeType: QuestionOnly question

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions