From 3db954642726b8ac1d3e5f1c8eb30282d92a78dd Mon Sep 17 00:00:00 2001 From: Andy Salisbury Date: Wed, 31 May 2023 11:28:09 -0400 Subject: [PATCH] Ensure the RemainingTime attribute is set correctly. When the transition time is 0, the remaining time should also be 0. --- .../color-control-server.cpp | 45 ++++++++++++++++--- 1 file changed, 40 insertions(+), 5 deletions(-) diff --git a/src/app/clusters/color-control-server/color-control-server.cpp b/src/app/clusters/color-control-server/color-control-server.cpp index 666e084bd4ffa9..0d88c7f043e682 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -1059,7 +1059,14 @@ bool ColorControlServer::moveToHueCommand(app::CommandHandler * commandObj, cons colorHueTransitionState->up = (direction == HueDirection::kUp); colorHueTransitionState->repeat = false; - SetHSVRemainingTime(endpoint); + if (transitionTime > 0) + { + SetHSVRemainingTime(endpoint); + } + else + { + Attributes::RemainingTime::Set(endpoint, 0); + } // kick off the state machine: scheduleTimerCallbackMs(configureHSVEventControl(endpoint), firstStepDelayMs); @@ -1168,7 +1175,14 @@ bool ColorControlServer::moveToHueAndSaturationCommand(app::CommandHandler * com colorSaturationTransitionState->lowLimit = MIN_SATURATION_VALUE; colorSaturationTransitionState->highLimit = MAX_SATURATION_VALUE; - SetHSVRemainingTime(endpoint); + if (transitionTime > 0) + { + SetHSVRemainingTime(endpoint); + } + else + { + Attributes::RemainingTime::Set(endpoint, 0); + } // kick off the state machine: scheduleTimerCallbackMs(configureHSVEventControl(endpoint), firstStepDelayMs); @@ -1266,7 +1280,14 @@ bool ColorControlServer::stepHueCommand(app::CommandHandler * commandObj, const colorHueTransitionState->endpoint = endpoint; colorHueTransitionState->repeat = false; - SetHSVRemainingTime(endpoint); + if (transitionTime > 0) + { + SetHSVRemainingTime(endpoint); + } + else + { + Attributes::RemainingTime::Set(endpoint, 0); + } // kick off the state machine: scheduleTimerCallbackMs(configureHSVEventControl(endpoint), firstStepDelayMs); @@ -1403,7 +1424,14 @@ bool ColorControlServer::moveToSaturationCommand(app::CommandHandler * commandOb colorSaturationTransitionState->lowLimit = MIN_SATURATION_VALUE; colorSaturationTransitionState->highLimit = MAX_SATURATION_VALUE; - SetHSVRemainingTime(endpoint); + if (transitionTime > 0) + { + SetHSVRemainingTime(endpoint); + } + else + { + Attributes::RemainingTime::Set(endpoint, 0); + } // kick off the state machine: scheduleTimerCallbackMs(configureHSVEventControl(endpoint), firstStepDelayMs); @@ -1467,7 +1495,14 @@ bool ColorControlServer::stepSaturationCommand(app::CommandHandler * commandObj, colorSaturationTransitionState->lowLimit = MIN_SATURATION_VALUE; colorSaturationTransitionState->highLimit = MAX_SATURATION_VALUE; - SetHSVRemainingTime(endpoint); + if (transitionTime > 0) + { + SetHSVRemainingTime(endpoint); + } + else + { + Attributes::RemainingTime::Set(endpoint, 0); + } // kick off the state machine: scheduleTimerCallbackMs(configureHSVEventControl(endpoint), firstStepDelayMs);