예제 #1
0
  /**
   * 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;
  }
예제 #2
0
 /**
  * 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));
 }
예제 #3
0
 /**
  * Transforms {@link State} into {@link StringType} representing the {@link AlertMode}.
  *
  * @param lightState light state.
  * @return string type representing the alert mode.
  */
 public static StringType toAlertStringType(State lightState) {
   return new StringType(lightState.getAlertMode().toString());
 }
예제 #4
0
 /**
  * Transforms {@link HueLightState} into {@link PercentType} representing the color temperature.
  *
  * @param lightState light state
  * @return percent type representing the color temperature
  */
 public static PercentType toColorTemperaturePercentType(State lightState) {
   int percent =
       (lightState.getColorTemperature() - MIN_COLOR_TEMPERATURE) / COLOR_TEMPERATURE_RANGE;
   return new PercentType(restrictToBounds(percent));
 }