Examples of HSBType


Examples of org.openhab.core.library.types.HSBType

   
    // get RGB hex value
    State state = itemUIRegistry.getState(cp);
    String hexValue = "#ffffff";
    if(state instanceof HSBType) {
      HSBType hsbState = (HSBType) state;
      Color color = hsbState.toColor();
      hexValue = "#" + Integer.toHexString(color.getRGB()).substring(2);
    }
    String label = getLabel(cp);
    String purelabel = label;
    if(label.contains("<span>")) {
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

      } else if (item instanceof ContactItem) {
        state = OpenClosedType.valueOf(i.getValue());
      } else if (item instanceof RollershutterItem) {
        state = new PercentType(Integer.valueOf(i.getValue()));
      } else if (item instanceof ColorItem) {
        state = new HSBType(i.getValue());
      } else if (item instanceof DateTimeItem) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(new Date(Long.valueOf(i.getValue())));
        state = new DateTimeType(cal);
      } else {
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

      if(currentState instanceof HSBType) {
        DecimalType hue = ((HSBType) currentState).getHue();
        PercentType saturation = ((HSBType) currentState).getSaturation();
        // we map ON/OFF values to dark/bright, so that the hue and saturation values are not changed
        if(state==OnOffType.OFF) {
          super.setState(new HSBType(hue, saturation, PercentType.ZERO));
        } else if(state==OnOffType.ON) {
          super.setState(new HSBType(hue, saturation, PercentType.HUNDRED));
        } else if(state instanceof PercentType && !(state instanceof HSBType)) {
          super.setState(new HSBType(hue, saturation, (PercentType) state));
        } else {
          super.setState(state);
        }
      } else {
        // we map ON/OFF values to black/white and percentage values to grey scale
        if(state==OnOffType.OFF) {
          super.setState(HSBType.BLACK);
        } else if(state==OnOffType.ON) {
          super.setState(HSBType.WHITE);
        } else if(state instanceof PercentType && !(state instanceof HSBType)) {
          super.setState(new HSBType(DecimalType.ZERO, PercentType.ZERO, (PercentType) state));
        } else {
          super.setState(state);
        }
      }
    }
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

    public State getStateAs(Class<? extends State> typeClass) {
      if(typeClass==HSBType.class) {
        return this.state;
      } else if(typeClass==OnOffType.class) {
        if(state instanceof HSBType) {
          HSBType hsbState = (HSBType) state;
          // if brightness is not completely off, we consider the state to be on
          return hsbState.getBrightness().equals(PercentType.ZERO) ? OnOffType.OFF : OnOffType.ON;         
        }
      } else if(typeClass==DecimalType.class) {
        if(state instanceof HSBType) {
          HSBType hsbState = (HSBType) state;
          return new DecimalType(hsbState.getBrightness().toBigDecimal().divide(new BigDecimal(100), 8, RoundingMode.UP));
        }
      }
      return super.getStateAs(typeClass);
    }
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

      } else if (item instanceof ContactItem) {
        state = OpenClosedType.valueOf(obj.getString(FIELD_VALUE));
      } else if (item instanceof RollershutterItem) {
        state = new PercentType(obj.getInt(FIELD_VALUE));
      } else if (item instanceof ColorItem) {
        state = new HSBType(obj.getString(FIELD_VALUE));
      } else if (item instanceof DateTimeItem) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(obj.getDate(FIELD_VALUE));
        state = new DateTimeType(cal);
      } else {
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

        int r = Integer.parseInt (value.split(" ")[0].split(":")[1]);
        int g = Integer.parseInt (value.split(" ")[1].split(":")[1]);
        int b = Integer.parseInt (value.split(" ")[2].split(":")[1]);

        Color color = new Color (r, g, b);
        return new HSBType(color);
      }
    }
    catch (KNXFormatException kfe) {
      logger.info("Translator couldn't parse data for datapoint type ‘{}‘ (KNXFormatException).", datapoint.getDPT());
    }
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

                if ((bulb.getIsOn() == true) && (bulb.getIsReachable() == true)) {
                  // Only postUpdate when bulb is on, otherwise color item is not retaining state and shows to max brightness value
                  DecimalType decimalHue = new DecimalType(bulb.getHue() / (double)182);
                  PercentType percentBrightness = new PercentType((int)Math.round((bulb.getBrightness() * (double)100) / (double)255));
                  PercentType percentSaturation = new PercentType((int)Math.round((bulb.getSaturation() * (double)100) / (double)255));
                  HSBType newHsb = new HSBType(decimalHue, percentSaturation, percentBrightness);
                  if ((deviceConfig.itemStateHSBType == null) || (deviceConfig.itemStateHSBType.equals(newHsb) == false)) {
                    eventPublisher.postUpdate(hueItemName, newHsb);
                    deviceConfig.itemStateHSBType = newHsb;
                  }
                }                 
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

    if (command instanceof OnOffType) {
      bulb.switchOn(OnOffType.ON.equals(command));
    }

    if (command instanceof HSBType) {
      HSBType hsbCommand = (HSBType) command;
      DecimalType hue = hsbCommand.getHue();
      PercentType sat = hsbCommand.getSaturation();
      PercentType bri = hsbCommand.getBrightness();
      bulb.colorizeByHSB(hue.doubleValue() / 360,
          sat.doubleValue() / 100, bri.doubleValue() / 100);
    }

    if (deviceConfig.getType().equals(BindingType.brightness)
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

        count++;

        if (item instanceof NumberItem)
          state = new DecimalType(rs.getDouble(2));
        else if (item instanceof ColorItem)
          state = new HSBType(rs.getString(2));
        else if (item instanceof DimmerItem)
          state = new PercentType(rs.getInt(2));
        else if (item instanceof SwitchItem)
          state = OnOffType.valueOf(rs.getString(2));
        else if (item instanceof ContactItem)
View Full Code Here

Examples of org.openhab.core.library.types.HSBType

   * @param tvCommand
   */
  private void updateItemState(String itemName, String tvCommand) {
    if (tvCommand.contains("ambilight")) {
      String[] layer = command2LayerString(tvCommand);
      HSBType state = new HSBType(getAmbilightColor(ip + ":" + port, layer));
      eventPublisher.postUpdate(itemName, state);
    } else if (tvCommand.contains("volume")) {
      if (tvCommand.contains("mute")) {
        eventPublisher.postUpdate(itemName, getTVVolume(ip + ":" + port).mute ? OnOffType.ON : OnOffType.OFF);
      } else {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.