Package org.openhab.core.types

Examples of org.openhab.core.types.State


  /**
   * @{inheritDoc
   */
  @Override
  public State getStateAs(Class<? extends State> typeClass) {
    State newState = function.getStateAs(getAllMembers(), typeClass);
    if(newState==null && baseItem!=null) {
      // we use the transformation method from the base item
      baseItem.setState(state);
      newState = baseItem.getStateAs(typeClass);
    }
View Full Code Here


    /**
     * @{inheritDoc
     */
    public State calculate(List<Item> items) {
      if(items.size()>0) {
        State state = items.get(0).getState();
        for(int i=1; i<items.size(); i++) {
          if(!state.equals(items.get(i).getState())) {
            return UnDefType.UNDEF;
          }
        }
        return state;
      } else {
View Full Code Here

    /**
     * @{inheritDoc
     */
    public State getStateAs(List<Item> items,
        Class<? extends State> stateClass) {
      State state = calculate(items);
      if(stateClass.isInstance(state)) {
        return state;
      } else {
        return null;
      }
View Full Code Here

      // Can't get the state at the start time
      // If we've got results more recent that this, it must have changed
      return(it.hasNext());
    }

    State state = itemThen.getState();
    while(it.hasNext()) {
      HistoricItem hItem = it.next();
      if(state!=null && !hItem.getState().equals(state)) {
        return true;
      }
View Full Code Here

    Iterator<HistoricItem> it = result.iterator();
    HistoricItem maximumHistoricItem = null;
    DecimalType maximum = (DecimalType) item.getStateAs(DecimalType.class);
    while(it.hasNext()) {
      HistoricItem historicItem = it.next();
      State state = historicItem.getState();
      if (state instanceof DecimalType) {
        DecimalType value = (DecimalType) state;
        if(maximum==null || value.compareTo(maximum)>0) {
          maximum = value;
          maximumHistoricItem = historicItem;
View Full Code Here

    Iterator<HistoricItem> it = result.iterator();
    HistoricItem minimumHistoricItem = null;
    DecimalType minimum = (DecimalType) item.getStateAs(DecimalType.class);
    while(it.hasNext()) {
      HistoricItem historicItem = it.next();
      State state = historicItem.getState();
      if (state instanceof DecimalType) {
        DecimalType value = (DecimalType) state;
        if(minimum==null || value.compareTo(minimum)<0) {
          minimum = value;
          minimumHistoricItem = historicItem;
View Full Code Here

    }
   
    double average = value.doubleValue();
    int quantity = 1;
    while(it.hasNext()) {
      State state = it.next().getState();
      if (state instanceof DecimalType) {
        value = (DecimalType) state;
        average += value.doubleValue();
        quantity++;
      }
View Full Code Here

    @PUT @Path("/{itemname: [a-zA-Z_0-9]*}/state")
  @Consumes(MediaType.TEXT_PLAIN
  public Response putItemState(@PathParam("itemname") String itemname, String value) {
      Item item = getItem(itemname);
      if(item!=null) {
        State state = TypeParser.parseState(item.getAcceptedDataTypes(), value);
        if(state!=null) {
          logger.debug("Received HTTP PUT request at '{}' with value '{}'.", uriInfo.getPath(), value);
          RESTApplication.getEventPublisher().postUpdate(itemname, state);
          return Response.ok().build();
        } else {
View Full Code Here

   */
  private void postUpdate(Configuration config, ConfigAdminBindingConfig bindingConfig) {
    if (config != null) {
      String stateAsString = (String) config.getProperties().get(bindingConfig.configParameter);
      if (StringUtils.isNotBlank(stateAsString)) {
        State state = createState(bindingConfig.item, stateAsString);
        eventPublisher.postUpdate(bindingConfig.item.getName(), state);
      } else {
        logger.debug("config parameter '{}:{}' has value 'null'. It won't be posted to the event bus hence.",
            bindingConfig.normalizedPid, bindingConfig.configParameter);
      }
View Full Code Here

  }
 
  private GroupItem applyGroupFunction(GenericItem baseItem, ModelGroupItem modelGroupItem, ModelGroupFunction function) {
    List<State> args = new ArrayList<State>();
    for (String arg : modelGroupItem.getArgs()) {
      State state = TypeParser.parseState(baseItem.getAcceptedDataTypes(), arg);
      if (state == null) {
        logger.warn("State '{}' is not valid for group item '{}' with base type '{}'",
          new Object[]{arg, modelGroupItem.getName(), modelGroupItem.getType()});
        args.clear();
        break;
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.