Skip to content

Add color_mode support to zwave_js light#49588

Merged
MartinHjelmare merged 2 commits into
home-assistant:devfrom
emontnemery:zwavejs_rgbw
Apr 30, 2021
Merged

Add color_mode support to zwave_js light#49588
MartinHjelmare merged 2 commits into
home-assistant:devfrom
emontnemery:zwavejs_rgbw

Conversation

@emontnemery
Copy link
Copy Markdown
Contributor

@emontnemery emontnemery commented Apr 23, 2021

Breaking change

Zwave JS lights no longer supports deprecated white_value, use rgbw_color instead.

Proposed change

Add color_mode support to zwave_js light.
Flag support for rgbw instead of white_value for lights with red, green, blue and a single white channel

Note:

The driver for this PR is that white_value is deprecated, with a plan to warn when it's used in 2021.6, and a complete removal in 2021.10.
zwave_js is one of the most widely used integrations which supports white_value.
If this is not the right way to modify zwave_js, it's perfectly fine to close this PR.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

To help with the load of incoming pull requests:

@probot-home-assistant
Copy link
Copy Markdown

Hey there @home-assistant/z-wave, mind taking a look at this pull request as its been labeled with an integration (zwave_js) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

# convert to HS
self._hs_color = color_util.color_RGB_to_hs(red, green, blue)
# Light supports color, set color mode to hs
self._color_mode = COLOR_MODE_HS
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zwave is using raw RGB internally, we might want to flag COLOR_MODE_RGB instead.

- ((cold_white / 255) * (self._max_mireds - self._min_mireds))
)
# White channels turned on, set color mode to color_temp
self._color_mode = COLOR_MODE_COLOR_TEMP
Copy link
Copy Markdown
Contributor Author

@emontnemery emontnemery Apr 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zwave allows all 5 channels in a 5 channel light to be on simultaneously. Unless blocked by zwave_js, we might want to check which channels are on:
if r, g, b are all zero and at least one white channel is non zero -> COLOR_MODE_COLOR_TEMP
if at least one of r, g, b is non zero and at least one white channel is non zero -> COLOR_MODE_RGBWW

if self._supports_rgbw:
self._supported_color_modes.add(COLOR_MODE_RGBW)
elif self._supports_color:
self._supported_color_modes.add(COLOR_MODE_HS)
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zwave is using raw RGB internally, we might want to flag COLOR_MODE_RGB instead.
Also, if the light supports both color and color_temp, it's a 5 channel light and we might want to flag COLOR_MODE_RGBWW as well.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. I'll test the PR with my color light.

Comment thread homeassistant/components/zwave_js/light.py
Comment thread homeassistant/components/zwave_js/light.py
@MartinHjelmare MartinHjelmare self-assigned this Apr 23, 2021
@MartinHjelmare
Copy link
Copy Markdown
Member

My color light is missing the color wheel in the frontend with this PR.

@MartinHjelmare
Copy link
Copy Markdown
Member

MartinHjelmare commented Apr 23, 2021

Calling the light.turn_on service seems to work with a color name. (but still no color wheel in the frontend)

@emontnemery
Copy link
Copy Markdown
Contributor Author

emontnemery commented Apr 23, 2021

For testing with frontend, you need this PR, I forgot to mention it home-assistant/frontend#8961

Also, what kind of color lights do you have?

@MartinHjelmare
Copy link
Copy Markdown
Member

It's an Aeotec LED Bulb 6 Multi-Colour with warm/cold/red/blue/green.

@MartinHjelmare
Copy link
Copy Markdown
Member

Ok, we should wait with merging here until the frontend is updated with this in core.

@MartinHjelmare MartinHjelmare marked this pull request as draft April 23, 2021 14:22
@emontnemery
Copy link
Copy Markdown
Contributor Author

emontnemery commented Apr 28, 2021

The frontend PR is merged, I think this should not be marked as draft anymore?

@MartinHjelmare MartinHjelmare marked this pull request as ready for review April 28, 2021 19:23
@firstof9
Copy link
Copy Markdown
Contributor

I think this may need a little rework in light of the recently fixed white_value issue.

@emontnemery
Copy link
Copy Markdown
Contributor Author

emontnemery commented Apr 29, 2021

Thanks @firstof9, rebased + reworked as needed 👍

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've now tested this with my light and the new frontend and the behavior is the same as before.

Looks good!

@MartinHjelmare MartinHjelmare merged commit 956c972 into home-assistant:dev Apr 30, 2021
@github-actions github-actions Bot locked and limited conversation to collaborators May 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants