Skip to content

Commit

Permalink
fix: Echo user requested setpoint for kelvin
Browse files Browse the repository at this point in the history
If the bulb's color temperature changes because of an ST-initiated user
requested setpoint, we emit that directly instead of clamping to the
step size. This is to remain consistent with the way things are done on
the rest of the platform with other integrations.
  • Loading branch information
dljsjr committed Mar 3, 2025
1 parent 2dac5c2 commit 59b1da3
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions drivers/SmartThings/philips-hue/src/fields.lua
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ local Fields = {
COLOR_SATURATION = "color_saturation",
COLOR_HUE = "color_hue",
SWITCH_STATE = "switch_state_cache",
COLOR_TEMP_SETPOINT = "ct_setpoint"
}

return Fields
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,17 @@ local function _emit_light_events_inner(light_device, light_repr)
)
)
else
local last_kelvin_setpoint = light_device:get_field(Fields.COLOR_TEMP_SETPOINT)
if
last_kelvin_setpoint ~= nil and
last_kelvin_setpoint >= utils.mirek_to_kelvin(mirek + 1) and
last_kelvin_setpoint <= utils.mirek_to_kelvin(mirek - 1)
then
kelvin = last_kelvin_setpoint;
end
light_device:emit_event(capabilities.colorTemperature.colorTemperature(kelvin))
end
light_device:set_field(Fields.COLOR_TEMP_SETPOINT, nil);
end

if light_repr.color then
Expand Down
1 change: 1 addition & 0 deletions drivers/SmartThings/philips-hue/src/handlers/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ local function do_color_temp_action(driver, device, args)
end
end
end
device:set_field(Fields.COLOR_TEMP_SETPOINT, clamped_kelvin);
end

---@param driver HueDriver
Expand Down

0 comments on commit 59b1da3

Please sign in to comment.