From 204c6319f5bd1ae42c8372ed3f3e55adb564af55 Mon Sep 17 00:00:00 2001 From: Justin Wood Date: Tue, 30 Jan 2024 14:56:01 -0800 Subject: [PATCH] [nrf fromtree] When dimming a light/bulb over time or changing color the thread network can be spammed (#31778) * Adding diff * Restyled by clang-format --------- Cherry picked commit: 935aa450 Co-authored-by: Restyled.io --- .../color-control-server.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 39fc5f9cdc..ae16a0d9c8 100644 --- a/src/app/clusters/color-control-server/color-control-server.cpp +++ b/src/app/clusters/color-control-server/color-control-server.cpp @@ -2565,6 +2565,24 @@ void ColorControlServer::updateTempCommand(EndpointId endpoint) isColorTempTransitionDone = computeNewColor16uValue(colorTempTransitionState); + if (!isColorTempTransitionDone) + { + // Check whether our color temperature has actually changed. If not, do + // nothing, and wait for it to change. + uint16_t currentColorTemp; + if (Attributes::ColorTemperatureMireds::Get(endpoint, ¤tColorTemp) != EMBER_ZCL_STATUS_SUCCESS) + { + // Why can't we read our attribute? + return; + } + + if (currentColorTemp == colorTempTransitionState->currentValue) + { + scheduleTimerCallbackMs(configureTempEventControl(endpoint), TRANSITION_UPDATE_TIME_MS.count()); + return; + } + } + Attributes::RemainingTime::Set(endpoint, colorTempTransitionState->timeRemaining); if (isColorTempTransitionDone)