use of org.openhab.core.items.Item in project openhab1-addons by openhab.
the class NikobusGenericBindingProviderTest method parseButton.
private void parseButton(String name, String config, Button.PressType type, String address) throws BindingConfigParseException {
Item item = new SwitchItem(name);
provider.processBindingConfiguration("context", item, config);
Button button = (Button) provider.getItemConfig(name);
assertEquals(name, button.getName());
assertEquals(address, button.getAddress());
assertEquals(type, button.getType());
}
use of org.openhab.core.items.Item in project openhab1-addons by openhab.
the class UCPRelayBoardBinding method readAndDecodeResponse.
private void readAndDecodeResponse(SerialDevice serialDevice) {
byte[] response = serialDevice.readBytes(new byte[5]);
if (validateResponse(response)) {
for (int relay = 0; relay < 8; relay++) {
Item item = getItemForRelay(serialDevice, relay);
if (item != null) {
UCPRelayConfig config = getRelayConfigForItem(item.getName());
State state = getRelayState(response, relay, config);
eventPublisher.postUpdate(item.getName(), state);
}
}
}
}
use of org.openhab.core.items.Item in project openhab1-addons by openhab.
the class DSCAlarmActiveBinding method processUpdateMap.
/**
* Processes the Update Items Map
*/
private void processUpdateMap() {
if (dscAlarmUpdateMap.size() == 0) {
logger.debug("processUpdateMap(): Nothing to update.");
return;
}
Map<String, DSCAlarmBindingConfig> itemsMap = new HashMap<String, DSCAlarmBindingConfig>(dscAlarmUpdateMap);
for (String itemName : itemsMap.keySet()) {
DSCAlarmBindingConfig dscAlarmBindingConfig = itemsMap.get(itemName);
dscAlarmUpdateMap.remove(itemName);
Item item = null;
for (DSCAlarmBindingProvider provider : providers) {
item = provider.getItem(itemName);
}
if (dscAlarmBindingConfig.getDSCAlarmItemType().equals(DSCAlarmItemType.PANEL_COMMAND)) {
dscAlarmItemUpdate.updateDeviceItem(item, dscAlarmBindingConfig, eventPublisher, null, -1, "");
} else {
dscAlarmItemUpdate.updateDeviceItem(item, dscAlarmBindingConfig, eventPublisher, null, 0, "");
}
logger.debug("processUpdateMap(): Updated item: {}", itemName);
}
}
use of org.openhab.core.items.Item in project openhab1-addons by openhab.
the class HttpGenericBindingProviderTest method testParseBindingConfigWithXPATH.
@Test
public void testParseBindingConfigWithXPATH() throws BindingConfigParseException {
String bindingConfig = "<[http://www.wetter-vista.de:7970/api/xml.php?q=Berlin:60000:XPATH(/wettervorhersage/tag[1]/tmax)]";
Item testItem = new DecimalTestItem();
// method under test
HttpBindingConfig config = provider.parseBindingConfig(testItem, bindingConfig);
// asserts
Assert.assertEquals(true, config.containsKey(HttpGenericBindingProvider.IN_BINDING_KEY));
Assert.assertEquals(null, config.get(HttpGenericBindingProvider.IN_BINDING_KEY).httpMethod);
Assert.assertEquals("http://www.wetter-vista.de:7970/api/xml.php?q=Berlin", config.get(HttpGenericBindingProvider.IN_BINDING_KEY).url);
Assert.assertEquals(60000, config.get(HttpGenericBindingProvider.IN_BINDING_KEY).refreshInterval);
Assert.assertEquals("XPATH(/wettervorhersage/tag[1]/tmax)", config.get(HttpGenericBindingProvider.IN_BINDING_KEY).transformation);
}
use of org.openhab.core.items.Item in project openhab1-addons by openhab.
the class HttpGenericBindingProviderTest method testParseBindingConfigWithNumbers.
@Test
public void testParseBindingConfigWithNumbers() throws BindingConfigParseException {
String bindingConfig = ">[1:POST:http://www.domain.org:1234/home/lights/23871/?status=on&type=\"text\"] >[0:GET:http://www.domain.org:1234/home/lights/23871/?status=off]";
Item testItem = new DecimalTestItem();
// method under test
HttpBindingConfig config = provider.parseBindingConfig(testItem, bindingConfig);
// asserts
Assert.assertEquals(true, config.containsKey(DecimalType.valueOf("1")));
Assert.assertEquals("POST", config.get(DecimalType.valueOf("1")).httpMethod);
Assert.assertEquals("http://www.domain.org:1234/home/lights/23871/?status=on&type=\"text\"", config.get(DecimalType.valueOf("1")).url);
Assert.assertEquals(true, config.containsKey(DecimalType.valueOf("0")));
Assert.assertEquals("GET", config.get(DecimalType.valueOf("0")).httpMethod);
Assert.assertEquals("http://www.domain.org:1234/home/lights/23871/?status=off", config.get(DecimalType.valueOf("0")).url);
}
Aggregations