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));
}
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)));
}
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));
}
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()));
}
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!");
}
}
Aggregations