Examples of PercentType


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

      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);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(5, 97);
View Full Code Here

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

      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);
    Mockito.verify(service, Mockito.times(1)).setChannelValue(5, 97);
View Full Code Here

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

  @Test
  public void canBeSetWith0PercentType() throws BindingConfigParseException {

    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);
    item.processCommand(service, new PercentType(0));
    Mockito.verify(service).setChannelValue(3, 0);
    Mockito.verify(service).setChannelValue(4, 0);
    Mockito.verify(service).setChannelValue(5, 0);
  }
View Full Code Here

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

  @Test
  public void canBeSetWithPercentType() throws BindingConfigParseException {

    DmxItem item = getValidInstance();
    DmxService service = Mockito.mock(DmxService.class);
    item.processCommand(service, new PercentType(50));
    Mockito.verify(service).setChannelValue(3, 129);
    Mockito.verify(service).setChannelValue(4, 129);
    Mockito.verify(service).setChannelValue(5, 129);
  }
View Full Code Here

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

   * @return converted value 0-31
   */
  public static PercentType getPercentTypeFromDimLevel(int value) {
    value = Math.min(value, 31);
   
    return new PercentType(BigDecimal
        .valueOf(value)
        .multiply(BigDecimal.valueOf(100))
        .divide(BigDecimal.valueOf(31), 0,
            BigDecimal.ROUND_UP).intValue());
  }
View Full Code Here

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

 
  @Test
  public void canSendGroup1DimmerUpdate() throws Exception {

    ModuleChannel item = group1.addChannel("test4", 4, new ArrayList<Class<? extends Command>>());
    item.setState(new PercentType(25));

    group1.publishStateToNikobus(item, binding);

    Mockito.verify(binding, Mockito.times(1)).sendCommand(
        command.capture());
View Full Code Here

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

      if (device != null) {

        State state = null;
        if (item instanceof DimmerItem) {
          state = new PercentType(
              getPercent(device.getMaxOutPutValue(),
                  device.getOutputValue()));

        } else if (item instanceof SwitchItem
            && !(item instanceof DimmerItem)) {

          state = device.getOutputValue() > 0 ? OnOffType.ON
              : OnOffType.OFF;
        } else if (item instanceof NumberItem) {

          DigitalSTROMBindingConfig confItem = getConfigForItemName(item
              .getName());
          if (confItem != null) {
            if (confItem.consumption != null) {

              int value = -1;
              switch (confItem.consumption) {

              case ACTIVE_POWER:
                value = device.getPowerConsumption();

                if (value != -1) {
                  state = new DecimalType(value);
                }
                break;
              case OUTPUT_CURRENT:
                value = device.getEnergyMeterValue();

                if (value != -1) {
                  state = new DecimalType(value);
                }
                break;
              default:
                break;

              }
            }
          }
        } else if (item instanceof RollershutterItem) {

          DigitalSTROMBindingConfig confItem = getConfigForItemName(item
              .getName());
          if (confItem != null) {

            if (confItem.context != null
                && confItem.context.equals(ContextConfig.slat)) {

              int output = getPercent(
                  device.getMaxSlatPosition(),
                  device.getSlatPosition());

              state = new PercentType(100 - output);
            } else if (confItem.context != null
                && confItem.context
                    .equals(ContextConfig.awning)) {

              int output = getPercent(device.getMaxOutPutValue(),
                  device.getOutputValue());

              state = new PercentType(output);
            } else {
              int output = getPercent(device.getMaxOutPutValue(),
                  device.getOutputValue());

              state = new PercentType(100 - output);
            }
          }
        } else if (item instanceof StringItem) {
          DigitalSTROMBindingConfig confItem = getConfigForItemName(item
              .getName());
View Full Code Here

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

   * Converts different openHAB commands to a Homematic object.
   */
  @Override
  public Object commandToBinding(Command command, HmValueItem hmValueItem) {
    if (command.getClass() == IncreaseDecreaseType.class) {
      PercentType type = convertFromBinding(hmValueItem);

      int percent = type.intValue();
      percent += command.equals(IncreaseDecreaseType.INCREASE) ? 10 : -10;
      percent = (percent / 10) * 10;
      percent = Math.min(100, percent);
      percent = Math.max(0, percent);
      return convertToBinding(new PercentType(percent), hmValueItem);
    } else if (command.getClass() == OnOffType.class) {
      PercentType type = new PercentType(command.equals(OnOffType.ON) ? 100 : 0);
      return convertToBinding(type, hmValueItem);
    } else if (command.getClass() == UpDownType.class) {
      int result = command.equals(UpDownType.UP) ? 100 : 0;
      if (isRollerShutterLevelDatapoint(hmValueItem)) {
        result = command.equals(UpDownType.UP) ? 0 : 100;
      }
      return convertToBinding(new PercentType(result), hmValueItem);
    } else {
      return super.commandToBinding(command, hmValueItem);
    }
  }
View Full Code Here

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

  /**
   * Creates a PercentType from the value.
   */
  protected PercentType createType(BigDecimal value) {
    return new PercentType(value);
  }
View Full Code Here

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

  /**
   * {@inheritDoc}
   */
  @Override
  protected PercentType fromBoolean(HmValueItem hmValueItem) {
    return Boolean.TRUE.equals(hmValueItem.getValue()) ? new PercentType(100) : new PercentType(0);
  }
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.