From 591d8d956aeb7ccfecf6d4c9b37f5a32a63bc394 Mon Sep 17 00:00:00 2001 From: Andrew Fiddian-Green Date: Mon, 4 Nov 2024 10:01:20 +0000 Subject: [PATCH] =?UTF-8?q?[Units]=20Add=20MK=E2=81=BB=C2=B9=20unit=20alia?= =?UTF-8?q?s=20(#4433)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add unit alias for Micro Reciprocal Kelvin Signed-off-by: AndrewFG --- .../java/org/openhab/core/library/unit/Units.java | 4 +++- .../java/org/openhab/core/library/unit/UnitsTest.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java index 824d531f801..f3e220fb152 100644 --- a/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java +++ b/bundles/org.openhab.core/src/main/java/org/openhab/core/library/unit/Units.java @@ -293,7 +293,9 @@ public final class Units extends CustomUnits { SimpleUnitFormat.getInstance().label(MILLIAMPERE_HOUR, "mAh"); SimpleUnitFormat.getInstance().label(MILLIBAR, "mbar"); SimpleUnitFormat.getInstance().label(MILLIMETRE_OF_MERCURY, MILLIMETRE_OF_MERCURY.getSymbol()); - SimpleUnitFormat.getInstance().label(MIRED, "mired"); + SimpleUnitFormat.getInstance().label(MIRED, "MK⁻¹"); + SimpleUnitFormat.getInstance().alias(MIRED, "mired"); + SimpleUnitFormat.getInstance().alias(MIRED, "mirek"); SimpleUnitFormat.getInstance().label(PARTS_PER_BILLION, "ppb"); SimpleUnitFormat.getInstance().label(PARTS_PER_MILLION, "ppm"); SimpleUnitFormat.getInstance().label(PETABYTE, "PB"); diff --git a/bundles/org.openhab.core/src/test/java/org/openhab/core/library/unit/UnitsTest.java b/bundles/org.openhab.core/src/test/java/org/openhab/core/library/unit/UnitsTest.java index 74ef456bb01..f88cb2a6bb5 100644 --- a/bundles/org.openhab.core/src/test/java/org/openhab/core/library/unit/UnitsTest.java +++ b/bundles/org.openhab.core/src/test/java/org/openhab/core/library/unit/UnitsTest.java @@ -431,6 +431,17 @@ public void testYearMonthDay() { assertThat(converted2.doubleValue(), is(closeTo(12.0, DEFAULT_ERROR))); } + @Test + public void testColorTemperatureAliases() { + QuantityType value; + value = QuantityType.valueOf("20 mired"); + assertEquals(Units.MIRED, value.getUnit()); + value = QuantityType.valueOf("20 mirek"); + assertEquals(Units.MIRED, value.getUnit()); + value = QuantityType.valueOf("20 MK⁻¹"); + assertEquals(Units.MIRED, value.getUnit()); + } + private static class QuantityEquals extends IsEqual> { private Quantity quantity;