Search in sources :

Example 6 with ColorItem

use of org.openhab.core.library.items.ColorItem in project openhab1-addons by openhab.

the class ColorItemIntegrationTest method storeData.

@BeforeClass
public static void storeData() throws InterruptedException {
    ColorItem item = (ColorItem) items.get(name);
    item.setState(state1);
    beforeStore = new Date();
    Thread.sleep(10);
    service.store(item);
    afterStore1 = new Date();
    Thread.sleep(10);
    item.setState(state2);
    service.store(item);
    Thread.sleep(10);
    afterStore2 = new Date();
    logger.info("Created item between {} and {}", AbstractDynamoDBItem.DATEFORMATTER.format(beforeStore), AbstractDynamoDBItem.DATEFORMATTER.format(afterStore1));
}
Also used : ColorItem(org.openhab.core.library.items.ColorItem) Date(java.util.Date) BeforeClass(org.junit.BeforeClass)

Example 7 with ColorItem

use of org.openhab.core.library.items.ColorItem in project openhab1-addons by openhab.

the class AbstractDynamoDBItemSerializationTest method testPercentTypeWithColorItem.

@Test
public void testPercentTypeWithColorItem() throws IOException {
    DynamoDBItem<?> dbitem = testStateGeneric(new PercentType(new BigDecimal(3.2)), new BigDecimal(3.2));
    testAsHistoricGeneric(dbitem, new ColorItem("foo"), new PercentType(new BigDecimal(3.2)));
}
Also used : ColorItem(org.openhab.core.library.items.ColorItem) PercentType(org.openhab.core.library.types.PercentType) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 8 with ColorItem

use of org.openhab.core.library.items.ColorItem in project openhab1-addons by openhab.

the class AbstractDynamoDBItemSerializationTest method testOnOffTypeWithColorItem.

@Test
public void testOnOffTypeWithColorItem() throws IOException {
    DynamoDBItem<?> dbitemOff = testStateGeneric(OnOffType.OFF, BigDecimal.ZERO);
    testAsHistoricGeneric(dbitemOff, new ColorItem("foo"), new PercentType(BigDecimal.ZERO));
    DynamoDBItem<?> dbitemOn = testStateGeneric(OnOffType.ON, BigDecimal.ONE);
    testAsHistoricGeneric(dbitemOn, new ColorItem("foo"), new PercentType(BigDecimal.ONE));
}
Also used : ColorItem(org.openhab.core.library.items.ColorItem) PercentType(org.openhab.core.library.types.PercentType) Test(org.junit.Test)

Example 9 with ColorItem

use of org.openhab.core.library.items.ColorItem in project openhab1-addons by openhab.

the class MqttMessageSubscriberTest method canParseCommand.

@Test
public void canParseCommand() throws Exception {
    ColorItem colorItem = new ColorItem("ColorItem");
    DimmerItem dimmerItem = new DimmerItem("DimmerItem");
    LocationItem locationItem = new LocationItem("LocationItem");
    NumberItem numberItem = new NumberItem("NumberItem");
    RollershutterItem rollershutterItem = new RollershutterItem("SetpointItem");
    StringItem stringItem = new StringItem("StringItem");
    SwitchItem switchItem = new SwitchItem("SwitchItem");
    MqttMessageSubscriber subscriber = new MqttMessageSubscriber("mybroker:/mytopic:command:default");
    assertEquals(StringType.valueOf("test"), subscriber.getCommand("test", stringItem.getAcceptedCommandTypes()));
    assertEquals(StringType.valueOf("{\"person\"{\"name\":\"me\"}}"), subscriber.getCommand("{\"person\"{\"name\":\"me\"}}", stringItem.getAcceptedCommandTypes()));
    assertEquals(StringType.valueOf(""), subscriber.getCommand("", stringItem.getAcceptedCommandTypes()));
    assertEquals(OnOffType.ON, subscriber.getCommand("ON", switchItem.getAcceptedCommandTypes()));
    assertEquals(HSBType.valueOf("5,6,5"), subscriber.getCommand("5,6,5", colorItem.getAcceptedCommandTypes()));
    assertEquals(DecimalType.ZERO, subscriber.getCommand(DecimalType.ZERO.toString(), numberItem.getAcceptedCommandTypes()));
    assertEquals(PercentType.HUNDRED, subscriber.getCommand(PercentType.HUNDRED.toString(), dimmerItem.getAcceptedCommandTypes()));
    assertEquals(PercentType.valueOf("80"), subscriber.getCommand(PercentType.valueOf("80").toString(), rollershutterItem.getAcceptedCommandTypes()));
    assertEquals(PointType.valueOf("53.3239919,-6.5258807"), subscriber.getCommand(PointType.valueOf("53.3239919,-6.5258807").toString(), locationItem.getAcceptedCommandTypes()));
}
Also used : NumberItem(org.openhab.core.library.items.NumberItem) LocationItem(org.openhab.core.library.items.LocationItem) DimmerItem(org.openhab.core.library.items.DimmerItem) RollershutterItem(org.openhab.core.library.items.RollershutterItem) ColorItem(org.openhab.core.library.items.ColorItem) StringItem(org.openhab.core.library.items.StringItem) SwitchItem(org.openhab.core.library.items.SwitchItem) Test(org.junit.Test)

Example 10 with ColorItem

use of org.openhab.core.library.items.ColorItem in project openhab1-addons by openhab.

the class HueGenericBindingProvider method processBindingConfiguration.

@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
    super.processBindingConfiguration(context, item, bindingConfig);
    try {
        if (bindingConfig != null) {
            String[] configParts = bindingConfig.split(";");
            if (item instanceof ColorItem) {
                BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], BindingType.rgb.name(), null);
                addBindingConfig(item, hueBindingConfig);
            } else if (item instanceof DimmerItem) {
                BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], configParts.length < 2 ? null : configParts[1], configParts.length < 3 ? null : configParts[2]);
                addBindingConfig(item, hueBindingConfig);
            } else if (item instanceof SwitchItem) {
                BindingConfig hueBindingConfig = new HueBindingConfig(configParts[0], BindingType.switching.name(), null);
                addBindingConfig(item, hueBindingConfig);
            }
        } else {
            logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!");
        }
    } catch (ArrayIndexOutOfBoundsException e) {
        logger.warn("bindingConfig is invalid (item=" + item + ") -> processing bindingConfig aborted!");
    }
}
Also used : BindingConfig(org.openhab.core.binding.BindingConfig) DimmerItem(org.openhab.core.library.items.DimmerItem) ColorItem(org.openhab.core.library.items.ColorItem) SwitchItem(org.openhab.core.library.items.SwitchItem)

Aggregations

ColorItem (org.openhab.core.library.items.ColorItem)18 DimmerItem (org.openhab.core.library.items.DimmerItem)13 RollershutterItem (org.openhab.core.library.items.RollershutterItem)11 SwitchItem (org.openhab.core.library.items.SwitchItem)11 PercentType (org.openhab.core.library.types.PercentType)11 NumberItem (org.openhab.core.library.items.NumberItem)8 ContactItem (org.openhab.core.library.items.ContactItem)7 DateTimeItem (org.openhab.core.library.items.DateTimeItem)7 DecimalType (org.openhab.core.library.types.DecimalType)7 HSBType (org.openhab.core.library.types.HSBType)7 Calendar (java.util.Calendar)6 DateTimeType (org.openhab.core.library.types.DateTimeType)6 State (org.openhab.core.types.State)6 StringType (org.openhab.core.library.types.StringType)5 BigDecimal (java.math.BigDecimal)4 Test (org.junit.Test)4 Item (org.openhab.core.items.Item)4 ItemNotFoundException (org.openhab.core.items.ItemNotFoundException)4 Date (java.util.Date)3 LocationItem (org.openhab.core.library.items.LocationItem)3