espressif / esp-matter

Espressif's SDK for Matter
Apache License 2.0
692 stars 156 forks source link

Multiple endpoint with thermostat and on off switch in Homekit not working (CON-1322) #1071

Open dzungpv opened 2 months ago

dzungpv commented 2 months ago

In Homekit I can create multiple node in master node, but I read from this #1304 can only add multiple endpoint to a single node. So I add 1 thermostat and 2 on off switch (to simulate dry and fan mode) like this:

    /* Create a Matter node and add the mandatory Root Node device type on endpoint 0 */
    node::config_t node_config;

    // node handle can be used to add/modify other endpoints.
    node_t *node = node::create(&node_config, app_matter_attribute_update_cb, app_matter_identification_cb);
    ABORT_APP_ON_FAILURE(node != nullptr, ESP_LOGE(TAG, "Failed to create Matter node"));
    // Add enpoint to the node
    thermostat::config_t thermostat_config;
    thermostat_config.thermostat.local_temperature = 1900;  // 19 degree
    thermostat_config.thermostat.system_mode = 0;           // OFF state
    endpoint_t *thermostat_endpoint = thermostat::create(node, &thermostat_config, ENDPOINT_FLAG_NONE, NULL);

    thermostat_endpoint_id = endpoint::get_id(thermostat_endpoint);
    ESP_LOGI(TAG_MATTER, "Thermostat endpoint_id = %" PRIu32, static_cast<uint32_t>(thermostat_endpoint_id));

    // Switch for dry mode
    on_off_switch::config_t dry_switch_config;
    endpoint_t *dry_endpoint = on_off_switch::create(node, &dry_switch_config, ENDPOINT_FLAG_NONE, NULL);
    ABORT_APP_ON_FAILURE(dry_endpoint != nullptr, ESP_LOGE(TAG, "Failed to create on off switch endpoint"));

    // Add group cluster to the dry switch endpoint
    cluster::groups::config_t groups_config_d;
    cluster::groups::create(dry_endpoint, &groups_config_d, CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT);

    dry_switch_endpoint_id = endpoint::get_id(dry_endpoint);
    ESP_LOGE(TAG, "Dry Switch created with endpoint_id %d", dry_switch_endpoint_id);

    // Switch for fan mode
    on_off_switch::config_t fan_switch_config;
    endpoint_t *fan_endpoint = on_off_switch::create(node, &fan_switch_config, ENDPOINT_FLAG_NONE, NULL);
    ABORT_APP_ON_FAILURE(dry_endpoint != nullptr, ESP_LOGE(TAG, "Failed to create on off switch endpoint"));

    // Add group cluster to the dry switch endpoint
    cluster::groups::config_t groups_config_f;
    cluster::groups::create(fan_endpoint, &groups_config_f, CLUSTER_FLAG_SERVER | CLUSTER_FLAG_CLIENT);

    fan_switch_endpoint_id = endpoint::get_id(fan_endpoint);
    ESP_LOGE(TAG, "Fan Switch created with endpoint_id %d", fan_switch_endpoint_id); 

But when I add it to homekit, only thermostat device appear, could not see on off switch enywhere

pimpalemahesh commented 1 month ago

We are working on it.