@@ -237,76 +237,60 @@ class DefaultColorControlSceneHandler : public scenes::DefaultSceneHandlerImpl
237
237
case Attributes::CurrentX::Id:
238
238
if (SupportsColorMode (endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY ))
239
239
{
240
- if (decodePair.valueUnsigned16 .HasValue ())
241
- colorXTransitionState->finalValue =
242
- std::min (decodePair.valueUnsigned16 .Value (), colorXTransitionState->highLimit );
240
+ VerifyOrReturnError (decodePair.valueUnsigned16 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
241
+ colorXTransitionState->finalValue =
242
+ std::min (decodePair.valueUnsigned16 .Value (), colorXTransitionState->highLimit );
243
243
}
244
244
break ;
245
245
case Attributes::CurrentY::Id:
246
246
if (SupportsColorMode (endpoint, ColorControl::EnhancedColorMode::kCurrentXAndCurrentY ))
247
247
{
248
- if (decodePair.valueUnsigned16 .HasValue ())
249
- {
250
- colorYTransitionState->finalValue =
251
- std::min (decodePair.valueUnsigned16 .Value (), colorYTransitionState->highLimit );
252
- }
248
+ VerifyOrReturnError (decodePair.valueUnsigned16 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
249
+ colorYTransitionState->finalValue =
250
+ std::min (decodePair.valueUnsigned16 .Value (), colorYTransitionState->highLimit );
253
251
}
254
252
break ;
255
253
case Attributes::EnhancedCurrentHue::Id:
256
254
if (SupportsColorMode (endpoint, ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation ))
257
255
{
258
- if (decodePair.valueUnsigned16 .HasValue ())
259
- {
260
- colorHueTransitionState->finalEnhancedHue = decodePair.valueUnsigned16 .Value ();
261
- }
256
+ VerifyOrReturnError (decodePair.valueUnsigned16 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
257
+ colorHueTransitionState->finalEnhancedHue = decodePair.valueUnsigned16 .Value ();
262
258
}
263
259
break ;
264
260
case Attributes::CurrentSaturation::Id:
265
261
if (SupportsColorMode (endpoint, ColorControl::EnhancedColorMode::kCurrentHueAndCurrentSaturation ))
266
262
{
267
- if (decodePair.valueUnsigned8 .HasValue ())
268
- {
269
- colorSaturationTransitionState->finalValue = std::min (
270
- static_cast <uint16_t >(decodePair.valueUnsigned8 .Value ()), colorSaturationTransitionState->highLimit );
271
- }
263
+ VerifyOrReturnError (decodePair.valueUnsigned8 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
264
+ colorSaturationTransitionState->finalValue = std::min (static_cast <uint16_t >(decodePair.valueUnsigned8 .Value ()),
265
+ colorSaturationTransitionState->highLimit );
272
266
}
273
267
break ;
274
268
case Attributes::ColorLoopActive::Id:
275
- if (decodePair.valueUnsigned8 .HasValue ())
276
- {
277
- loopActiveValue = decodePair.valueUnsigned8 .Value ();
278
- }
269
+ VerifyOrReturnError (decodePair.valueUnsigned8 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
270
+ loopActiveValue = decodePair.valueUnsigned8 .Value ();
279
271
break ;
280
272
case Attributes::ColorLoopDirection::Id:
281
- if (decodePair.valueUnsigned8 .HasValue ())
282
- {
283
- loopDirectionValue = decodePair.valueUnsigned8 .Value ();
284
- }
273
+ VerifyOrReturnError (decodePair.valueUnsigned8 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
274
+ loopDirectionValue = decodePair.valueUnsigned8 .Value ();
285
275
break ;
286
276
case Attributes::ColorLoopTime::Id:
287
- if (decodePair.valueUnsigned16 .HasValue ())
288
- {
289
- loopTimeValue = decodePair.valueUnsigned16 .Value ();
290
- }
277
+ VerifyOrReturnError (decodePair.valueUnsigned16 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
278
+ loopTimeValue = decodePair.valueUnsigned16 .Value ();
291
279
break ;
292
280
case Attributes::ColorTemperatureMireds::Id:
293
281
if (SupportsColorMode (endpoint, ColorControl::EnhancedColorMode::kColorTemperature ))
294
282
{
295
- if (decodePair.valueUnsigned16 .HasValue ())
296
- {
297
- colorTempTransitionState->finalValue =
298
- std::min (decodePair.valueUnsigned16 .Value (), colorTempTransitionState->highLimit );
299
- }
283
+ VerifyOrReturnError (decodePair.valueUnsigned16 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
284
+ colorTempTransitionState->finalValue =
285
+ std::min (decodePair.valueUnsigned16 .Value (), colorTempTransitionState->highLimit );
300
286
}
301
287
break ;
302
288
case Attributes::EnhancedColorMode::Id:
303
- if (decodePair.valueUnsigned8 .HasValue ())
289
+ VerifyOrReturnError (decodePair.valueUnsigned8 .HasValue (), CHIP_ERROR_INVALID_ARGUMENT);
290
+ if (decodePair.valueUnsigned8 .Value () <=
291
+ static_cast <uint8_t >(ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation ))
304
292
{
305
- if (decodePair.valueUnsigned8 .Value () <=
306
- static_cast <uint8_t >(ColorControl::EnhancedColorMode::kEnhancedCurrentHueAndCurrentSaturation ))
307
- {
308
- targetColorMode = decodePair.valueUnsigned8 .Value ();
309
- }
293
+ targetColorMode = decodePair.valueUnsigned8 .Value ();
310
294
}
311
295
break ;
312
296
default :
0 commit comments