/** * Transforms {@link HueLightState} into {@link HSBType} representing the color. * * @param lightState light state * @return HSB type representing the color */ public static HSBType toHSBType(State lightState) { int hue = lightState.getHue(); int saturationInPercent = (int) (lightState.getSaturation() / SATURATION_FACTOR); int brightnessInPercent = (int) (lightState.getBrightness() / BRIGHTNESS_FACTOR); saturationInPercent = restrictToBounds(saturationInPercent); brightnessInPercent = restrictToBounds(brightnessInPercent); HSBType hsbType = new HSBType( new DecimalType(hue / HUE_FACTOR), new PercentType(saturationInPercent), new PercentType(brightnessInPercent)); return hsbType; }
/** * Transforms {@link HueLightState} into {@link PercentType} representing the brightness. * * @param lightState light state * @return percent type representing the brightness */ public static PercentType toBrightnessPercentType(State lightState) { int percent = (int) (lightState.getBrightness() / BRIGHTNESS_FACTOR); return new PercentType(restrictToBounds(percent)); }