Fix ZWave RGBW lights not producing color without explicit white_value (#15412)

* Fix ZWave RGBW lights not producing color without explicit white_value (#13930)

* simplify conditional in previous commit (#13930)

* ZwaveColorLight - only zero _white if white_value not specified in call (#13930)
This commit is contained in:
Jason Antman 2018-07-13 18:54:15 -04:00 committed by Anders Melchiorsen
parent ce5b4cd51e
commit 6e22a0e4d9
2 changed files with 29 additions and 1 deletions

View file

@ -324,9 +324,11 @@ class ZwaveColorLight(ZwaveDimmer):
else:
self._ct = TEMP_COLD_HASS
rgbw = '#00000000ff'
elif ATTR_HS_COLOR in kwargs:
self._hs = kwargs[ATTR_HS_COLOR]
if ATTR_WHITE_VALUE not in kwargs:
# white LED must be off in order for color to work
self._white = 0
if ATTR_WHITE_VALUE in kwargs or ATTR_HS_COLOR in kwargs:
rgbw = '#'

View file

@ -255,6 +255,32 @@ def test_set_white_value(mock_openzwave):
assert color.data == '#ffffffc800'
def test_disable_white_if_set_color(mock_openzwave):
"""
Test that _white is set to 0 if turn_on with ATTR_HS_COLOR.
See Issue #13930 - many RGBW ZWave bulbs will only activate the RGB LED to
produce color if _white is set to zero.
"""
node = MockNode(command_classes=[const.COMMAND_CLASS_SWITCH_COLOR])
value = MockValue(data=0, node=node)
color = MockValue(data='#0000000000', node=node)
# Supports RGB only
color_channels = MockValue(data=0x1c, node=node)
values = MockLightValues(primary=value, color=color,
color_channels=color_channels)
device = zwave.get_device(node=node, values=values, node_config={})
device._white = 234
assert color.data == '#0000000000'
assert device.white_value == 234
device.turn_on(**{ATTR_HS_COLOR: (30, 50)})
assert device.white_value == 0
assert color.data == '#ffbf7f0000'
def test_zw098_set_color_temp(mock_openzwave):
"""Test setting zwave light color."""
node = MockNode(manufacturer_id='0086', product_id='0062',