-
-
Notifications
You must be signed in to change notification settings - Fork 34.3k
Add ability to force number selector as an integer #130104
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
Conversation
Hey there @yuxincs, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @autinerd, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @autinerd, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Hey there @MartinHjelmare, @functionpointer, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
I think this should be further discussed before we add it if at all. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Can we close here? I've heard no motivation why this is better than composing validators. |
The biggest challenge today is that there is no way of telling the frontend to reject a decimal number. There are a few comments above indicating that developpers would find it useful, and it would make it easier to prevent mistakes both on the developper side and on the user side. However I don't have the energy to fight for this so... |
If we want to extend the number selector to validate a specific type of number we should add an option for that in the number selector config. We shouldn't reuse the step option for a different purpose. I'll close here since this isn't the right approach. |
That was what we started with: 93bcbc8 |
Then we need an architecture discussion. |
Breaking change
Integrations using an explicit step with an integer value will now have the value validated.
If this behavior is not desired, please adjust the step to a float (
1
=>1.0
)Proposed change
As I was reviewing #130084, I realised that there was no easy way to force a
NumberSelector
to return an integer, and developers had to rely onvol.All(NumberSelector(...), vol.Coerce(int))
The default behavior for
NumberSelector
has been updated, such that setting the step as an integer will now cause validation of the value, to ensure it is an integerTo improve backwards compatibility, the default step value has been adjusted from 1 (integer) to 1.0 (float)
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: