use of org.openhab.core.library.items.SwitchItem 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.SwitchItem in project openhab1-addons by openhab.
the class RockerSwitchInSwitchOnOffProfileTest method setUpDefaultDevice.
@Before
public void setUpDefaultDevice() {
parameterAddress = new EnoceanParameterAddress(EnoceanId.fromString(EnoceanBindingProviderMock.DEVICE_ID), CHANNEL, (String) null);
provider.setParameterAddress(parameterAddress);
provider.setItem(new SwitchItem("dummie"));
provider.setEep(EEPId.EEP_F6_02_01);
binding.addBindingProvider(provider);
}
use of org.openhab.core.library.items.SwitchItem in project openhab1-addons by openhab.
the class RockerSwitchTest method testReceiveButtonPress.
@Test
public void testReceiveButtonPress() {
parameterAddress = new EnoceanParameterAddress(EnoceanId.fromString(EnoceanBindingProviderMock.DEVICE_ID), Parameter.I);
provider.setParameterAddress(parameterAddress);
binding.addBindingProvider(provider);
provider.setItem(new SwitchItem("dummie"));
binding.valueChanged(parameterAddress, ButtonState.PRESSED);
assertEquals("Update State", OnOffType.ON, publisher.getUpdateState());
}
use of org.openhab.core.library.items.SwitchItem in project openhab1-addons by openhab.
the class LightwaveRfGenericBindingProviderTest method testProcessBindingConfigurationForSwitch.
@Test
public void testProcessBindingConfigurationForSwitch() throws Exception {
LightwaveRfGenericBindingProvider bingindProvider = new LightwaveRfGenericBindingProvider();
bingindProvider.processBindingConfiguration(context, new SwitchItem("MySwitch"), "room=3,device=4,type=SWITCH");
assertEquals(Arrays.asList("MySwitch"), bingindProvider.getBindingItemsForRoomDevice("3", "4"));
assertEquals(Arrays.asList("MySwitch"), bingindProvider.getItemNames());
assertEquals("3", bingindProvider.getRoomId("MySwitch"));
assertEquals("4", bingindProvider.getDeviceId("MySwitch"));
assertEquals(LightwaveRfType.SWITCH, bingindProvider.getTypeForItemName("MySwitch"));
}
use of org.openhab.core.library.items.SwitchItem in project openhab1-addons by openhab.
the class LightwaveRfGenericBindingProviderTest method testProcessBindingConfiguratiLionForInOnly.
@Test
public void testProcessBindingConfiguratiLionForInOnly() throws Exception {
LightwaveRfGenericBindingProvider bingindProvider = new LightwaveRfGenericBindingProvider();
bingindProvider.processBindingConfiguration(context, new SwitchItem("MySwitch"), "<room=3,device=4,type=SWITCH");
assertEquals(Arrays.asList("MySwitch"), bingindProvider.getBindingItemsForRoomDevice("3", "4"));
assertEquals(Arrays.asList("MySwitch"), bingindProvider.getItemNames());
assertEquals("3", bingindProvider.getRoomId("MySwitch"));
assertEquals("4", bingindProvider.getDeviceId("MySwitch"));
assertEquals(LightwaveRfType.SWITCH, bingindProvider.getTypeForItemName("MySwitch"));
assertEquals(LightwaveRfItemDirection.IN_ONLY, bingindProvider.getDirection("MySwitch"));
}
Aggregations