Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trim CW from RGB when not supported in ozw #39191

Merged
merged 2 commits into from Aug 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 7 additions & 2 deletions homeassistant/components/ozw/light.py
Expand Up @@ -204,12 +204,17 @@ async def async_turn_on(self, **kwargs):
rgbw = "#"
for colorval in color_util.color_hs_to_RGB(*hs_color):
rgbw += f"{colorval:02x}"
rgbw += "0000"
if self._color_channels and self._color_channels & COLOR_CHANNEL_COLD_WHITE:
rgbw += "0000"
else:
# trim the CW value or it will not work correctly
rgbw += "00"
# white LED must be off in order for color to work

elif white is not None:
if self._color_channels & COLOR_CHANNEL_WARM_WHITE:
rgbw = f"#000000{white:02x}00"
# trim the CW value or it will not work correctly
rgbw = f"#000000{white:02x}"
else:
rgbw = f"#00000000{white:02x}"

Expand Down
8 changes: 4 additions & 4 deletions tests/components/ozw/test_light.py
Expand Up @@ -377,11 +377,11 @@ async def test_pure_rgb_dimmer_light(

msg = sent_messages[-2]
assert msg["topic"] == "OpenZWave/1/command/setvalue/"
assert msg["payload"] == {"Value": "#ff4cff0000", "ValueIDKey": 122470423}
assert msg["payload"] == {"Value": "#ff4cff00", "ValueIDKey": 122470423}

# Feedback on state
light_pure_rgb_msg.decode()
light_pure_rgb_msg.payload["Value"] = "#ff4cff0000"
light_pure_rgb_msg.payload["Value"] = "#ff4cff00"
light_pure_rgb_msg.encode()
receive_message(light_pure_rgb_msg)
await hass.async_block_till_done()
Expand Down Expand Up @@ -500,14 +500,14 @@ async def test_no_cw_light(
assert len(sent_messages) == 2
msg = sent_messages[-2]
assert msg["topic"] == "OpenZWave/1/command/setvalue/"
assert msg["payload"] == {"Value": "#000000be00", "ValueIDKey": 659341335}
assert msg["payload"] == {"Value": "#000000be", "ValueIDKey": 659341335}

# Feedback on state
light_msg.decode()
light_msg.payload["Value"] = byte_to_zwave_brightness(255)
light_msg.encode()
light_rgb_msg.decode()
light_rgb_msg.payload["Value"] = "#000000be00"
light_rgb_msg.payload["Value"] = "#000000be"
light_rgb_msg.encode()
receive_message(light_msg)
receive_message(light_rgb_msg)
Expand Down