Skip to content

Add kelvin/brightness_pct alternatives to light.turn_on#7596

Merged
balloob merged 7 commits into
home-assistant:devfrom
amelchio:light-kelvin-brightness_pct
May 17, 2017
Merged

Add kelvin/brightness_pct alternatives to light.turn_on#7596
balloob merged 7 commits into
home-assistant:devfrom
amelchio:light-kelvin-brightness_pct

Conversation

@amelchio
Copy link
Copy Markdown
Contributor

@amelchio amelchio commented May 14, 2017

Description:

The existing color_temp (in mired) and brightness (arbitrary 8-bit scale) parameters to light.turn_on usually require calculations that most people cannot do in their head.

This PR adds alternative and well-known ways to specify white temperature (kelvin) and brightness (brightness_pct).

I guess the best way to express brightness would be with a calibrated unit like lumen but I do not see any way to provide that.

Pull request in home-assistant.github.io with documentation (if applicable): home-assistant/home-assistant.github.io#<home-assistant.github.io PR number goes here>

Example entry for configuration.yaml (if applicable):

[...]
      service: light.turn_on
      entity_id: group.basement
      data:
        kelvin: 3000
        brightness_pct: 40

Checklist:

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

If the code does not interact with devices:

  • Local tests with tox run successfully.
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link
Copy Markdown

@amelchio, thanks for your PR! By analyzing the history of the files in this pull request, we identified @mxtra, @fabaff and @balloob to be potential reviewers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

undefined name 'preprocess_turn_on_alternatives'

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.

Why would LIFX need this logic?

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.

This is because LIFX effects (and also lifx_set_state now) accept the same parameter names as light.turn_on, without actually going through the turn_on handler.

I previously wrote it out for color_name, but now with four alternative names I thought it to be too much duplication.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

line too long (80 > 79 characters)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

expected 2 blank lines, found 1

@amelchio amelchio force-pushed the light-kelvin-brightness_pct branch from d9caf0e to 3bfbcc5 Compare May 14, 2017 16:35
@amelchio amelchio force-pushed the light-kelvin-brightness_pct branch from 3bfbcc5 to ebd9719 Compare May 14, 2017 16:53
@amelchio amelchio force-pushed the light-kelvin-brightness_pct branch from ebd9719 to 7534b10 Compare May 14, 2017 17:18
@amelchio amelchio force-pushed the light-kelvin-brightness_pct branch from 7534b10 to 687d330 Compare May 14, 2017 17:33

def preprocess_turn_on_alternatives(params):
"""Processing extra data for turn light on request."""
profile = Profiles.get(params.pop(ATTR_PROFILE, None))
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 wonder if anyone knows about this and uses it.

Copy link
Copy Markdown
Member

@balloob balloob May 15, 2017

Choose a reason for hiding this comment

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

Maybe we should deprecate it now that we have scenes, scripts etc. (out of scope of this PR)

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.

I have actually been thinking about extending it instead :-). I hope to make it possible to have multiple colors in a profile. This would create a "mood" that could be applied to a group of lights so each light gets one of the colors (without them all being identical). It could also be used for an animation effect where lights randomly change between colors in the profile.


color_name = params.pop(ATTR_COLOR_NAME, None)
if color_name is not None:
params[ATTR_RGB_COLOR] = color_util.color_name_to_rgb(color_name)
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.

Would it make sense to just mark rgb_color and color_name exclusive in the voluptuous schema? That way they can never be specified together. Now it might be confusing to the user why one parameter would overrule the other.

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.

Yes, I think that would make sense but I would prefer it to be a different PR?

The xy_color, color_temp, profile and maybe more parameters are also mutually exclusive.

@pvizeli
Copy link
Copy Markdown
Member

pvizeli commented May 16, 2017

@balloob profiles are realy cool. I hope we do that not remove 👍

@balloob balloob merged commit ed5f94f into home-assistant:dev May 17, 2017
@balloob
Copy link
Copy Markdown
Member

balloob commented May 17, 2017

Alrighty, looks good 🐬

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.

6 participants