Skip to content

Commit

Permalink
[mqtt.espmilighthub] use ColorUtil instead of deprecated HSBType.from…
Browse files Browse the repository at this point in the history
…XY (openhab#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 <cody@cutrer.us>
  • Loading branch information
ccutrer authored and joni1993 committed Oct 15, 2024
1 parent 307ecf4 commit 9b0c907
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit 9b0c907

Please sign in to comment.