From 9b0c907ac07b2c29c7ed2f831507498540314824 Mon Sep 17 00:00:00 2001 From: Cody Cutrer Date: Fri, 15 Dec 2023 11:48:17 -0700 Subject: [PATCH] [mqtt.espmilighthub] use ColorUtil instead of deprecated HSBType.fromXY (#16066) and fix that it expects ranges from 0.0 to 1.0 instead of 0.0 to 100.0 Signed-off-by: Cody Cutrer --- .../espmilighthub/internal/handler/EspMilightHubHandler.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.mqtt.espmilighthub/src/main/java/org/openhab/binding/mqtt/espmilighthub/internal/handler/EspMilightHubHandler.java b/bundles/org.openhab.binding.mqtt.espmilighthub/src/main/java/org/openhab/binding/mqtt/espmilighthub/internal/handler/EspMilightHubHandler.java index 72d46aa9000a4..cfc64a3877ea1 100644 --- a/bundles/org.openhab.binding.mqtt.espmilighthub/src/main/java/org/openhab/binding/mqtt/espmilighthub/internal/handler/EspMilightHubHandler.java +++ b/bundles/org.openhab.binding.mqtt.espmilighthub/src/main/java/org/openhab/binding/mqtt/espmilighthub/internal/handler/EspMilightHubHandler.java @@ -48,6 +48,7 @@ import org.openhab.core.types.Command; import org.openhab.core.types.RefreshType; import org.openhab.core.types.State; +import org.openhab.core.util.ColorUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -294,7 +295,7 @@ private static HSBType calculateHSBFromColorTemp(int mireds, PercentType brightn coefficients = KANG_Y_COEFFICIENTS[0]; } BigDecimal y = polynomialFit(x, coefficients); - var rawHsb = HSBType.fromXY(x.floatValue() * 100.0f, y.floatValue() * 100.0f); + var rawHsb = ColorUtil.xyToHsb(new double[] { x.doubleValue(), y.doubleValue() }); return new HSBType(rawHsb.getHue(), rawHsb.getSaturation(), brightness); }