Examples of HSBType


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

      return;
    }

    logger.debug("Setting Ambilight color for host {} and layer {} to {}", host, layers, command.toString());

    HSBType hsbcommand = (HSBType) command;
    String url = "http://" + host + "/1/ambilight/cached";

    StringBuilder content = new StringBuilder();
    content.append("{");

    int count = 0;

    if (layers != null) {
      for (int i = 0; i < layers.length; i++) {
        content.append("\"" + layers[i] + "\":{");
        count++;
      }
    }

    int red = Math.round(hsbcommand.getRed().floatValue() * 2.55f);
    int green = Math.round(hsbcommand.getGreen().floatValue() * 2.55f);
    int blue = Math.round(hsbcommand.getBlue().floatValue() * 2.55f);
    content.append("\"r\":" + red + ", \"g\":" + green + ", \"b\":" + blue);

    for (int i = 0; i < count; i++) {
      content.append("}");
    }
View Full Code Here

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

  public void canBeSetWithHsbCommand() throws BindingConfigParseException {

    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);

    HSBType hsb = new HSBType(DecimalType.ZERO, PercentType.HUNDRED,
        PercentType.HUNDRED);
    item.processCommand(service, hsb);

    Mockito.verify(service).setChannelValue(3, 255);
    Mockito.verify(service).setChannelValue(4, 0);
View Full Code Here

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

      throws BindingConfigParseException {

    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);

    HSBType hsb = new HSBType(new DecimalType(150), new PercentType(50),
        new PercentType(50));
    item.processCommand(service, hsb);

    Mockito.verify(service, Mockito.times(1)).setChannelValue(3, 65);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(4, 129);
View Full Code Here

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

      throws BindingConfigParseException {

    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);

    HSBType hsb = new HSBType(new DecimalType(150), new PercentType(50),
        new PercentType(50));
    item.processCommand(service, hsb);

    Mockito.verify(service, Mockito.times(1)).setChannelValue(3, 65);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(4, 129);
View Full Code Here

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

  @Override
  public void processCommand(DmxService service, Command command) {

    // process HSB command
    if (command instanceof HSBType) {
      HSBType hsbValue = (HSBType) command;
      setHSBValue(service, hsbValue);
      return;
    }

    // process increase/decrease
    if (command instanceof IncreaseDecreaseType
        && !isRedefinedByCustomCommand(command)
        && !service.hasChannelActions(channels[0])) {

      // rather than doing a linear fade on all channels, we fade only the
      // V part of HSV to maintain the color during the fade

      HSBType hsb = hsbState;
      int brightness = 0;
      IncreaseDecreaseType t = (IncreaseDecreaseType) command;
      if (IncreaseDecreaseType.INCREASE.equals(t)) {

        if (hsb == null) {
          hsb = new HSBType(Color.WHITE);
        }
        for (int ch : channels) {
          service.enableChannel(ch);
        }

        brightness = hsb.getBrightness().intValue();
        brightness += BRIGHTNESS_STEP_SIZE;
        if (brightness > 100) {
          brightness = 100;
        }

      } else {

        if (hsb == null) {
          hsb = new HSBType(Color.BLACK);
        }
        brightness = hsb.getBrightness().intValue();
        brightness -= BRIGHTNESS_STEP_SIZE;
        if (brightness <= 0) {
          brightness = 0;
        }
      }

      HSBType newHsb = new HSBType(hsb.getHue(), hsb.getSaturation(),
          new PercentType(brightness));
      setHSBValue(service, newHsb);
      return;
    }

    // process percent command
    if (command instanceof PercentType
        && !isRedefinedByCustomCommand(command)
        && !service.hasChannelActions(channels[0])) {
      PercentType t = (PercentType) command;

      HSBType hsb = hsbState;
      if (hsb == null) {
        hsb = new HSBType(Color.WHITE);
      }

      HSBType newHsb = new HSBType(hsb.getHue(), hsb.getSaturation(), t);
      setHSBValue(service, newHsb);
      return;
    }

    // process on/off, increase/decrease, percent type
View Full Code Here

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

    if (channelValues.length != 3 && channelValues.length != 4) {
      return;
    }

    HSBType cmd = new HSBType(
      new Color(channelValues[0], channelValues[1], channelValues[2]));
    publishState(cmd);
  }
View Full Code Here

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

    setCurrentState(bulb, bridgeId, PercentType.ZERO, BindingType.brightness);
  }
 
  private void sendColor(Command command, String bridgeId, int bulb) {
    logger.debug("milight: sendColor");
    HSBType hsbCommand = (HSBType) command;
    DecimalType hue = hsbCommand.getHue();
   
    // we have to map [0,360] to [0,0xFF], where red equals hue=0 and the milight color 0xB0 (=176)
    Integer milightColorNo = (256 + 176 - (int) (hue.floatValue() / 360.0 * 255.0)) % 256;
    try {
      if (bulb == 5) {
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.