Package org.openhab.core.types

Examples of org.openhab.core.types.State


  public void publishChangedItemToOpenhab(Item item, HomematicBindingConfig bindingConfig) {
    HmValueItem hmValueItem = context.getStateHolder().getState(bindingConfig);
    if (hmValueItem != null) {
      Converter<?> converter = context.getConverterFactory().createConverter(item, bindingConfig);
      if (converter != null) {
        State state = converter.convertFromBinding(hmValueItem);
        context.getEventPublisher().postUpdate(item.getName(), state);
      }
    } else if (bindingConfig instanceof ProgramConfig || bindingConfig instanceof ActionConfig) {
      context.getEventPublisher().postUpdate(item.getName(), OnOffType.OFF);
    } else {
View Full Code Here


      public void next(HomematicBindingConfig providerBindingConfig, Item item, Converter<?> converter) {
        if (!item.getName().equals(event.getItem().getName())) {
          if (event.isCommand()) {
            context.getEventPublisher().postCommand(item.getName(), (Command) event.getType());
          } else {
            State state = converter.convertFromBinding(event.getHmValueItem());
            context.getEventPublisher().postUpdate(item.getName(), state);
          }
        }
      }
    });
View Full Code Here

        BindingType type = config.getBindingType();
        // FIXME Currently filtering STATUS_CHANGE out for non-dimmer types b/c it's not working properly. Need to learn more.
        if (type == BindingType.SWITCH
            && updateType == InsteonHubLevelUpdateType.STATUS_CHANGE) {
          // switch => 0=OFF, else=ON
          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
View Full Code Here

            if (providerBindingConfig instanceof ProgramConfig
                || providerBindingConfig instanceof ActionConfig) {
              context.getEventPublisher().postUpdate(item.getName(), OnOffType.OFF);
            } else {
              hmValueItem.setValue(converter.convertToBinding(OnOffType.OFF, hmValueItem));
              State state = converter.convertFromBinding(hmValueItem);
              context.getEventPublisher().postUpdate(item.getName(), state);
            }
            logger.debug("Disabled Item {} with binding {}", item.getName(), providerBindingConfig);
          }
        });
View Full Code Here

                  RFXComValueSelector valueSelector = provider
                      .getValueSelector(itemName);

                  if (supportedValueSelectors.contains(valueSelector)) {
                    try {
                      State value = obj.convertToState(valueSelector);
                      eventPublisher.postUpdate(itemName, value);
                    } catch (RFXComException e) {
                      logger.warn( "Data conversion error", e);
                    }
                  }
View Full Code Here

  protected void publish(final HomematicBindingConfig bindingConfig, final HmValueItem hmValueItem) {
    new ProviderItemIterator().iterate(bindingConfig, new ProviderItemIteratorCallback() {

      @Override
      public void next(HomematicBindingConfig providerBindingConfig, Item item, Converter<?> converter) {
        State state = converter.convertFromBinding(hmValueItem);
        context.getEventPublisher().postUpdate(item.getName(), state);
      }
    });
  }
View Full Code Here

    if(itemName!=null && label.contains("[")) {
     
      int indexOpenBracket = label.indexOf("[");
      int indexCloseBracket = label.indexOf("]");
     
      State state = null;
      String formatPattern = label.substring(indexOpenBracket + 1, indexCloseBracket);
      try {
        Item item = getItem(itemName);
        // TODO: TEE: we should find a more generic solution here! When
        // using indexes in formatString this 'contains' will fail again
View Full Code Here

    else {
      // Loop through all elements looking for the definition associated
      // with the supplied value
      for (ColorArray color : colorList) {
        // Use a local state variable in case it gets overridden below
        State cmpState = state;

        if(color.getState() == null) {
          logger.error("Error parsing color");
          continue;
        }
View Full Code Here

        // Default to visible!
        return true;
      }

      // Get the item state
      State state = item.getState();

      // Handle the sign
      String value;
      if(rule.getSign() != null)
        value = rule.getSign() + rule.getState();
View Full Code Here

    List<ComfoAirCommandType> commandTypes =
      ComfoAirCommandType.getCommandTypesByReplyCmd(command.getReplyCmd());

    for (ComfoAirCommandType commandType : commandTypes) {
      ComfoAirDataType dataType = commandType.getDataType();
      State value = dataType.convertToState(response, commandType);

      if (value == null) {
        logger.error("Unexpected value for DATA: " + ComfoAirConnector.dumpData(response));
      } else {
        for (ComfoAirBindingProvider provider : providers) {
View Full Code Here

TOP

Related Classes of org.openhab.core.types.State

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.