-
-
Notifications
You must be signed in to change notification settings - Fork 630
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
Fixed a regression where floats were rounded incorrectly when no minValue was provided #972
Conversation
…alue was provided (fixes #971)
Pull Request Test Coverage Report for Build 3081596305
💛 - Coveralls |
CC: @OrigamiDream |
In my opinion, Current state: const numericMin = maxWithUndefined(this.props.minValue, numericLowerBound(this.props.format));
const numericMax = minWithUndefined(this.props.maxValue, numericUpperBound(this.props.format)); And new suggestion: /* Needs to find original props */
const originalMin = originalProps.minValue; // if there is no defined default values, code must be failed.
const originalMax = originalProps.maxValue;
const numericMin = Math.max(numericLowerBound(this.props.format), maxWithUndefined(this.props.minValue, originalMin));
const numericMax = Math.min(numericUpperBound(this.props.format), maxWithUndefined(this.props.maxValue, originalMax)); This is not only preventing setting values that exceeding their limits, but also falling back to specific reasonable default value when the developer haven't set its specific value. All characteristic have their min and max values in their definitions. We have to restrict this to developers, not avoiding faced problem. |
I don’t disagree, but then please issue a warning that these are missing instead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also happy to see a warning when minValue and maxValue are missing, and leave the 0.10.3 logic.
I do remember issues with setting minValue for temperature to -273.15, because the minStep 0.1 would indeed start there, and no longer accept 20.5.
That's correct behaviour then. What I'm proposing is the following logic:
Requiring the Therefore, I would propose to merge this PR as is for a 0.10.4 release. We could open a discussion separately if we should change the behaviour for a future minor or major version increment of HAP-NodeJS. |
If this PR doesn't break any logics from 0.10.3 when I would expect |
This PR only changes the logic in the case where |
♻️ Current situation
The release of v0.10.3 introduced fixes to the float rounding mechanism (see #956, #958). It introduced a regression when no
minValue
was provided (see #971).💡 Proposed solution
This PR introduces a fix for this regression.
⚙️ Release Notes
minValue
was provided➕ Additional Information
This regression slipped through in this review step: https://github.com/homebridge/HAP-NodeJS/pull/958/files#r893353790.
Testing
A regression test was added, covering this case.
Reviewer Nudging
--