mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 00:37:53 +00:00
Coerce color_temp to int even when passed in as kelvin (#7640)
This commit is contained in:
parent
a068efcd47
commit
3d4b2436db
@ -229,7 +229,7 @@ def preprocess_turn_on_alternatives(params):
|
||||
kelvin = params.pop(ATTR_KELVIN, None)
|
||||
if kelvin is not None:
|
||||
mired = color_util.color_temperature_kelvin_to_mired(kelvin)
|
||||
params[ATTR_COLOR_TEMP] = mired
|
||||
params[ATTR_COLOR_TEMP] = int(mired)
|
||||
|
||||
brightness_pct = params.pop(ATTR_BRIGHTNESS_PCT, None)
|
||||
if brightness_pct is not None:
|
||||
|
@ -56,10 +56,10 @@ class TestDemoLight(unittest.TestCase):
|
||||
self.assertEqual(154, state.attributes.get(light.ATTR_MIN_MIREDS))
|
||||
self.assertEqual(500, state.attributes.get(light.ATTR_MAX_MIREDS))
|
||||
self.assertEqual('none', state.attributes.get(light.ATTR_EFFECT))
|
||||
light.turn_on(self.hass, ENTITY_LIGHT, kelvin=4000, brightness_pct=50)
|
||||
light.turn_on(self.hass, ENTITY_LIGHT, kelvin=3000, brightness_pct=50)
|
||||
self.hass.block_till_done()
|
||||
state = self.hass.states.get(ENTITY_LIGHT)
|
||||
self.assertEqual(250, state.attributes.get(light.ATTR_COLOR_TEMP))
|
||||
self.assertEqual(333, state.attributes.get(light.ATTR_COLOR_TEMP))
|
||||
self.assertEqual(127, state.attributes.get(light.ATTR_BRIGHTNESS))
|
||||
|
||||
def test_turn_off(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user