Matter based Color Temperature Light with Rainmaker App

ngorgi
Posts: 2
Joined: Thu Feb 04, 2016 4:35 am

Matter based Color Temperature Light with Rainmaker App

Postby ngorgi » Tue Sep 24, 2024 4:26 pm

Hello,
I'm trying to adapt the Rainmaker matter_light example to be used for a color temperature light but I'm having some issues with how the firmware interacts with the Rainmaker app.

In its base form, if I commision the example using the ESP Rainmaker app I can see that the hue and saturation controls are exposed, and if I commission it using my iPhone and Apple Homepod, I can see the color picker.

To change the example to a color temperature light, I edit app_matter_light_create() in app_matter_light.cpp and change the creation of the extended_color_light to a color_temperature_light. I also remove the creation of the hue_saturation control clusters since I assume that creating the color_temperature_light takes care of that for me. This is what my app_matter_light_create() looks like:
  1. esp_err_t app_matter_light_create(app_driver_handle_t driver_handle)
  2. {
  3.     node_t *node = node::get();
  4.     if (!node) {
  5.         ESP_LOGE(TAG, "Matter node not found");
  6.         return ESP_FAIL;
  7.     }
  8.  
  9.     color_temperature_light::config_t light_config;
  10.     light_config.on_off.on_off = DEFAULT_POWER;
  11.     light_config.on_off.lighting.start_up_on_off = nullptr;
  12.     light_config.level_control.current_level = DEFAULT_BRIGHTNESS;
  13.     light_config.level_control.lighting.start_up_current_level = DEFAULT_BRIGHTNESS;
  14.     light_config.color_control.color_mode = static_cast<uint8_t>(ColorControl::ColorMode::kColorTemperature);
  15.     light_config.color_control.enhanced_color_mode =
  16.         static_cast<uint8_t>(ColorControlServer::EnhancedColorMode::kColorTemperature);
  17.     light_config.color_control.color_temperature.color_temperature_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_STARTUP, MATTER_TEMPERATURE_FACTOR);
  18.     light_config.color_control.color_temperature.color_temp_physical_min_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MAX, MATTER_TEMPERATURE_FACTOR);
  19.     light_config.color_control.color_temperature.color_temp_physical_max_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MIN, MATTER_TEMPERATURE_FACTOR);
  20.     light_config.color_control.color_temperature.couple_color_temp_to_level_min_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MAX, MATTER_TEMPERATURE_FACTOR);
  21.     light_config.color_control.color_temperature.startup_color_temperature_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_STARTUP, MATTER_TEMPERATURE_FACTOR);
  22.     endpoint_t *endpoint = color_temperature_light::create(node, &light_config, ENDPOINT_FLAG_NONE, driver_handle);
  23.  
  24.     /* These node and endpoint handles can be used to create/add other endpoints and clusters. */
  25.     if (!node || !endpoint) {
  26.         ESP_LOGE(TAG, "Matter node creation failed");
  27.     }
  28.  
  29.     light_endpoint_id = endpoint::get_id(endpoint);
  30.     ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id);
  31.  
  32.     return ESP_OK;
  33. }

When I commision this new firmware with my iPhone and Apply Homepod, it recognizes it as a color temperature light and only lets me pick CCT on the color picker (not RGB). However, when I add it to Rainmaker, it doesn't expose any color control - only power and brightness. I also tried adding the CCT control cluster as well, but I got the same result. This is what it looked like with the CCT control cluster added.
  1. esp_err_t app_matter_light_create(app_driver_handle_t driver_handle)
  2. {
  3.     node_t *node = node::get();
  4.     if (!node) {
  5.         ESP_LOGE(TAG, "Matter node not found");
  6.         return ESP_FAIL;
  7.     }
  8.  
  9.     color_temperature_light::config_t light_config;
  10.     light_config.on_off.on_off = DEFAULT_POWER;
  11.     light_config.on_off.lighting.start_up_on_off = nullptr;
  12.     light_config.level_control.current_level = DEFAULT_BRIGHTNESS;
  13.     light_config.level_control.lighting.start_up_current_level = DEFAULT_BRIGHTNESS;
  14.     light_config.color_control.color_mode = static_cast<uint8_t>(ColorControl::ColorMode::kColorTemperature);
  15.     light_config.color_control.enhanced_color_mode =
  16.         static_cast<uint8_t>(ColorControlServer::EnhancedColorMode::kColorTemperature);
  17.     light_config.color_control.color_temperature.color_temperature_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_STARTUP, MATTER_TEMPERATURE_FACTOR);
  18.     light_config.color_control.color_temperature.color_temp_physical_min_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MAX, MATTER_TEMPERATURE_FACTOR);
  19.     light_config.color_control.color_temperature.color_temp_physical_max_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MIN, MATTER_TEMPERATURE_FACTOR);
  20.     light_config.color_control.color_temperature.couple_color_temp_to_level_min_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MAX, MATTER_TEMPERATURE_FACTOR);
  21.     light_config.color_control.color_temperature.startup_color_temperature_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_STARTUP, MATTER_TEMPERATURE_FACTOR);
  22.     endpoint_t *endpoint = color_temperature_light::create(node, &light_config, ENDPOINT_FLAG_NONE, driver_handle);
  23.  
  24.     /* These node and endpoint handles can be used to create/add other endpoints and clusters. */
  25.     if (!node || !endpoint) {
  26.         ESP_LOGE(TAG, "Matter node creation failed");
  27.     }
  28.  
  29.     light_endpoint_id = endpoint::get_id(endpoint);
  30.     ESP_LOGI(TAG, "Light created with endpoint_id %d", light_endpoint_id);
  31.  
  32.     /* Add additional features to the node */
  33.     cluster_t *cluster = cluster::get(endpoint, ColorControl::Id);
  34.     cluster::color_control::feature::color_temperature::config_t temperature_config;
  35.     temperature_config.color_temp_physical_max_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MIN, MATTER_TEMPERATURE_FACTOR);
  36.     temperature_config.color_temp_physical_min_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MAX, MATTER_TEMPERATURE_FACTOR);
  37.     temperature_config.couple_color_temp_to_level_min_mireds = REMAP_TO_RANGE_INVERSE(COLOR_TEMP_MAX, MATTER_TEMPERATURE_FACTOR);
  38.     esp_err_t cluster_add_res = cluster::color_control::feature::color_temperature::add(cluster, &temperature_config);
  39.  
  40.  
  41.     return ESP_OK;
  42. }

Any idea if I'm doing something wrong or there's an issue with the Rainmaker app? I'm confused as to why the Apple software is recognizing it as a color temperature control device but Rainmaker won't.

Who is online

Users browsing this forum: No registered users and 16 guests