use of org.openhab.core.library.items.NumberItem in project openhab1-addons by openhab.
the class AbstractDynamoDBItemSerializationTest method testPercentTypeWithNumberItem.
@Test
public void testPercentTypeWithNumberItem() throws IOException {
DynamoDBItem<?> dbitem = testStateGeneric(new PercentType(new BigDecimal(3.2)), new BigDecimal(3.2));
// note: comes back as DecimalType instead of the original PercentType
testAsHistoricGeneric(dbitem, new NumberItem("foo"), new DecimalType(new BigDecimal(3.2)));
}
use of org.openhab.core.library.items.NumberItem in project openhab1-addons by openhab.
the class EnergenieGenericBindingProvider method processBindingConfiguration.
/**
* {@inheritDoc}
*/
@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 (configParts.length < 2 || configParts.length > 2) {
throw new BindingConfigParseException("energenie binding configuration must have 2 parts");
}
String itemType = item.toString();
if (item instanceof SwitchItem) {
if ((configParts[1].equals("1")) || (configParts[1].equals("2")) || (configParts[1].equals("3")) || (configParts[1].equals("4"))) {
BindingConfig energenieBindingConfig = new EnergenieBindingConfig(configParts[0], configParts[1], itemType);
addBindingConfig(item, energenieBindingConfig);
} else {
throw new BindingConfigParseException("Your SwitchItem configuration does not contain channelNumbers");
}
} else if (item instanceof NumberItem) {
ChannelTypeDef channelType = ChannelTypeDef.valueOf(configParts[1].trim());
if (channelType != null) {
BindingConfig energenieBindingConfig = new EnergenieBindingConfig(configParts[0], configParts[1], itemType);
addBindingConfig(item, energenieBindingConfig);
} else {
throw new BindingConfigParseException("Your NumberItem configuration does not contain channelTypes");
}
}
} else {
logger.warn("bindingConfig is NULL (item=" + item + ") -> processing bindingConfig aborted!");
}
} catch (ArrayIndexOutOfBoundsException e) {
logger.warn("bindingConfig is invalid (item=" + item + ") -> processing bindingConfig aborted!");
}
}
use of org.openhab.core.library.items.NumberItem in project openhab1-addons by openhab.
the class TemperatureSensorTest method testReceiveTempertureUpdate.
@Test
public void testReceiveTempertureUpdate() {
parameterAddress = new EnoceanParameterAddress(EnoceanId.fromString(EnoceanBindingProviderMock.DEVICE_ID), Parameter.TEMPERATURE);
provider.setParameterAddress(parameterAddress);
binding.addBindingProvider(provider);
provider.setItem(new NumberItem("dummie"));
BigDecimal temperature = new BigDecimal("20.3");
binding.valueChanged(parameterAddress, new NumberWithUnit(Unit.DEGREE_CELSIUS, temperature));
assertEquals("Update State", new DecimalType(temperature), publisher.getUpdateState());
}
use of org.openhab.core.library.items.NumberItem in project openhab1-addons by openhab.
the class LightwaveRfBindingFunctionalTest method testWifiLinkStatusReceived.
@Test
public void testWifiLinkStatusReceived() throws Exception {
String message = "*!{\"trans\":452,\"mac\":\"ab:cd:ef\",\"time\":1447712274,\"type\":\"hub\",\"prod\":\"wfl\",\"fw\":\"U2.91Y\"," + "\"uptime\":1386309,\"timeZone\":0,\"lat\":52.48,\"long\":-87.89,\"duskTime\":1447690400," + "\"dawnTime\":1447659083,\"tmrs\":0,\"evns\":1,\"run\":0,\"macs\":8,\"ip\":\"192.168.0.1\",\"devs\":0}";
List<ItemConfigAndExpectedState> itemConfigAndExpectedStates = new LinkedList<ItemConfigAndExpectedState>();
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new StringItem("WIFILINK_IP"), "serial=wifilink,type=WIFILINK_IP", new StringType("192.168.0.1")));
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new StringItem("WIFILINK_FIRMWARE"), "serial=wifilink,type=WIFILINK_FIRMWARE", new StringType("U2.91Y")));
Calendar duskCal = Calendar.getInstance();
duskCal.setTime(new Date(1447690400000L));
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new DateTimeItem("WIFILINK_DUSK_TIME"), "serial=wifilink,type=WIFILINK_DUSK_TIME", new DateTimeType(duskCal)));
Calendar dawnCal = Calendar.getInstance();
dawnCal.setTime(new Date(1447659083000L));
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new DateTimeItem("WIFILINK_DAWN_TIME"), "serial=wifilink,type=WIFILINK_DAWN_TIME", new DateTimeType(dawnCal)));
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new NumberItem("WIFILINK_UPTIME"), "serial=wifilink,type=WIFILINK_UPTIME", new DecimalType("1386309")));
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new StringItem("WIFILINK_LONGITUDE"), "serial=wifilink,type=WIFILINK_LONGITUDE", new StringType("-87.89")));
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new StringItem("WIFILINK_LATITUDE"), "serial=wifilink,type=WIFILINK_LATITUDE", new StringType("52.48")));
Calendar cal = Calendar.getInstance();
cal.setTime(new Date(1447712274000L));
itemConfigAndExpectedStates.add(new ItemConfigAndExpectedState(new NumberItem("TIME"), "serial=wifilink,type=UPDATETIME", new DateTimeType(cal)));
testReceivingACommandAndVerify(itemConfigAndExpectedStates, message);
}
use of org.openhab.core.library.items.NumberItem in project openhab1-addons by openhab.
the class LightwaveRfGenericBindingProviderTest method testProcessBindingConfigurationForHeatingBattery.
@Test
public void testProcessBindingConfigurationForHeatingBattery() throws Exception {
LightwaveRfGenericBindingProvider bingindProvider = new LightwaveRfGenericBindingProvider();
bingindProvider.processBindingConfiguration(context, new NumberItem("MyBattery"), "room=3,device=4,type=HEATING_BATTERY");
assertEquals(Arrays.asList("MyBattery"), bingindProvider.getBindingItemsForRoomDevice("3", "4"));
assertEquals(Arrays.asList("MyBattery"), bingindProvider.getItemNames());
assertEquals("3", bingindProvider.getRoomId("MyBattery"));
assertEquals("4", bingindProvider.getDeviceId("MyBattery"));
assertEquals(LightwaveRfType.HEATING_BATTERY, bingindProvider.getTypeForItemName("MyBattery"));
}
Aggregations