Package org.openhab.core.library.types

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


    logger.debug("milight: sendCooler");
    int newPercent = getCurrentState(bulb, bridgeId, BindingType.brightness).intValue() - 10;
    if(newPercent < 0) {
      newPercent = 0;
    }
    PercentType newValue = new PercentType(newPercent);
    String messageBytes = "3F:00:55";
    sendMessage(messageBytes, bridgeId);
    setCurrentState(bulb, bridgeId, newValue, BindingType.brightness);
    return newValue;
  }
View Full Code Here


    DmxService service = Mockito.mock(DmxService.class);

    Mockito.when(service.getChannelValue(3)).thenReturn(0);
    Mockito.when(service.getChannelValue(4)).thenReturn(155);

    item.processCommand(service, new PercentType(0));
    Mockito.verify(service).setChannelValue(3, DmxChannel.DMX_MAX_VALUE);
    Mockito.verify(service).setChannelValue(3, PercentType.ZERO);
    Mockito.verify(service).setChannelValue(4, DmxChannel.DMX_MAX_VALUE);
    Mockito.verify(service).setChannelValue(4, PercentType.ZERO);
  }
View Full Code Here

        index = Integer.parseInt(data);
        state = new DecimalType(index);

      } else if (itemType == DimmerItem.class) {
        index = Integer.parseInt(data);
        state = new PercentType(index);

      } else if (itemType == RollershutterItem.class) {
        index = Integer.parseInt(data);
        state = new PercentType(index);

      } else if (itemType == StringItem.class) {
        // s = data.substring(3, data.length());
        state = new StringType(data);
      }
View Full Code Here

        State powerUpdate = state.isPower() ? OnOffType.ON : OnOffType.OFF;
        State muteUpdate = state.isMute() ? OnOffType.ON : OnOffType.OFF;
        State inputUpdate = new StringType(state.getInput());
        State surroundUpdate = new StringType(state.getSurroundProgram());
        State updateVolumeDb = new DecimalType(state.getVolume());
        State updateVolumePercent = new PercentType(
            (int) dbToPercent(state.getVolume()));
 
        // Send updates
        sendUpdate(configs, zone, BindingType.power, powerUpdate);
        sendUpdate(configs, zone, BindingType.mute, muteUpdate);
View Full Code Here

      // get the player id and make a new request for the media details
      Map<String, Object> params = RpcCall.getMap(json, "params");
      Map<String, Object> data = RpcCall.getMap(params, "data");
     
      Object o = data.get("volume");
      PercentType volume = new PercentType(0);
     
       if (o instanceof Integer) {
        volume = new PercentType((Integer)o);
      }
      else {
        if (o instanceof Double) {
          volume = new PercentType(((Double)o).intValue());
        }
      }
      
      updateProperty("Application.Volume", volume);
      this.volume = new BigDecimal(volume.intValue());
    }

  }
View Full Code Here

   
    app.execute(new Runnable() {
      public void run() {
        // now update each of the openHAB items for each property
        volume = new BigDecimal(app.getVolume());
        updateProperty("Application.Volume", new PercentType(volume));               
      }
    });

  }
View Full Code Here

      }
    }
  }

  private void updateProperty(String property, PercentType value) {
    value = (value == null ? new PercentType(0) : value);
   
    for (Entry<String, String> e : watches.entrySet()) {
      if (property.equals(e.getValue())) {
        eventPublisher.postUpdate(e.getKey(), value);
      }
View Full Code Here

  }

  @Test
  public void testPercentTypeConverterFromBinding() throws Exception {
    PercentTypeConverter converter = new PercentTypeConverter();
    Assert.assertEquals(new PercentType(100), converter.convertFromBinding(getDatapoint("PRESS_SHORT", 1, 0, 1)));
    Assert.assertEquals(new PercentType(0), converter.convertFromBinding(getDatapoint("PRESS_SHORT", 0, 0, 1)));

    Assert.assertEquals(new PercentType(100), converter.convertFromBinding(getDatapoint("PRESS_SHORT", true, 0, 1)));
    Assert.assertEquals(new PercentType(100), converter.convertFromBinding(getDatapoint("PRESS_SHORT", true, 0, 5)));
    Assert.assertEquals(new PercentType(100),
        converter.convertFromBinding(getDatapoint("PRESS_SHORT", true, 0.0, 5.4)));
    Assert.assertEquals(new PercentType(0), converter.convertFromBinding(getDatapoint("PRESS_SHORT", false, 0, 1)));

    Assert.assertEquals(new PercentType(100), converter.convertFromBinding(getDatapoint("SENSOR", 1, 0, 1)));
    Assert.assertEquals(new PercentType(0), converter.convertFromBinding(getDatapoint("SENSOR", 0, 0, 1)));

    Assert.assertEquals(new PercentType(100), converter.convertFromBinding(getDatapoint("LEVEL", 1.0, 0.0, 1.0)));
    Assert.assertEquals(new PercentType(100), converter.convertFromBinding(getDatapoint("LEVEL", 3.4, 0.0, 3.4)));

    Assert.assertEquals(new PercentType(40), converter.convertFromBinding(getDatapoint("LEVEL", 0.4, 0.0, 1.0)));
    Assert.assertEquals(new PercentType(80), converter.convertFromBinding(getDatapoint("LEVEL", 0.8, 0.0, 1.0)));

    Assert.assertEquals(new PercentType(60), converter.convertFromBinding(getRollerShutterDatapoint("LEVEL", 0.4)));
    Assert.assertEquals(new PercentType(20), converter.convertFromBinding(getRollerShutterDatapoint("LEVEL", 0.8)));

    Assert.assertEquals(new PercentType(20), converter.convertFromBinding(getDatapoint("LEVEL", 50, 0, 250)));
    Assert.assertEquals(new PercentType(20), converter.convertFromBinding(getDatapoint("LEVEL", 50.0, 0.0, 250.0)));

    Assert.assertEquals(new PercentType(20), converter.convertFromBinding(getDatapoint("LEVEL", "50", 0, 250)));
    Assert.assertEquals(new PercentType(20),
        converter.convertFromBinding(getDatapoint("LEVEL", "50.0", 0.0, 250.0)));
  }
View Full Code Here

  @Test
  public void testPercentTypeConverterToBinding() throws Exception {
    PercentTypeConverter converter = new PercentTypeConverter();

    Assert.assertEquals(true,
        converter.convertToBinding(new PercentType(100), getDatapoint("PRESS_SHORT", true, 0, 1)));
    Assert.assertEquals(false,
        converter.convertToBinding(new PercentType(0), getDatapoint("PRESS_SHORT", false, 0, 1)));

    Assert.assertEquals(1, converter.convertToBinding(new PercentType(100), getDatapoint("SENSOR", 1, 0, 1)));
    Assert.assertEquals(0, converter.convertToBinding(new PercentType(0), getDatapoint("SENSOR", 0, 0, 1)));

    Assert.assertEquals(0.5, converter.convertToBinding(new PercentType(50), getDatapoint("LEVEL", 0.0, 0, 1)));
    Assert.assertEquals(0.2, converter.convertToBinding(new PercentType(20), getDatapoint("LEVEL", 0.0, 0, 1)));
    Assert.assertEquals(50, converter.convertToBinding(new PercentType(20), getDatapoint("LEVEL", 0, 0, 250)));
    Assert.assertEquals(50, converter.convertToBinding(new PercentType(20), getDatapoint("LEVEL", 0, 0, 250)));

    Assert.assertEquals("50.0",
        converter.convertToBinding(new PercentType(20), getDatapoint("LEVEL", "text", 0, 250)));
    Assert.assertEquals("50.0",
        converter.convertToBinding(new PercentType(20), getDatapoint("LEVEL", "text", 0, 250)));

    Assert.assertEquals(0.0,
        converter.convertToBinding(new PercentType(100), getRollerShutterDatapoint("LEVEL", 0.0)));
    Assert.assertEquals(1.0,
        converter.convertToBinding(new PercentType(0), getRollerShutterDatapoint("LEVEL", 0.0)));
    Assert.assertEquals(0.2,
        converter.convertToBinding(new PercentType(80), getRollerShutterDatapoint("LEVEL", 0.0)));

    Assert.assertEquals(0.0,
        converter.convertToBinding(IncreaseDecreaseType.INCREASE, getRollerShutterDatapoint("LEVEL", 0.1)));
    Assert.assertEquals(0.3,
        converter.convertToBinding(IncreaseDecreaseType.DECREASE, getRollerShutterDatapoint("LEVEL", 0.2)));
View Full Code Here

        if (command.equals(IncreaseDecreaseType.DECREASE))
          volume = Math.max(0, volume - 5);
        logger.debug("setting " + audioItemName + " volume to "
            + volume);
        client.setVolumePercent(audioItem, volume);
        updateState = new PercentType(volume);
      } else if (command instanceof PercentType) {
        client.setVolumePercent(audioItem,
            Integer.valueOf(command.toString()));
        updateState = (PercentType) command;
      } else if (command instanceof DecimalType) {
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.