espressif / esp-zigbee-sdk

Espressif Zigbee SDK
Apache License 2.0
178 stars 31 forks source link

Multiple Endpoints (TZ-1070) #407

Closed Gazelle84 closed 1 month ago

Gazelle84 commented 3 months ago

Question

Hi, I’m trying to create multiple endpoints for an esp32-h2 and just cannot get more than one to register in zigbee2mqqt. I’m using the zigbee HA light example which works fine with the provided code. I have used the same code and some snippets to try and add a switch, which compiles but doesn’t register the switch.

if I comment out the light code, it builds and registers the switch, but with both there it only registers the light.

Do I need to create a list of endpoints and register the list? Or do I register them individually? I have tried numbering them from 1 and it behaves the same.

I want to connect around 5 devices to the gpio pins and control them individually. They will be a simple on/off switch. I can’t find any example where multiple endpoints are registered.

xieqinan commented 3 months ago

@Gazelle84 ,

The code below registers five endpoints to the device. You can use it as a reference for your project.

    esp_zb_on_off_switch_cfg_t switch_cfg = ESP_ZB_DEFAULT_ON_OFF_SWITCH_CONFIG();
    esp_zb_ep_list_t *ep_list = esp_zb_ep_list_create();
    for (int i = 0; i < 5; i++) {
        esp_zb_endpoint_config_t endpoint_config = {
            .endpoint = HA_ONOFF_SWITCH_ENDPOINT + i,
            .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID,
            .app_device_id = ESP_ZB_HA_ON_OFF_SWITCH_DEVICE_ID,
            .app_device_version = 0,
        };
        zcl_basic_manufacturer_info_t info = {
            .manufacturer_name = ESP_MANUFACTURER_NAME,
            .model_identifier = ESP_MODEL_IDENTIFIER,
        };
        esp_zb_ep_list_add_ep(ep_list, esp_zb_on_off_switch_clusters_create(&switch_cfg), endpoint_config);
        esp_zcl_utility_add_ep_basic_manufacturer_info(ep_list, HA_ONOFF_SWITCH_ENDPOINT + i, &info);
    }
    esp_zb_device_register(ep_list);
Gazelle84 commented 3 months ago

Superb, thanks, i will give it a try and report back.

xGreenPandax commented 2 months ago

Doesnt work for me. I only see the first endpoint in coordinator app

chshu commented 2 months ago

@Gazelle84 @xGreenPandax Any update on this issue?

xGreenPandax commented 2 months ago

@chshu nothing. Is it possible to provide complete example with multiple different endpoints?

Daniel-Craciun commented 2 months ago

Hello everyone, I've managed to get multiple endpoints working with my home made coordinator. What solved the issue for me, was that In my end device I removed the code which updates the attribute reporting info ie. I removed this line from my end device ESP_ERROR_CHECK(esp_zb_zcl_update_reporting_info(&reporting_info)); and everything started working like a charm. Hope this can help anyone :)

Gazelle84 commented 2 months ago

Ive attached the files i ended up with, which appear in mqqt and work as desired.

esp_zb_light.zip

xieqinan commented 1 month ago

@xGreenPandax ,

Good job. If the esp-zigbee-lib and esp-zboss-lib versions are higher than v1.4.0, the ZCL data model cannot be reused. You'll need to create and register the model for each endpoint, just like the example you provided here.

By the way, I think this issue has been addressed by yourself, could you please consider closing it?

Gazelle84 commented 1 month ago

Closing post as this appears to be working for others.