@@ -2679,39 +2679,32 @@ void ColorControlServer::startUpColorTempCommand(EndpointId endpoint)
2679
2679
2680
2680
if (status == Status::Success && !startUpColorTemp.IsNull ())
2681
2681
{
2682
- uint16_t updatedColorTemp = MAX_TEMPERATURE_VALUE;
2683
- status = Attributes::ColorTemperatureMireds::Get (endpoint, &updatedColorTemp);
2682
+ uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE;
2683
+ Attributes::ColorTempPhysicalMinMireds::Get (endpoint, &tempPhysicalMin);
2684
+ // Avoid potential divide-by-zero in future Kelvin conversions.
2685
+ tempPhysicalMin = std::max (static_cast <uint16_t >(1u ), tempPhysicalMin);
2684
2686
2685
- if (status == Status::Success)
2686
- {
2687
- uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE;
2688
- Attributes::ColorTempPhysicalMinMireds::Get (endpoint, &tempPhysicalMin);
2689
- // Avoid potential divide-by-zero in future Kelvin conversions.
2690
- tempPhysicalMin = std::max (static_cast <uint16_t >(1u ), tempPhysicalMin);
2687
+ uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE;
2688
+ Attributes::ColorTempPhysicalMaxMireds::Get (endpoint, &tempPhysicalMax);
2691
2689
2692
- uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE;
2693
- Attributes::ColorTempPhysicalMaxMireds::Get (endpoint, &tempPhysicalMax);
2690
+ if (tempPhysicalMin <= startUpColorTemp.Value () && startUpColorTemp.Value () <= tempPhysicalMax)
2691
+ {
2692
+ // Apply valid startup color temp value that is within physical limits of device.
2693
+ // Otherwise, the startup value is outside the device's supported range, and the
2694
+ // existing setting of ColorTemp attribute will be left unchanged (i.e., treated as
2695
+ // if startup color temp was set to null).
2696
+ uint16_t epIndex = getEndpointIndex (endpoint);
2697
+ MarkAttributeDirty markDirty = SetQuietReportAttribute (quietTemperatureMireds[epIndex], startUpColorTemp.Value (),
2698
+ false /* isEndOfTransition */ , 0 );
2699
+ status = Attributes::ColorTemperatureMireds::Set (endpoint, quietTemperatureMireds[epIndex].value ().Value (), markDirty);
2694
2700
2695
- if (tempPhysicalMin <= startUpColorTemp. Value () && startUpColorTemp. Value () <= tempPhysicalMax )
2701
+ if (status == Status::Success )
2696
2702
{
2697
- // Apply valid startup color temp value that is within physical limits of device.
2698
- // Otherwise, the startup value is outside the device's supported range, and the
2699
- // existing setting of ColorTemp attribute will be left unchanged (i.e., treated as
2700
- // if startup color temp was set to null).
2701
- uint16_t epIndex = getEndpointIndex (endpoint);
2702
- MarkAttributeDirty markDirty =
2703
- SetQuietReportAttribute (quietTemperatureMireds[epIndex], updatedColorTemp, false /* isEndOfTransition */ , 0 );
2704
- status =
2705
- Attributes::ColorTemperatureMireds::Set (endpoint, quietTemperatureMireds[epIndex].value ().Value (), markDirty);
2706
-
2707
- if (status == Status::Success)
2708
- {
2709
- // Set ColorMode attributes to reflect ColorTemperature.
2710
- auto updateColorMode = ColorModeEnum::kColorTemperatureMireds ;
2711
- Attributes::ColorMode::Set (endpoint, updateColorMode);
2703
+ // Set ColorMode attributes to reflect ColorTemperature.
2704
+ auto updateColorMode = ColorModeEnum::kColorTemperatureMireds ;
2705
+ Attributes::ColorMode::Set (endpoint, updateColorMode);
2712
2706
2713
- Attributes::EnhancedColorMode::Set (endpoint, static_cast <EnhancedColorModeEnum>(updateColorMode));
2714
- }
2707
+ Attributes::EnhancedColorMode::Set (endpoint, static_cast <EnhancedColorModeEnum>(updateColorMode));
2715
2708
}
2716
2709
}
2717
2710
}
0 commit comments