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

Validation failed with InvalidStepSize #18

Closed
Frederick-G764 opened this issue Feb 16, 2020 · 4 comments
Closed

Validation failed with InvalidStepSize #18

Frederick-G764 opened this issue Feb 16, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@Frederick-G764
Copy link

In the UI X you can specify the individual coffee amount for every program and there is a valid range listed for every program. But the API does not allow every value between those limits. When I enter a value that is not within the "step size" it leads to the fowling error when starting the program:

[2/16/2020, 12:16:48] [HomeConnect] [Kaffeevollautomat] Home Connect API error:ConsumerProducts.CoffeeMaker.Option.When validation failed with InvalidStepSize. [SDK.Error.InvalidOptionValue]

In terms of usability the setpsize should maybe be added as a hint. Or maybe a dropdown menu for the amount based on the API setpsize.

@Frederick-G764 Frederick-G764 added the bug Something isn't working label Feb 16, 2020
@thoukydides
Copy link
Owner

The step size for each option is added to the .homebridge-homeconnect-v1.schema.json file (as multipleOf). Unfortunately, homebridge-config-ui-x (or rather its use of Angular JSON Schema Form) allows the configuration to be saved with invalid values.

A dropdown menu may be suitable when only a few values are allowed, which looks like is often the case for ConsumerProducts.CoffeeMaker.Option.FillQuantity (which is presumably what you are setting). However, it is not suitable for some other numeric fields, e.g. BSH.Common.Option.StartInRelative can be any integer from 0 to 86340 seconds.

Perhaps selecting between a dropdown menu or a comment based on the number of allowed values. I'll have a think about it...

@thoukydides thoukydides added enhancement New feature or request and removed bug Something isn't working labels Feb 16, 2020
@thoukydides
Copy link
Owner

The step size for each option is added to the .homebridge-homeconnect-v1.schema.json file (as multipleOf). Unfortunately, homebridge-config-ui-x (or rather its use of Angular JSON Schema Form) allows the configuration to be saved with invalid values.

Actually, it is slightly more complicated than that...

The .homebridge-homeconnect-v1.schema.json file defines each program's options and their constraints in two places. The schema section lists the union of options that apply to any of the appliance's programs, with constraints encompassing all possible values. The form section then restricts the options and allowed values to those applicable to the selected program. This approach is required because Angular JSON Schema Form does not support arrays of mixed objects (using anyOf).

Both the schema and form sections specify the minimum and maximum range for numeric types. However, the multipleOf is currently only specified in the form section. I could probably add it to the schema too as the GCD (greatest common divisor) of the step sizes for all programs with that option.

AJSF only uses the minimum / maximum / multipleOf from the schema when validating the input and deciding whether to display a warning message.

The values from the form section are, however, applied when clicking on the up/down narrows next to the input field for numeric values. These do correctly round the value to the allowed step size for each program.

@thoukydides
Copy link
Owner

I have implemented:

  • The schema's multipleOf is set to the GCD of the step sizes required by all programs.
  • If there are less than 20 permitted values for a specific program's option then they are enumerated.
  • If there are 20 or more permitted values then the required step size is added to the option's description.

Committed as 318410d. Will be in the next release.

@thoukydides
Copy link
Owner

Released as v0.17.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants