Package org.openhab.core.items

Examples of org.openhab.core.items.Item


        }
    }

    private void queryAndSendActualState(EnoceanBindingProvider provider, String itemName) {
        EnoceanParameterAddress parameterAddress = provider.getParameterAddress(itemName);
        Item item = provider.getItem(itemName);
        if (item == null) {
            logger.warn("No item found for " + parameterAddress + " - doing nothing.");
            return;
        }
        State value = getValueFromDevice(parameterAddress, item);
View Full Code Here


        } else if (profiles.containsKey(parameterAddress.getChannelAsString())) {
            profile = profiles.get(parameterAddress.getChannelAsString());
        } else if (profiles.containsKey(parameterAddress.getDeviceAsString())) {
            profile = profiles.get(parameterAddress.getDeviceAsString());
        } else {
            Item item = getItemForParameter(parameterAddress);
            profile = new StandardProfile(item, eventPublisher);
            addProfile(item, parameterAddress, profile);
        }
        profile.valueChanged(parameterAddress, valueObject);
    }
View Full Code Here

    logger.debug("internalReceiveCommand() is called!!! {} {} ", itemName,
        command);
    if (omniWorker != null && omniWorker.isConnected()) {
      for (OmniLinkBindingProvider provider : providers) {
        OmniLinkBindingConfig config = provider.getOmniLinkBindingConfig(itemName);
        Item item = provider.getItem(itemName);
        List<OmniLinkControllerCommand> commands = OmniLinkCommandMapper.getCommand(item, config, command);
       
        /*
         * send each command we get back
         */
 
View Full Code Here

  protected void updateItemsForDevice(OmnilinkDevice device) {
    for (OmniLinkBindingProvider provider : providers) {
      for (String itemName : provider.getItemNames()) {
        OmniLinkBindingConfig bindingConfig = provider.getOmniLinkBindingConfig(itemName);
        OmnilinkDevice itemDevice = bindingConfig.getDevice();
        Item item = provider.getItem(itemName);
        if (itemDevice != null && itemDevice == device) {
          device.updateItem(item, bindingConfig, eventPublisher);
        }
      }
    }
View Full Code Here

  static public Object sendCommand(String itemName, String commandString) {
    ItemRegistry registry = (ItemRegistry) ScriptActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ScriptActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandString);
        publisher.sendCommand(itemName, command);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
View Full Code Here

  static public Object postUpdate(String itemName, String stateString) {
    ItemRegistry registry = (ItemRegistry) ScriptActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ScriptActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateString);
        publisher.postUpdate(itemName, state);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
View Full Code Here

    }

    public void receiveCommand(String itemName, Command command) {
      if(triggerManager!=null && itemRegistry!=null) {
        try {
          Item item = itemRegistry.getItem(itemName);
          Iterable<Rule> rules = triggerManager.getRules(COMMAND, item, command);
          RuleEvaluationContext context = new RuleEvaluationContext();
          context.newValue(QualifiedName.create(RuleContextHelper.VAR_RECEIVED_COMMAND), command);
          executeRules(rules, context);
        } catch (ItemNotFoundException e) {
View Full Code Here

          State value = UnDefType.UNDEF;

          try {
            if (owc.exists("/" + sensorId)) {
              int attempt = 1;
              Item item = provider.getItem(itemName);
              while (value == UnDefType.UNDEF && attempt <= retry) {
                String valueString = owc.read(sensorId + "/" + unitId);
                logger.debug("{}: Read value '{}' from {}/{}, attempt={}",
                    new Object[] { itemName, valueString, sensorId, unitId, attempt });
                if (valueString != null) {
                  if (item instanceof ContactItem) {
                    value = valueString.trim().equals("1") ? OpenClosedType.CLOSED : OpenClosedType.OPEN;
                  } else if (item instanceof SwitchItem) {
                    value = valueString.trim().equals("1") ? OnOffType.ON : OnOffType.OFF;
                  } else if (item instanceof NumberItem) {
                    value = new DecimalType(Double.valueOf(valueString));
                    if (filter != null) {
                      value = filter.filter((DecimalType)value);
                    }
                  } else {
                    throw new IllegalStateException(
                      "The item with name " + itemName + " is not a valid type.");
                  }
                }
                attempt++;
              }
            } else {
              logger.info("there is no sensor for path {}",
                  sensorId);
            }

            logger.debug("Found sensor {} with value {}", sensorId, value);
          } catch (OwfsException oe) {
            logger.warn("couldn't read from path {}", sensorId);
            if (logger.isDebugEnabled()) {
              logger.debug("reading from path " + sensorId + " throws exception", oe);
            }
          } catch (IOException ioe) {
            logger.error(
                "couldn't establish network connection while reading '"  + sensorId + "'", ioe);
          } finally {
            Item item = provider.getItem(itemName);
            if (item != null) {
              synchronized (item) {
                if (!item.getState().equals(value)) {
                  eventPublisher.postUpdate(itemName, value);
                }
              }
            }
          }
View Full Code Here

   *        listeners. These devices are marked with poll "true" flag.
   */
  protected void updateItemValues(TinkerforgeBindingProvider provider, String itemName,
      boolean only_poll_enabled) {
    String deviceUid = provider.getUid(itemName);
    Item item = provider.getItem(itemName);
    String deviceSubId = provider.getSubId(itemName);
    String deviceName = provider.getName(itemName);
    if (deviceName != null) {
      String[] ids = getDeviceIdsForDeviceName(deviceName);
      deviceUid = ids[0];
View Full Code Here

              String deviceCmd = commandParts[1];
              String deviceId = commandParts[0];

              if (deviceId.equals(devicename) && deviceCmd.equals("BROWSER_URL")) {
                try {
                  Item i = itemregistry.getItem(itemName);
                  State state = i.getState();
                  String va = state.toString();
                  out.print(va);

                } catch (ItemNotFoundException e) {
                  logger.error("item not found");
View Full Code Here

TOP

Related Classes of org.openhab.core.items.Item

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.