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

UnitUtils.getDimensionName wrong result #2880

Closed
clinique opened this issue Mar 29, 2022 · 0 comments · Fixed by #2895
Closed

UnitUtils.getDimensionName wrong result #2880

clinique opened this issue Mar 29, 2022 · 0 comments · Fixed by #2895
Labels
bug An unexpected problem or unintended behavior of the Core

Comments

@clinique
Copy link
Contributor

Dimensionless units like Units.DECIBEL, Units.PARTS_PER_MILLION, Units.PERCENT are reported as an "Angle" instead of "Dimensionless" by UnitUtils.getDimensionName()

Some binding have implemented a counter measure but root correction would be better :

                String dimension = UnitUtils.getDimensionName(unit);
                dimension = (Units.DECIBEL.equals(unit) || Units.PARTS_PER_MILLION.equals(unit)
                        || Units.PERCENT.equals(unit)) ? "Dimensionless" // strangely it is given as an Angle
                                : dimension;
wborn added a commit to wborn/openhab-core that referenced this issue Apr 4, 2022
An Angle is also Dimensionless and because it is the first compatible unit it is always returned instead of any other Dimensionless unit.
With these changes `getDimensionName` will prefer the unit of equal dimensions over those of compatible dimensions.

Fixes openhab#2880

Signed-off-by: Wouter Born <github@maindrain.net>
wborn added a commit to wborn/openhab-core that referenced this issue Apr 4, 2022
An Angle is also Dimensionless and because it is the first compatible unit it is always returned instead of any other Dimensionless unit.
With these changes `getDimensionName` will prefer the dimension of equal units over those of compatible units.

Fixes openhab#2880

Signed-off-by: Wouter Born <github@maindrain.net>
@wborn wborn added the bug An unexpected problem or unintended behavior of the Core label Apr 4, 2022
wborn added a commit to wborn/openhab-core that referenced this issue Apr 4, 2022
An Angle is also Dimensionless and because it is the first compatible unit it is always returned instead of any other Dimensionless unit.
With these changes `getDimensionName` will prefer the dimension of equal units over those of compatible units.

Fixes openhab#2880

Signed-off-by: Wouter Born <github@maindrain.net>
wborn added a commit to wborn/openhab-core that referenced this issue Apr 4, 2022
An Angle is also Dimensionless and because it is the first compatible unit it is always returned instead of any other Dimensionless unit.
With these changes `getDimensionName` will prefer the dimension of equal units over those of compatible units.

Fixes openhab#2880

Signed-off-by: Wouter Born <github@maindrain.net>
kaikreuzer pushed a commit that referenced this issue Apr 14, 2022
…#2895)

An Angle is also Dimensionless and because it is the first compatible unit it is always returned instead of any other Dimensionless unit.
With these changes `getDimensionName` will prefer the dimension of equal units over those of compatible units.

Fixes #2880

Signed-off-by: Wouter Born <github@maindrain.net>
splatch pushed a commit to ConnectorIO/copybara-hab-core that referenced this issue Jul 12, 2023
…openhab#2895)

An Angle is also Dimensionless and because it is the first compatible unit it is always returned instead of any other Dimensionless unit.
With these changes `getDimensionName` will prefer the dimension of equal units over those of compatible units.

Fixes openhab#2880

Signed-off-by: Wouter Born <github@maindrain.net>
GitOrigin-RevId: a4353ee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior of the Core
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants