Flux switch improvements (#3615)
* Make flux always adjust brightness of light (even when not in XY mode) * Remove kelvin mode from flux switch The light/turn_on service only works with mired values, kelvin values are out of range per the schema. * Use already defined min/max values for light/turn_on schema * Clamp temp value to light/turn_on allowed values
This commit is contained in:
1 parent
fcbfcf0aa7
commit
d55ed7a3a2
3 files changed
+17
-58
No files matched your search
@@ -532,46 +532,3 @@ class TestSwitchFlux(unittest.TestCase):
|
||||
self.hass.block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
self.assertEqual(call.data[light.ATTR_COLOR_TEMP], 269)
|
||||
|
||||
def test_flux_with_kelvin(self):
|
||||
"""Test the flux switch´s mode kelvin."""
|
||||
platform = loader.get_component('light.test')
|
||||
platform.init()
|
||||
self.assertTrue(
|
||||
setup_component(self.hass, light.DOMAIN,
|
||||
{light.DOMAIN: {CONF_PLATFORM: 'test'}}))
|
||||
|
||||
dev1 = platform.DEVICES[0]
|
||||
|
||||
# Verify initial state of light
|
||||
state = self.hass.states.get(dev1.entity_id)
|
||||
self.assertEqual(STATE_ON, state.state)
|
||||
self.assertIsNone(state.attributes.get('color_temp'))
|
||||
|
||||
test_time = dt_util.now().replace(hour=8, minute=30, second=0)
|
||||
sunset_time = test_time.replace(hour=17, minute=0, second=0)
|
||||
sunrise_time = test_time.replace(hour=5,
|
||||
minute=0,
|
||||
second=0) + timedelta(days=1)
|
||||
|
||||
with patch('homeassistant.util.dt.now', return_value=test_time):
|
||||
with patch('homeassistant.components.sun.next_rising',
|
||||
return_value=sunrise_time):
|
||||
with patch('homeassistant.components.sun.next_setting',
|
||||
return_value=sunset_time):
|
||||
assert setup_component(self.hass, switch.DOMAIN, {
|
||||
switch.DOMAIN: {
|
||||
'platform': 'flux',
|
||||
'name': 'flux',
|
||||
'lights': [dev1.entity_id],
|
||||
'mode': 'kelvin'
|
||||
}
|
||||
})
|
||||
turn_on_calls = mock_service(
|
||||
self.hass, light.DOMAIN, SERVICE_TURN_ON)
|
||||
switch.turn_on(self.hass, 'switch.flux')
|
||||
self.hass.block_till_done()
|
||||
fire_time_changed(self.hass, test_time)
|
||||
self.hass.block_till_done()
|
||||
call = turn_on_calls[-1]
|
||||
self.assertEqual(call.data[light.ATTR_COLOR_TEMP], 3708)
|
||||
Reference in new issue
Block a user