mirror of
https://github.com/danieldemus/openhab-core.git
synced 2026-07-29 12:34:22 +02:00
Do not provide unit information for plain number items (#1811)
Signed-off-by: Kai Kreuzer <kai@openhab.org>
This commit is contained in:
+5
-1
@@ -192,6 +192,10 @@ public class NumberItem extends GenericItem {
|
||||
*/
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
private @Nullable Unit<? extends Quantity<?>> getUnit(@Nullable Class<? extends Quantity<?>> dimension) {
|
||||
if (dimension == null) {
|
||||
// if it is a plain number without dimension, we do not have a unit.
|
||||
return null;
|
||||
}
|
||||
StateDescription stateDescription = getStateDescription();
|
||||
if (stateDescription != null) {
|
||||
String pattern = stateDescription.getPattern();
|
||||
@@ -203,7 +207,7 @@ public class NumberItem extends GenericItem {
|
||||
}
|
||||
}
|
||||
|
||||
if (dimension != null && unitProvider != null) {
|
||||
if (unitProvider != null) {
|
||||
// explicit cast to Class<? extends Quantity> as JDK compiler complains
|
||||
return unitProvider.getUnit((Class<? extends Quantity>) dimension);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user