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

Already on GitHub? Sign in to your account

Add auto slider/box mode to number entity #10272

Merged
merged 3 commits into from
Oct 21, 2021
Merged

Add auto slider/box mode to number entity #10272

merged 3 commits into from
Oct 21, 2021

Conversation

frenck
Copy link
Member

@frenck frenck commented Oct 14, 2021

Proposed change

Type of change

This extends the number entity with an optional mode, it provides a hint to the UI on how to represent this number entity in either a slider or box, similar to how we do it with input_number.

The difference is the auto mode, which is the default. This should cover almost all cases out there and will be instantly applied to all existing number entities.

When in auto mode: If the range of possible positions on the number is 256 positions or smaller, it will become a slider, else a box is automatically picked.

The demo platform has been extended, the 2 existing entities (volume, PWM) have a fixed mode, while the large and small range entities have the default auto mode.

Backend PR: home-assistant/core#57737

image

image

image

Related to: home-assistant/core#56862

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

Example configuration

Additional information

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

Checklist

  • The code change is tested and works locally.
  • There is no commented out code in this PR.
  • Tests have been added to verify that the new code works.

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

@rytilahti
Copy link
Member

Tested with home-assistant/core#56862 (in auto mode, w/o the core changes) - is it expected that the slider is only used in the state card?

image

@frenck
Copy link
Member Author

frenck commented Oct 15, 2021

It needs the core changes from home-assistant/core#57737

@rytilahti
Copy link
Member

rytilahti commented Oct 15, 2021

Yes, I just realized that, I suppose I just wanted to ask if there should be a fallback to the default (auto) as I'm not familiar with TS practices. I just rebased that WLED PR on top of 57737 for testing, and it's works great! :-)

image

balloob
balloob previously approved these changes Oct 15, 2021
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
@frenck frenck added the Breaking Change Needs Special Documentation to let users know about Change label Oct 15, 2021
Comment on lines +85 to +88
(stateObj.attributes.mode === "auto" &&
(Number(stateObj.attributes.max) - Number(stateObj.attributes.min)) /
Number(stateObj.attributes.step) <=
256)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe idea to break this out in a helper function to reuse with state card.

@balloob balloob merged commit d05c763 into dev Oct 21, 2021
@balloob balloob deleted the frenck-2021-2598 branch October 21, 2021 05:12
@github-actions github-actions bot locked and limited conversation to collaborators Oct 22, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Breaking Change Needs Special Documentation to let users know about Change cla-signed hacktoberfest
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants