44ZigbeeColorDimmableLight::ZigbeeColorDimmableLight (uint8_t endpoint) : ZigbeeEP(endpoint) {
55 _device_id = ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID;
66
7- esp_zb_color_dimmable_light_cfg_t light_cfg = ESP_ZB_DEFAULT_COLOR_DIMMABLE_LIGHT_CONFIG ();
7+ esp_zb_color_dimmable_light_cfg_t light_cfg = ZIGBEE_DEFAULT_COLOR_DIMMABLE_LIGHT_CONFIG ();
88 _cluster_list = esp_zb_color_dimmable_light_clusters_create (&light_cfg);
9+
10+ // Add support for hue and saturation
11+ uint8_t hue = 0 ;
12+ uint8_t saturation = 0 ;
13+
14+ esp_zb_attribute_list_t *color_cluster = esp_zb_cluster_list_get_cluster (_cluster_list, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE);
15+ esp_zb_color_control_cluster_add_attr (color_cluster, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID, &hue);
16+ esp_zb_color_control_cluster_add_attr (color_cluster, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_SATURATION_ID, &saturation);
17+
918 _ep_config = {
1019 .endpoint = _endpoint, .app_profile_id = ESP_ZB_AF_HA_PROFILE_ID, .app_device_id = ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID, .app_device_version = 0
1120 };
@@ -30,8 +39,8 @@ uint16_t ZigbeeColorDimmableLight::getCurrentColorY() {
3039 ->data_p );
3140}
3241
33- uint16_t ZigbeeColorDimmableLight::getCurrentColorHue () {
34- return (*(uint16_t *)esp_zb_zcl_get_attribute (
42+ uint8_t ZigbeeColorDimmableLight::getCurrentColorHue () {
43+ return (*(uint8_t *)esp_zb_zcl_get_attribute (
3544 _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID
3645 )
3746 ->data_p );
@@ -84,8 +93,8 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me
8493 _current_color = espXYToRgbColor (255 , light_color_x, light_color_y); // TODO: Check if level is correct
8594 lightChanged ();
8695 return ;
87- } else if (message->attribute .id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID && message->attribute .data .type == ESP_ZB_ZCL_ATTR_TYPE_U16 ) {
88- uint16_t light_color_hue = (*(uint16_t *)message->attribute .data .value );
96+ } else if (message->attribute .id == ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID && message->attribute .data .type == ESP_ZB_ZCL_ATTR_TYPE_U8 ) {
97+ uint8_t light_color_hue = (*(uint8_t *)message->attribute .data .value );
8998 _current_color = espHsvToRgbColor (light_color_hue, getCurrentColorSaturation (), 255 );
9099 lightChanged ();
91100 return ;
@@ -137,8 +146,9 @@ void ZigbeeColorDimmableLight::setLight(bool state, uint8_t level, uint8_t red,
137146 _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_Y_ID, &xy_color.y , false
138147 );
139148 // set hsv color
149+ uint8_t hue = (uint8_t )hsv_color.h ;
140150 esp_zb_zcl_set_attribute_val (
141- _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID, &hsv_color. h , false
151+ _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID, &hue , false
142152 );
143153 esp_zb_zcl_set_attribute_val (
144154 _endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_SATURATION_ID, &hsv_color.s , false
0 commit comments