Skip to content

Commit

Permalink
fix(hue): Fix Mirek -> Kelvin conversion constant.
Browse files Browse the repository at this point in the history
This constant should be 100, but I resolved a conflict during a rebase incorrectly
when prepping the original PR and it got set to 11 instead of 100.
  • Loading branch information
dljsjr committed Feb 13, 2025
1 parent af3584e commit 1368feb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/SmartThings/philips-hue/src/consts.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ Consts.DEFAULT_MAX_MIREK = 500
Consts.MIN_TEMP_KELVIN_COLOR_AMBIANCE = 2000
Consts.MIN_TEMP_KELVIN_WHITE_AMBIANCE = 2200
Consts.MAX_TEMP_KELVIN = 6500
Consts.KELVIN_STEP_SIZE = 11
Consts.KELVIN_STEP_SIZE = 100

return Consts
16 changes: 16 additions & 0 deletions drivers/SmartThings/philips-hue/src/test/spec/unit/utils_spec.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
describe("utility functions", function()
local Consts
local Fields
local HueDeviceTypes
local st_utils
local utils

setup(function()
Consts = require "consts"
Fields = require "fields"
HueDeviceTypes = require "hue_device_types"
utils = require "utils"
st_utils = require "st.utils"
end)

describe("that perform mirek to kelvin conversions behave properly:", function()
it("Common minimum mirek of 153 results in 6500 Kelvin", function()
local expected_kelvin = 6500
local computed_kelvin = utils.mirek_to_kelvin(Consts.DEFAULT_MIN_MIREK)
assert.are.equal(expected_kelvin, computed_kelvin, string.format("Expected value of %s, got %s", expected_kelvin, computed_kelvin))
end)

it("Common maximum mirek of 500 results in 2000 Kelvin", function()
local expected_kelvin = 2000
local computed_kelvin = utils.mirek_to_kelvin(Consts.DEFAULT_MAX_MIREK)
assert.are.equal(expected_kelvin, computed_kelvin, string.format("Expected value of %s, got %s", expected_kelvin, computed_kelvin))
end)
end)

describe("that handle raw data will handle their input correctly:", function()
local test_mac_addr
local test_cisco_mac_addr
Expand Down

0 comments on commit 1368feb

Please sign in to comment.