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 step validation to input_number and number selectors #20170

Closed
wants to merge 2 commits into from

Conversation

jbouwh
Copy link
Contributor

@jbouwh jbouwh commented Mar 23, 2024

Proposed change

Add step validation to number selectors to only call the setValue API if there is a valid step value selected.

The entity row UI number control has a red border when the step is invalid (autoValidate).
Enabled autoValidate on the state card to ensure the same behavior.

Type of change

  • 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

The MQTT number config example below can help to test the change (turn debug logging on for mqtt).

mqtt:
  - number:
      command_topic: test/number
      min: -18
      max: 40
      name: Test number
      mode: box
      step: 5

Additional information

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:

@jbouwh jbouwh force-pushed the number-step-validation branch from cebe490 to a86339f Compare March 23, 2024 14:59
@ildar170975
Copy link
Contributor

Assume an input_number helper is defined with step: 1 (i.e. w/o fractions).
Will it be still possible to input values like 123.123 ?

@jbouwh
Copy link
Contributor Author

jbouwh commented Mar 25, 2024

Assume an input_number helper is defined with step: 1 (i.e. w/o fractions). Will it be still possible to input values like 123.123 ?

I think so, but I'll do some additional testing to conform this. The test size of the entity is used BTW, not 1.

@jbouwh
Copy link
Contributor Author

jbouwh commented Mar 25, 2024

Converting to draft, as this works not well yet if not the native unit is set in the UI.

@jbouwh jbouwh marked this pull request as draft March 25, 2024 08:20
@jbouwh
Copy link
Contributor Author

jbouwh commented Jun 22, 2024

This PR is not ready, but the approach is not good., so closing this for now,

@jbouwh jbouwh closed this Jun 22, 2024
@jbouwh jbouwh deleted the number-step-validation branch June 22, 2024 20:22
@il77781
Copy link

il77781 commented Jun 23, 2024

@jbouwh, understood you. Well, it's a pity...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The "step" variable does not work for number in the box mode
3 participants