Skip to content

Commit 07308d7

Browse files
Fix/cleaup of startUpColorTempCommand
1 parent 45c361e commit 07308d7

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

src/app/clusters/color-control-server/color-control-server.cpp

+19-26
Original file line numberDiff line numberDiff line change
@@ -2671,37 +2671,30 @@ void ColorControlServer::startUpColorTempCommand(EndpointId endpoint)
26712671

26722672
if (status == Status::Success && !startUpColorTemp.IsNull())
26732673
{
2674-
uint16_t updatedColorTemp = MAX_TEMPERATURE_VALUE;
2675-
status = Attributes::ColorTemperatureMireds::Get(endpoint, &updatedColorTemp);
2674+
uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE;
2675+
Attributes::ColorTempPhysicalMinMireds::Get(endpoint, &tempPhysicalMin);
26762676

2677-
if (status == Status::Success)
2678-
{
2679-
uint16_t tempPhysicalMin = MIN_TEMPERATURE_VALUE;
2680-
Attributes::ColorTempPhysicalMinMireds::Get(endpoint, &tempPhysicalMin);
2677+
uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE;
2678+
Attributes::ColorTempPhysicalMaxMireds::Get(endpoint, &tempPhysicalMax);
26812679

2682-
uint16_t tempPhysicalMax = MAX_TEMPERATURE_VALUE;
2683-
Attributes::ColorTempPhysicalMaxMireds::Get(endpoint, &tempPhysicalMax);
2680+
if (tempPhysicalMin <= startUpColorTemp.Value() && startUpColorTemp.Value() <= tempPhysicalMax)
2681+
{
2682+
// Apply valid startup color temp value that is within physical limits of device.
2683+
// Otherwise, the startup value is outside the device's supported range, and the
2684+
// existing setting of ColorTemp attribute will be left unchanged (i.e., treated as
2685+
// if startup color temp was set to null).
2686+
uint16_t epIndex = getEndpointIndex(endpoint);
2687+
MarkAttributeDirty markDirty = SetQuietReportAttribute(quietTemperatureMireds[epIndex], startUpColorTemp.Value(),
2688+
false /* isEndOfTransition */, 0);
2689+
status = Attributes::ColorTemperatureMireds::Set(endpoint, quietTemperatureMireds[epIndex].value().Value(), markDirty);
26842690

2685-
if (tempPhysicalMin <= startUpColorTemp.Value() && startUpColorTemp.Value() <= tempPhysicalMax)
2691+
if (status == Status::Success)
26862692
{
2687-
// Apply valid startup color temp value that is within physical limits of device.
2688-
// Otherwise, the startup value is outside the device's supported range, and the
2689-
// existing setting of ColorTemp attribute will be left unchanged (i.e., treated as
2690-
// if startup color temp was set to null).
2691-
uint16_t epIndex = getEndpointIndex(endpoint);
2692-
MarkAttributeDirty markDirty =
2693-
SetQuietReportAttribute(quietTemperatureMireds[epIndex], updatedColorTemp, false /* isEndOfTransition */, 0);
2694-
status =
2695-
Attributes::ColorTemperatureMireds::Set(endpoint, quietTemperatureMireds[epIndex].value().Value(), markDirty);
2693+
// Set ColorMode attributes to reflect ColorTemperature.
2694+
auto updateColorMode = ColorModeEnum::kColorTemperatureMireds;
2695+
Attributes::ColorMode::Set(endpoint, updateColorMode);
26962696

2697-
if (status == Status::Success)
2698-
{
2699-
// Set ColorMode attributes to reflect ColorTemperature.
2700-
auto updateColorMode = ColorModeEnum::kColorTemperatureMireds;
2701-
Attributes::ColorMode::Set(endpoint, updateColorMode);
2702-
2703-
Attributes::EnhancedColorMode::Set(endpoint, static_cast<EnhancedColorModeEnum>(updateColorMode));
2704-
}
2697+
Attributes::EnhancedColorMode::Set(endpoint, static_cast<EnhancedColorModeEnum>(updateColorMode));
27052698
}
27062699
}
27072700
}

0 commit comments

Comments
 (0)