Skip to content

Hue: fix issue with small color temp increments#2771

Open
nickolas-deboom wants to merge 2 commits intomainfrom
fix/hue-small-color-temp-increments-leads-to-command-timeout
Open

Hue: fix issue with small color temp increments#2771
nickolas-deboom wants to merge 2 commits intomainfrom
fix/hue-small-color-temp-increments-leads-to-command-timeout

Conversation

@nickolas-deboom
Copy link
Copy Markdown
Contributor

@nickolas-deboom nickolas-deboom commented Feb 11, 2026

Type of Change

  • WWST Certification Request
    • If this is your first time contributing code:
      • I have reviewed the README.md file
      • I have reviewed the CODE_OF_CONDUCT.md file
      • I have signed the CLA
    • I plan on entering a WWST Certification Request or have entered a request through the WWST Certification console at developer.smartthings.com
  • Bug fix
  • New feature
  • Refactor

Checklist

  • I have performed a self-review of my code
  • I have commented my code in hard-to-understand areas
  • I have verified my changes by testing with a device or have communicated a plan for testing
  • I am adding new behavior, such as adding a sub-driver, and have added and run new unit tests to cover the new behavior

Description of Change

Incrementing or decrementing the color temp by a small amount can lead to the driver sending the Hue bridge the same value in mireds as the device is already set to, and the bridge not responding, which in turn leads to a spinning wheel in the app and eventually the value being reset to its previous value. This change emits the capability with the updated value without waiting for a response from the bridge if the new mireds value would be the same as the previous.

Summary of Completed Tests

@nickolas-deboom nickolas-deboom marked this pull request as draft February 11, 2026 22:03
@nickolas-deboom nickolas-deboom marked this pull request as ready for review February 11, 2026 22:03
@github-actions
Copy link
Copy Markdown

@nickolas-deboom nickolas-deboom marked this pull request as draft February 11, 2026 22:04
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 11, 2026

Test Results

   72 files    502 suites   0s ⏱️
2 764 tests 2 764 ✅ 0 💤 0 ❌
4 662 runs  4 662 ✅ 0 💤 0 ❌

Results for commit 4506632.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 11, 2026

Minimum allowed coverage is 90%

Generated by 🐒 cobertura-action against 4506632

@nickolas-deboom nickolas-deboom changed the title Hue: fix issue with color temp increment of 1 kelvin Hue: fix issue with small color temp increments Feb 11, 2026
if current_mirek == mirek then
log.debug(string.format("Color temp change from %dK to %dK results in same mirek value (%d), emitting event directly", current_color_temp, clamped_kelvin, mirek))
device:emit_event(capabilities.colorTemperature.colorTemperature(clamped_kelvin))
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should still send the command to the bridge and not return early here. It might be possible that the user changed the temp in the hue app and we never emitted an event for the change so we might actually be changing it here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good point!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 38e8c2f

for _, device in ipairs(group.devices) do
device:emit_event(capabilities.colorTemperature.colorTemperature(clamped_kelvin))
end
return
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar reasoning as above for not returning early here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 38e8c2f

end
end

if all_same_mirek and #group.devices > 0 then
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather then checking if they are all the same mirek, I wonder if we want to track all the devices that have the same mirek and then emit the event for all of those devices. I'm not sure how this interaction works with the grouped lighting but it seems like if only one device had the same mirek then the bridge might not send anything for that specific device.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good call. When I was testing it I had all my bulbs at the same color temp value and neglected to think of the case where they are at different values initially.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated in 38e8c2f

---@param bridge_device HueBridgeDevice
---@param group table
---@param args table
---@param aux table auxilary data needed for the command that the devices all had in common
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

at least I am a consistent bad speller 🥲

@nickolas-deboom nickolas-deboom marked this pull request as ready for review February 12, 2026 21:37
@pInksenberg
Copy link
Copy Markdown
Contributor

pInksenberg commented Mar 12, 2026

we conducted the test in our Philips Hue test environment (Philips Hue + color temperature light), but the issue still exist. Additionally, every time I changed the Kelvin value from the ST app, I printed the current_color_temp value. However, the edge driver log always displayed the same current_color_temp value, regardless of the Kelvin value I set. As a result, the subsequent if statement fails to work properly:

 if current_mirek == mirek then
      device:emit_event(capabilities.colorTemperature.colorTemperature(clamped_kelvin))
 end

related log:

2026-03-12T18:50:24.906160748+08:00 TRACE Philips Hue [st.driver] Received event with handler capability
2026-03-12T18:50:24.910234446+08:00 INFO Philips Hue [hue_driver_template] Batch not big enough to handle with group commands
2026-03-12T18:50:24.927907112+08:00 INFO Philips Hue [st.device] <Device: 554c6ce8-c6f9-4cce-99ae-de03d6564852 (Hue color lamp 1 1)> received command: {"args":{"temperature":2001},"capability":"colorTemperature","command":"setColorTemperature","component":"main","named_args":{"temperature":2001},"positional_args":[2001]}
2026-03-12T18:50:24.934380972+08:00 TRACE Philips Hue [st.dispatcher] Found CapabilityCommandDispatcher handler in hue
2026-03-12T18:50:24.940011666+08:00 TRACE Philips Hue [utils] ------------------------ Looking for bridge for Hue color lamp 1 1 with parent_device_id b43eb9c0-d4c2-41ac-9737-9b3ec5b7b934
2026-03-12T18:50:24.945216445+08:00 TRACE Philips Hue [utils] ------------------------- parent_device label is Hue Bridge, checking if bridge
2026-03-12T18:50:24.956043336+08:00 INFO Philips Hue [handlers.commands] current_color_temp ------------------ 3623

2026-03-12T18:50:30.529990610+08:00 TRACE Philips Hue [st.driver] Received event with handler capability
2026-03-12T18:50:30.533591268+08:00 INFO Philips Hue [hue_driver_template] Batch not big enough to handle with group commands
2026-03-12T18:50:30.554210801+08:00 INFO Philips Hue [st.device] <Device: 554c6ce8-c6f9-4cce-99ae-de03d6564852 (Hue color lamp 1 1)> received command: {"args":{"temperature":2002},"capability":"colorTemperature","command":"setColorTemperature","component":"main","named_args":{"temperature":2002},"positional_args":[2002]}
2026-03-12T18:50:30.560029787+08:00 TRACE Philips Hue [st.dispatcher] Found CapabilityCommandDispatcher handler in hue
2026-03-12T18:50:30.565344607+08:00 TRACE Philips Hue [utils] ------------------------ Looking for bridge for Hue color lamp 1 1 with parent_device_id b43eb9c0-d4c2-41ac-9737-9b3ec5b7b934
2026-03-12T18:50:30.571829758+08:00 TRACE Philips Hue [utils] ------------------------- parent_device label is Hue Bridge, checking if bridge
2026-03-12T18:50:30.583586938+08:00 INFO Philips Hue [handlers.commands] current_color_temp ------------------ 3623

2026-03-12T18:50:17.461218411+08:00 TRACE Philips Hue [st.driver] Received event with handler capability
2026-03-12T18:50:17.466557606+08:00 INFO Philips Hue [hue_driver_template] Batch not big enough to handle with group commands
2026-03-12T18:50:17.484188773+08:00 INFO Philips Hue [st.device] <Device: 554c6ce8-c6f9-4cce-99ae-de03d6564852 (Hue color lamp 1 1)> received command: {"args":{"temperature":2000},"capability":"colorTemperature","command":"setColorTemperature","component":"main","named_args":{"temperature":2000},"positional_args":[2000]}
2026-03-12T18:50:17.490927298+08:00 TRACE Philips Hue [st.dispatcher] Found CapabilityCommandDispatcher handler in hue
2026-03-12T18:50:17.499788986+08:00 TRACE Philips Hue [utils] ------------------------ Looking for bridge for Hue color lamp 1 1 with parent_device_id b43eb9c0-d4c2-41ac-9737-9b3ec5b7b934
2026-03-12T18:50:17.521524393+08:00 TRACE Philips Hue [utils] ------------------------- parent_device label is Hue Bridge, checking if bridge
2026-03-12T18:50:17.532304200+08:00 INFO Philips Hue [handlers.commands] current_color_temp ------------------ 3623

Incrementing or decrementing the color temp by 1 can lead to the driver
sending the Hue bridge the same value in mireds as the device is already
set to, and the bridge not responding, which in turn leads to a spinning
wheel in the app and eventually the value being reset to its previous
value. This change emits the capability with the updated value without
waiting for a response from the bridge.
@nickolas-deboom nickolas-deboom force-pushed the fix/hue-small-color-temp-increments-leads-to-command-timeout branch from 38e8c2f to 4506632 Compare April 16, 2026 19:25
@nickolas-deboom
Copy link
Copy Markdown
Contributor Author

Hi @pInksenberg , I retested this today, and found that the channel link in this PR has not been updated for a few months. I'm not really sure what's going on there, but I needed to manually package the driver and install it on my hub. Would you be able to retest after manually installing the driver? Here are some logs I gathered that show that this change is working as expected:

2026-04-16T19:36:08.545555423Z DEBUG Philips Hue  [utils.hue_bridge_utils] 	Received update event with type grouped_light
2026-04-16T19:36:08.548691589Z DEBUG Philips Hue  [utils.hue_bridge_utils] 	Looking for device record for 038ba623-a280-440e-a1d4-58c7cc9d7904
2026-04-16T19:36:08.551695506Z DEBUG Philips Hue  [utils.hue_bridge_utils] 	Received update event with type grouped_light
2026-04-16T19:36:08.554685714Z DEBUG Philips Hue  [utils.hue_bridge_utils] 	Looking for device record for 80b26065-7459-4926-9c47-37de4497d459
2026-04-16T19:36:17.319031090Z TRACE Philips Hue  [st.driver] 	Received event with handler capability
2026-04-16T19:36:17.320722049Z INFO Philips Hue  [hue_driver_template] 	Batch not big enough to handle with group commands
2026-04-16T19:36:17.327444257Z INFO Philips Hue  [st.device] 	<Device: 4ee7f7cc-8d0c-429e-8f06-0d168db6d229 (Left Lamp)> received command: {"args":{"temperature":2834},"capability":"colorTemperature","command":"setColorTemperature","component":"main","named_args":{"temperature":2834},"positional_args":[2834]}
2026-04-16T19:36:17.329029465Z TRACE Philips Hue  [st.dispatcher] 	Found CapabilityCommandDispatcher handler in hue
2026-04-16T19:36:17.331408257Z TRACE Philips Hue  [utils] 	------------------------ Looking for bridge for Left Lamp with parent_device_id 20606b2e-9670-4cd5-a88c-574d7a3af499
2026-04-16T19:36:17.334457799Z TRACE Philips Hue  [utils] 	------------------------- parent_device label is Hue Bridge, checking if bridge
2026-04-16T19:36:17.337723007Z DEBUG Philips Hue  [handlers.commands] 	Color temp change from 2833K to 2834K results in same mirek value (352), emitting event directly
2026-04-16T19:36:17.341251965Z INFO Philips Hue  [st.device] 	<Device: 4ee7f7cc-8d0c-429e-8f06-0d168db6d229 (Left Lamp)> emitting event: {"attribute_id":"colorTemperature","capability_id":"colorTemperature","component_id":"main","state":{"value":2834}}
2026-04-16T19:36:17.431674424Z DEBUG Philips Hue  [st.thread] 	Left Lamp device thread event handled
2026-04-16T19:36:17.510170007Z DEBUG Philips Hue  [utils.hue_bridge_utils] 	Received update event with type light
2026-04-16T19:36:17.515262674Z DEBUG Philips Hue  [utils.hue_bridge_utils] 	Looking for device record for a2950d3a-d97c-400b-b38a-2d3a85b3daca
2026-04-16T19:36:17.521852965Z DEBUG Philips Hue  [utils.hue_bridge_utils] 	updating={
  {
    color_temperature={
      mirek=352, 
      mirek_valid=true, 
    }, 
    id="a2950d3a-d97c-400b-b38a-2d3a85b3daca", 
    id_v1="/lights/3", 
    owner={
      rid="59be40d0-ed54-4e35-97d9-cd9023d86c22", 
      rtype="device", 
    }, 
    service_id=0, 
    type="light", 
  }, 
  device_type="light", 
}
2026-04-16T19:36:17.527480674Z DEBUG Philips Hue  [st.device] 	<Device: 4ee7f7cc-8d0c-429e-8f06-0d168db6d229 (Left Lamp)> updating color temp range={maximum=6500, minimum=2000}
2026-04-16T19:36:17.533038840Z INFO Philips Hue  [st.device] 	<Device: 4ee7f7cc-8d0c-429e-8f06-0d168db6d229 (Left Lamp)> emitting event: {"attribute_id":"colorTemperatureRange","capability_id":"colorTemperature","component_id":"main","state":{"value":{"maximum":6500,"minimum":2000}}}
2026-04-16T19:36:17.553807132Z INFO Philips Hue  [st.device] 	<Device: 4ee7f7cc-8d0c-429e-8f06-0d168db6d229 (Left Lamp)> emitting event: {"attribute_id":"colorTemperature","capability_id":"colorTemperature","component_id":"main","state":{"value":2834}}
2026-04-16T19:36:31.894571925Z TRACE Philips Hue  [st.driver] 	Received event with handler capability
2026-04-16T19:36:31.900347842Z INFO Philips Hue  [hue_driver_template] 	Batch not big enough to handle with group commands
2026-04-16T19:36:31.910543509Z INFO Philips Hue  [st.device] 	<Device: 4ee7f7cc-8d0c-429e-8f06-0d168db6d229 (Left Lamp)> received command: {"args":{"temperature":2835},"capability":"colorTemperature","command":"setColorTemperature","component":"main","named_args":{"temperature":2835},"positional_args":[2835]}
2026-04-16T19:36:31.916848717Z TRACE Philips Hue  [st.dispatcher] 	Found CapabilityCommandDispatcher handler in hue
2026-04-16T19:36:31.920214967Z TRACE Philips Hue  [utils] 	------------------------ Looking for bridge for Left Lamp with parent_device_id 20606b2e-9670-4cd5-a88c-574d7a3af499
2026-04-16T19:36:31.924134050Z TRACE Philips Hue  [utils] 	------------------------- parent_device label is Hue Bridge, checking if bridge
2026-04-16T19:36:31.931500675Z DEBUG Philips Hue  [handlers.commands] 	Color temp change from 2833K to 2835K results in same mirek value (352), emitting event directly
2026-04-16T19:36:31.938370092Z INFO Philips Hue  [st.device] 	<Device: 4ee7f7cc-8d0c-429e-8f06-0d168db6d229 (Left Lamp)> emitting event: {"attribute_id":"colorTemperature","capability_id":"colorTemperature","component_id":"main","state":{"value":2835}}
2026-04-16T19:36:32.007643134Z DEBUG Philips Hue  [st.thread] 	Left Lamp device thread event handled

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants