Search in sources :

Example 11 with SwitchItem

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!");
    }
}
Also used : NumberItem(org.openhab.core.library.items.NumberItem) BindingConfig(org.openhab.core.binding.BindingConfig) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) SwitchItem(org.openhab.core.library.items.SwitchItem) ChannelTypeDef(org.openhab.binding.energenie.internal.EnergenieBindingConfig.ChannelTypeDef)

Example 12 with SwitchItem

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);
}
Also used : EnoceanParameterAddress(org.opencean.core.address.EnoceanParameterAddress) SwitchItem(org.openhab.core.library.items.SwitchItem) Before(org.junit.Before)

Example 13 with SwitchItem

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());
}
Also used : EnoceanParameterAddress(org.opencean.core.address.EnoceanParameterAddress) SwitchItem(org.openhab.core.library.items.SwitchItem) Test(org.junit.Test)

Example 14 with SwitchItem

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"));
}
Also used : SwitchItem(org.openhab.core.library.items.SwitchItem) Test(org.junit.Test)

Example 15 with SwitchItem

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"));
}
Also used : SwitchItem(org.openhab.core.library.items.SwitchItem) Test(org.junit.Test)

Aggregations

SwitchItem (org.openhab.core.library.items.SwitchItem)55 NumberItem (org.openhab.core.library.items.NumberItem)25 DimmerItem (org.openhab.core.library.items.DimmerItem)21 Test (org.junit.Test)18 ContactItem (org.openhab.core.library.items.ContactItem)17 Item (org.openhab.core.items.Item)15 RollershutterItem (org.openhab.core.library.items.RollershutterItem)15 DecimalType (org.openhab.core.library.types.DecimalType)15 ColorItem (org.openhab.core.library.items.ColorItem)12 StringItem (org.openhab.core.library.items.StringItem)12 PercentType (org.openhab.core.library.types.PercentType)11 StringType (org.openhab.core.library.types.StringType)10 State (org.openhab.core.types.State)8 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)8 DateTimeItem (org.openhab.core.library.items.DateTimeItem)7 DateTimeType (org.openhab.core.library.types.DateTimeType)7 Calendar (java.util.Calendar)6 ItemNotFoundException (org.openhab.core.items.ItemNotFoundException)5 HSBType (org.openhab.core.library.types.HSBType)5 SappBindingConfigContactItem (org.openhab.binding.sapp.internal.configs.SappBindingConfigContactItem)4