Skip to content

Commit

Permalink
Ensure the RemainingTime attribute is set correctly.
Browse files Browse the repository at this point in the history
When the transition time is 0, the remaining time should also be 0.
  • Loading branch information
harimau-qirex committed May 31, 2023
1 parent 9f3017e commit 3db9546
Showing 1 changed file with 40 additions and 5 deletions.
45 changes: 40 additions & 5 deletions src/app/clusters/color-control-server/color-control-server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 3db9546

Please sign in to comment.