4
4
ZigbeeColorDimmableLight::ZigbeeColorDimmableLight (uint8_t endpoint) : ZigbeeEP(endpoint) {
5
5
_device_id = ESP_ZB_HA_COLOR_DIMMABLE_LIGHT_DEVICE_ID;
6
6
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 ();
8
8
_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
+
9
18
_ep_config = {
10
19
.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
11
20
};
@@ -30,8 +39,8 @@ uint16_t ZigbeeColorDimmableLight::getCurrentColorY() {
30
39
->data_p );
31
40
}
32
41
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 (
35
44
_endpoint, ESP_ZB_ZCL_CLUSTER_ID_COLOR_CONTROL, ESP_ZB_ZCL_CLUSTER_SERVER_ROLE, ESP_ZB_ZCL_ATTR_COLOR_CONTROL_CURRENT_HUE_ID
36
45
)
37
46
->data_p );
@@ -84,8 +93,8 @@ void ZigbeeColorDimmableLight::zbAttributeSet(const esp_zb_zcl_set_attr_value_me
84
93
_current_color = espXYToRgbColor (255 , light_color_x, light_color_y); // TODO: Check if level is correct
85
94
lightChanged ();
86
95
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 );
89
98
_current_color = espHsvToRgbColor (light_color_hue, getCurrentColorSaturation (), 255 );
90
99
lightChanged ();
91
100
return ;
@@ -137,8 +146,9 @@ void ZigbeeColorDimmableLight::setLight(bool state, uint8_t level, uint8_t red,
137
146
_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
138
147
);
139
148
// set hsv color
149
+ uint8_t hue = (uint8_t )hsv_color.h ;
140
150
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
142
152
);
143
153
esp_zb_zcl_set_attribute_val (
144
154
_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