Package org.openhab.core.library.types

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


    int percent = (int) ((100 / hmValueItem.getMaxValue().doubleValue()) * number);

    if (isRollerShutterLevelDatapoint(hmValueItem)) {
      percent = 100 - percent;
    }
    return new PercentType(percent);
  }
View Full Code Here


          State update = level == 0 ? OnOffType.OFF : OnOffType.ON;
          sendUpdate(config, update);
        } else if (type == BindingType.DIMMER
            && updateType == InsteonHubLevelUpdateType.STATUS_CHANGE) {
          // dimmer => 0-255 to percent
          State update = new PercentType(levelToPercent(level));
          sendUpdate(config, update);
        } else if (type == BindingType.INPUT_ON_OFF
            && updateType == InsteonHubLevelUpdateType.STATUS_CHANGE) {
          // on/off input => translate
          Integer onValue = config.getOnValue();
          Integer offValue = config.getOffValue();
          State update = parseDigitalUpdate(level, onValue, offValue,
              OnOffType.ON, OnOffType.OFF);
          sendUpdate(config, update);
        } else if (type == BindingType.INPUT_OPEN_CLOSED
            && updateType == InsteonHubLevelUpdateType.STATUS_CHANGE) {
          // open/closed input => translate
          Integer openValue = config.getOpenValue();
          Integer closedValue = config.getClosedValue();
          State update = parseDigitalUpdate(level, openValue,
              closedValue, OpenClosedType.OPEN,
              OpenClosedType.CLOSED);
          sendUpdate(config, update);
        } else if (type == BindingType.INPUT_UBYTE) {
          // analog byte value => 0-255
          sendUpdate(config, new DecimalType(level));
        } else if (type == BindingType.INPUT_PERCENT) {
          // analog percentage => 0-255 to percent
          sendUpdate(config, new PercentType(levelToPercent(level)));
        }
      }
    }
View Full Code Here

        return new NumberWithUnit(Unit.HUMIDITY, source.toBigDecimal());
    }

    @Override
    protected PercentType convertToImpl(NumberWithUnit source) {
        return new PercentType((BigDecimal) source.getValue());
    }
View Full Code Here

        return new NumberWithUnit(Unit.VOLTAGE, source.toBigDecimal());
    }

    @Override
    protected DecimalType convertToImpl(NumberWithUnit source) {
        return new PercentType((BigDecimal) source.getValue());
    }
View Full Code Here

        return new NumberWithUnit(Unit.WATT, source.toBigDecimal());
    }

    @Override
    protected DecimalType convertToImpl(NumberWithUnit source) {
        return new PercentType((BigDecimal) source.getValue());
    }
View Full Code Here

   * @param pt
   *            percent type to convert
   * @return converted value 0-255
   */
  public static PercentType getPercentTypeFromByte(int value) {
    return new PercentType(BigDecimal
        .valueOf(value)
        .multiply(BigDecimal.valueOf(100))
        .divide(BigDecimal.valueOf(DmxChannel.DMX_MAX_VALUE), 0,
            BigDecimal.ROUND_UP).intValue());
  }
View Full Code Here

          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);
      }
View Full Code Here

    if (!hasRunningActions()) {
      // increase channel value
      value = DmxUtil
          .capDmxValue(value
              + DmxUtil.getByteFromPercentType(new PercentType(
                  increment)));
    } else {
      // increase channel actions output
      for (BaseAction a : actions) {
        a.increase(increment);
View Full Code Here

    if (!hasRunningActions()) {
      // increase channel value
      value = DmxUtil
          .capDmxValue(value
              - DmxUtil.getByteFromPercentType(new PercentType(
                  decrement)));
    } else {
      // decrease channel actions output
      for (BaseAction a : actions) {
        a.decrease(decrement);
View Full Code Here

      // Alloe inversion of roller shutter PERCENT value
      if(converter instanceof MultiLevelPercentCommandConverter){
        logger.debug("Multilevel Switch MultiLevelPercentCommandConverter");
        if ("true".equalsIgnoreCase(arguments.get("invert_percent"))) {
          logger.debug("Multilevel Switch MultiLevelPercentCommandConverter - invert");
          command = new PercentType(100 - ((DecimalType)command).intValue());
          logger.debug("Multilevel Switch MultiLevelPercentCommandConverter - inverted: {}", command);
        }
      }
     
View Full Code Here

TOP

Related Classes of org.openhab.core.library.types.PercentType

Copyright © 2018 www.massapicom. 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.