Skip to content

Migrate homematic light to color_mode#69267

Merged
pvizeli merged 1 commit intodevfrom
homematic_light_color_mode
Apr 5, 2022
Merged

Migrate homematic light to color_mode#69267
pvizeli merged 1 commit intodevfrom
homematic_light_color_mode

Conversation

@emontnemery
Copy link
Copy Markdown
Contributor

Proposed change

Migrate homematic light to color_mode

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

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.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • 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 @pvizeli, @danielperna84, mind taking a look at this pull request as it has been labeled with an integration (homematic) you are listed as a code owner for? Thanks!
(message by CodeOwnersMention)

Comment on lines +63 to +83
def color_mode(self) -> str:
"""Return the color mode of the light."""
if "COLOR" in self._hmdevice.WRITENODE:
return COLOR_MODE_HS
if hasattr(self._hmdevice, "get_color_temp"):
return COLOR_MODE_COLOR_TEMP
return COLOR_MODE_BRIGHTNESS

@property
def supported_color_modes(self) -> set[str] | None:
"""Flag supported color modes."""
color_modes = set()

if "COLOR" in self._hmdevice.WRITENODE:
features |= SUPPORT_COLOR
color_modes.add(COLOR_MODE_HS)
if hasattr(self._hmdevice, "get_color_temp"):
color_modes.add(COLOR_MODE_COLOR_TEMP)
if not color_modes:
color_modes.add(COLOR_MODE_BRIGHTNESS)

return color_modes
Copy link
Copy Markdown
Contributor Author

@emontnemery emontnemery Apr 4, 2022

Choose a reason for hiding this comment

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

This code is assuming:

  • A homematic light's features can dynamically change, and is not necessarily known when the HMLight object instantiated
  • There are homematic lights which can support both hs color and color temperature

Looking at the code in pyhomematic, I think neither of this is true; IPKeySwitchLevel and ColorEffectLight supports hs color, but not color temperature, ColdWarmDimmer supports color temperature but not hs color and there's no light supporting both.

@danielperna84, @pvizeli can you confirm this is the case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't know about the second one but the first one is wrong. Nothing is dynamic, all is known after the HMLight object is created

@pvizeli pvizeli merged commit 7b18d51 into dev Apr 5, 2022
@pvizeli pvizeli deleted the homematic_light_color_mode branch April 5, 2022 13:54
ggravlingen pushed a commit to ggravlingen/core that referenced this pull request Apr 5, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Apr 6, 2022
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