@@ -26,17 +26,17 @@ using namespace chip::app::Clusters;
26
26
bool MatterColorTemperatureLight::attributeChangeCB (uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val) {
27
27
bool ret = true ;
28
28
if (!started) {
29
- log_e (" Matter CW_WW Light device has not begun." );
29
+ log_e (" Matter Temperature Light device has not begun." );
30
30
return false ;
31
31
}
32
32
33
- log_d (" CW_WW Attr update callback: endpoint: %u, cluster: %u, attribute: %u, val: %u" , endpoint_id, cluster_id, attribute_id, val->val .u32 );
33
+ log_d (" Temperature Attr update callback: endpoint: %u, cluster: %u, attribute: %u, val: %u" , endpoint_id, cluster_id, attribute_id, val->val .u32 );
34
34
35
35
if (endpoint_id == getEndPointId ()) {
36
36
switch (cluster_id) {
37
37
case OnOff::Id:
38
38
if (attribute_id == OnOff::Attributes::OnOff::Id) {
39
- log_d (" CW_WW Light On/Off State changed to %d" , val->val .b );
39
+ log_d (" Temperature Light On/Off State changed to %d" , val->val .b );
40
40
if (_onChangeOnOffCB != NULL ) {
41
41
ret &= _onChangeOnOffCB (val->val .b );
42
42
}
@@ -50,7 +50,7 @@ bool MatterColorTemperatureLight::attributeChangeCB(uint16_t endpoint_id, uint32
50
50
break ;
51
51
case LevelControl::Id:
52
52
if (attribute_id == LevelControl::Attributes::CurrentLevel::Id) {
53
- log_d (" CW_WW Light Brightness changed to %d" , val->val .u8 );
53
+ log_d (" Temperature Light Brightness changed to %d" , val->val .u8 );
54
54
if (_onChangeBrightnessCB != NULL ) {
55
55
ret &= _onChangeBrightnessCB (val->val .u8 );
56
56
}
@@ -64,7 +64,7 @@ bool MatterColorTemperatureLight::attributeChangeCB(uint16_t endpoint_id, uint32
64
64
break ;
65
65
case ColorControl::Id:
66
66
if (attribute_id == ColorControl::Attributes::ColorTemperatureMireds::Id) {
67
- log_d (" CW_WW Light Temperature changed to %d" , val->val .u16 );
67
+ log_d (" Temperature Light Temperature changed to %d" , val->val .u16 );
68
68
if (_onChangeTemperatureCB != NULL ) {
69
69
ret &= _onChangeTemperatureCB (val->val .u16 );
70
70
}
@@ -89,8 +89,13 @@ MatterColorTemperatureLight::~MatterColorTemperatureLight() {
89
89
90
90
bool MatterColorTemperatureLight::begin (bool initialState, uint8_t brightness, uint16_t ColorTemperature) {
91
91
ArduinoMatter::_init ();
92
- color_temperature_light::config_t light_config;
93
92
93
+ if (getEndPointId () != 0 ) {
94
+ log_e (" Matter Temperature Light with Endpoint Id %d device has already been created." , getEndPointId ());
95
+ return false ;
96
+ }
97
+
98
+ color_temperature_light::config_t light_config;
94
99
light_config.on_off .on_off = initialState;
95
100
light_config.on_off .lighting .start_up_on_off = nullptr ;
96
101
onOffState = initialState;
@@ -108,12 +113,12 @@ bool MatterColorTemperatureLight::begin(bool initialState, uint8_t brightness, u
108
113
// endpoint handles can be used to add/modify clusters.
109
114
endpoint_t *endpoint = color_temperature_light::create (node::get (), &light_config, ENDPOINT_FLAG_NONE, (void *)this );
110
115
if (endpoint == nullptr ) {
111
- log_e (" Failed to create CW_WW light endpoint" );
116
+ log_e (" Failed to create Temperature Light endpoint" );
112
117
return false ;
113
118
}
114
119
115
120
setEndPointId (endpoint::get_id (endpoint));
116
- log_i (" CW_WW Light created with endpoint_id %d" , getEndPointId ());
121
+ log_i (" Temperature Light created with endpoint_id %d" , getEndPointId ());
117
122
118
123
/* Mark deferred persistence for some attributes that might be changed rapidly */
119
124
cluster_t *level_control_cluster = cluster::get (endpoint, LevelControl::Id);
@@ -134,7 +139,7 @@ void MatterColorTemperatureLight::end() {
134
139
135
140
bool MatterColorTemperatureLight::setOnOff (bool newState) {
136
141
if (!started) {
137
- log_e (" Matter CW_WW Light device has not begun." );
142
+ log_e (" Matter Temperature Light device has not begun." );
138
143
return false ;
139
144
}
140
145
@@ -175,7 +180,7 @@ bool MatterColorTemperatureLight::toggle() {
175
180
176
181
bool MatterColorTemperatureLight::setBrightness (uint8_t newBrightness) {
177
182
if (!started) {
178
- log_w (" Matter CW_WW Light device has not begun." );
183
+ log_w (" Matter Temperature Light device has not begun." );
179
184
return false ;
180
185
}
181
186
@@ -206,7 +211,7 @@ uint8_t MatterColorTemperatureLight::getBrightness() {
206
211
207
212
bool MatterColorTemperatureLight::setColorTemperature (uint16_t newTemperature) {
208
213
if (!started) {
209
- log_w (" Matter CW_WW Light device has not begun." );
214
+ log_w (" Matter Temperature Light device has not begun." );
210
215
return false ;
211
216
}
212
217
0 commit comments