8000 Make default dim level configurable in Lutron by cameronr · Pull Request #137127 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make default dim level configurable in Lutron #137127

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Feb 25, 2025

Conversation

cameronr
Copy link
Contributor
@cameronr cameronr commented Feb 1, 2025

Proposed change

Re-submitting #126160 after changing branch name to pass commit checks.

Make the default dim setting user configurable as requested in issue #122805

On docs, I'll submit a doc PR assuming this change looks ok.

On tests, the existing tests pass but I'm not sure how to update the tests to test options. I was mostly following what ESPHome does and I didn't see any examples of them testing options. I'm happy to add if I can get a pointer on how to test them.

thanks!

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)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • [x ] 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
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format 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.

To help with the load of incoming pull requests:

@home-assistant
Copy link
home-assistant bot commented Feb 1, 2025

Hey there @cdheiser, @wilburCforce, mind taking a look at this pull request as it has been labeled with an integration (lutron) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of lutron can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign lutron Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@cameronr
Copy link
Contributor Author
cameronr commented Feb 1, 2025

@joostlek Here's the updated Lutron default light level PR after changing the source branch name to comply with the git commit checks. Thanks!

"step": {
"init": {
"data": {
"default_dimmer_level": "Default light level when first turning on a light from HomeAssistant"
Copy link
Contributor

Choose a reason for hiding this comment

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

"HomeAssistant" -> "Home Assistant"

@MartinHjelmare MartinHjelmare changed the title Make default dim level configurable in Lutron (#122805) Make default dim level configurable in Lutron Feb 23, 2025
@@ -72,7 +73,9 @@ def turn_on(self, **kwargs: Any) -> None:
if ATTR_BRIGHTNESS in kwargs and self._lutron_device.is_dimmable:
brightness = kwargs[ATTR_BRIGHTNESS]
elif self._prev_brightness == 0:
brightness = 255 / 2
brightness = self.platform.config_entry.options.get(
Copy link
Member

Choose a reason for hiding this comment

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

(oh lol I missed this one).

We shouldn't get the config entry via self.platform, please just pass it as a parameter (or just pass the default dimmer level as parameter)

default=self.config_entry.options.get(
CONF_DEFAULT_DIMMER_LEVEL, DEFAULT_DIMMER_LEVEL
),
): vol.All(vol.Coerce(int), vol.Range(min=1, max=255)),
Copy link
Member

Choose a reason for hiding this comment

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

Also, I think you can use a NumberSelector here (not sure how this currently shows in the flow)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Now looks like this:

Screenshot 2025-02-23 at 10 35 38

@home-assistant home-assistant bot marked this pull request as draft February 23, 2025 13:40
@home-assistant
Copy link

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@cameronr cameronr force-pushed the lutron-default-brightness branch from dc9e211 to fc6470e Compare February 23, 2025 18:06
@cameronr cameronr marked this pull request as ready for review February 23, 2025 19:14
@home-assistant home-assistant bot requested a review from joostlek February 23, 2025 19:14
@joostlek joostlek merged commit b8b153b into home-assistant:dev Feb 25, 2025
30 of 32 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2025
config_entry: ConfigEntry,
) -> OptionsFlowHandler:
"""Get the options flow for this handler."""
return OptionsFlowHandler()
Copy link
Member
@MartinHjelmare MartinHjelmare Feb 27, 2025

Choose a reason for hiding this comment

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

Tests are missing. The CI checks for required coverage failed.

Copy link
Contributor Author
@cameronr cameronr Feb 27, 2025

Choose a reason for hiding this comment

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

I added a test for the OptionsFlowHandler. Should I open another PR to submit it?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, please. Thanks!

@home-assistant home-assistant unlocked this conversation Feb 27, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Feb 28, 2025
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.

Lutron using default dim for all dimmers after HA reboot
5 participants
0