From 1368feb90e43bd5a7296c4a73be13aeb65db9cb0 Mon Sep 17 00:00:00 2001 From: Doug Stephen Date: Thu, 13 Feb 2025 14:43:36 -0600 Subject: [PATCH] fix(hue): Fix Mirek -> Kelvin conversion constant. 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. --- drivers/SmartThings/philips-hue/src/consts.lua | 2 +- .../src/test/spec/unit/utils_spec.lua | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/drivers/SmartThings/philips-hue/src/consts.lua b/drivers/SmartThings/philips-hue/src/consts.lua index 1c35d92726..1f59a90de7 100644 --- a/drivers/SmartThings/philips-hue/src/consts.lua +++ b/drivers/SmartThings/philips-hue/src/consts.lua @@ -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 diff --git a/drivers/SmartThings/philips-hue/src/test/spec/unit/utils_spec.lua b/drivers/SmartThings/philips-hue/src/test/spec/unit/utils_spec.lua index c0791df114..861723a6a7 100644 --- a/drivers/SmartThings/philips-hue/src/test/spec/unit/utils_spec.lua +++ b/drivers/SmartThings/philips-hue/src/test/spec/unit/utils_spec.lua @@ -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