Search in sources :

Example 6 with BindingConfig

use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.

the class MilightGenericBindingProvider 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 (configParts.length > 4) {
                throw new BindingConfigParseException("milight binding configuration must not have more than four parts");
            }
            if (item instanceof ColorItem) {
                BindingConfig milightBindingConfig = new MilightBindingConfig(configParts[0], configParts[1], BindingType.rgb.name(), null);
                addBindingConfig(item, milightBindingConfig);
            } else if (item instanceof DimmerItem || item instanceof SwitchItem) {
                BindingConfig milightBindingConfig = new MilightBindingConfig(configParts[0], configParts[1], configParts.length < 3 ? null : configParts[2], configParts.length < 4 ? null : configParts[3]);
                addBindingConfig(item, milightBindingConfig);
            }
        } 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 : BindingConfig(org.openhab.core.binding.BindingConfig) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException) DimmerItem(org.openhab.core.library.items.DimmerItem) ColorItem(org.openhab.core.library.items.ColorItem) SwitchItem(org.openhab.core.library.items.SwitchItem)

Example 7 with BindingConfig

use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.

the class MochadX10GenericBindingProvider method processBindingConfiguration.

@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
    String bindingConfigLc = bindingConfig.toLowerCase();
    super.processBindingConfiguration(context, item, bindingConfigLc);
    if (bindingConfigLc != null) {
        String address = getAddress(bindingConfigLc);
        String transmitMethod = getTransmitMethod(bindingConfigLc);
        String dimMethod = getDimMethod(bindingConfigLc);
        if (address != null) {
            if (transmitMethod == null) {
                transmitMethod = "pl";
            }
            if (dimMethod == null) {
                dimMethod = "xdim";
            }
            BindingConfig mochadX10BindingConfig = new MochadX10BindingConfig(item.getName(), item.getClass(), transmitMethod, dimMethod, address);
            addBindingConfig(item, mochadX10BindingConfig);
        } else {
            throw new BindingConfigParseException("No address specified, bindingConfig is invalid (item=" + item + ") -> processing bindingConfig aborted!");
        }
    } else {
        throw new BindingConfigParseException("No binding config specified (item=" + item + ") -> processing bindingConfig aborted!");
    }
}
Also used : BindingConfig(org.openhab.core.binding.BindingConfig) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException)

Example 8 with BindingConfig

use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.

the class VDRGenericBindingProvider method getBindingItemName.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.openhab.binding.vdr.VDRBindingProvider#getBindingItemName(java.lang
     * .String, org.openhab.binding.vdr.internal.VDRCommandType)
     */
@Override
public String getBindingItemName(String vdrId, VDRCommandType vdrCommand) {
    String itemName = null;
    logger.debug("Searching for a binding config that matches the id '{}' and command '{}'", vdrId, vdrCommand);
    for (BindingConfig config : this.bindingConfigs.values()) {
        VDRBindingConfig vdrConfig = (VDRBindingConfig) config;
        if (vdrConfig.vDRId.equals(vdrId) && vdrConfig.command.equals(vdrCommand.getVDRCommand())) {
            itemName = vdrConfig.item.getName();
            logger.debug("Match found: '{}'", itemName);
            break;
        } else {
            logger.debug("Not a match: '{}':'{}'", vdrConfig.vDRId, vdrConfig.command);
        }
    }
    return itemName;
}
Also used : BindingConfig(org.openhab.core.binding.BindingConfig)

Example 9 with BindingConfig

use of org.openhab.core.binding.BindingConfig 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!");
    }
}
Also used : BindingConfig(org.openhab.core.binding.BindingConfig) DimmerItem(org.openhab.core.library.items.DimmerItem) ColorItem(org.openhab.core.library.items.ColorItem) SwitchItem(org.openhab.core.library.items.SwitchItem)

Example 10 with BindingConfig

use of org.openhab.core.binding.BindingConfig in project openhab1-addons by openhab.

the class OneWireBinding method scheduleAllBindings.

/**
     * schedule All Bindings to get updated
     *
     * @param pvProvider
     */
private void scheduleAllBindings(BindingProvider pvProvider) {
    if (OneWireConnection.isConnectionEstablished()) {
        logger.debug("scheduleAllBindings");
        if (pvProvider instanceof OneWireBindingProvider) {
            OneWireBindingProvider lvBindingProvider = (OneWireBindingProvider) pvProvider;
            ivOneWireReaderScheduler.clear();
            ivCacheItemStates.clear();
            Map<String, BindingConfig> lvBindigConfigs = lvBindingProvider.getBindingConfigs();
            for (String lvItemName : lvBindigConfigs.keySet()) {
                logger.debug("scheduleAllBindings, now item {}.", lvItemName);
                OneWireBindingConfig lvOneWireBindingConfig = (OneWireBindingConfig) lvBindigConfigs.get(lvItemName);
                if (lvOneWireBindingConfig instanceof AbstractOneWireDevicePropertyBindingConfig) {
                    logger.debug("Initializing read of item {}.", lvItemName);
                    AbstractOneWireDevicePropertyBindingConfig lvDevicePropertyBindingConfig = (AbstractOneWireDevicePropertyBindingConfig) lvOneWireBindingConfig;
                    if (lvDevicePropertyBindingConfig != null) {
                        int lvAutoRefreshTimeInSecs = lvDevicePropertyBindingConfig.getAutoRefreshInSecs();
                        if (lvAutoRefreshTimeInSecs > -1) {
                            ivOneWireReaderScheduler.updateOnce(lvItemName);
                        }
                        if (lvAutoRefreshTimeInSecs > 0) {
                            if (!ivOneWireReaderScheduler.scheduleUpdate(lvItemName, lvAutoRefreshTimeInSecs)) {
                                logger.warn("Couldn't add to OneWireUpdate scheduler", lvDevicePropertyBindingConfig);
                            }
                        }
                    }
                } else {
                    logger.debug("Didn't schedule item {} because it is not a DevicePropertyBinding.", lvItemName);
                }
            }
        }
    }
}
Also used : AbstractOneWireDevicePropertyBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyBindingConfig) OneWireDevicePropertyExecutableBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.OneWireDevicePropertyExecutableBindingConfig) AbstractOneWireDevicePropertyWritableBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyWritableBindingConfig) BindingConfig(org.openhab.core.binding.BindingConfig) AbstractOneWireControlBindingConfig(org.openhab.binding.onewire.internal.control.AbstractOneWireControlBindingConfig) AbstractOneWireDevicePropertyBindingConfig(org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyBindingConfig) OneWireBindingProvider(org.openhab.binding.onewire.OneWireBindingProvider)

Aggregations

BindingConfig (org.openhab.core.binding.BindingConfig)10 HashSet (java.util.HashSet)3 SwitchItem (org.openhab.core.library.items.SwitchItem)3 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)3 ArrayList (java.util.ArrayList)2 ColorItem (org.openhab.core.library.items.ColorItem)2 DimmerItem (org.openhab.core.library.items.DimmerItem)2 ChannelTypeDef (org.openhab.binding.energenie.internal.EnergenieBindingConfig.ChannelTypeDef)1 OneWireBindingProvider (org.openhab.binding.onewire.OneWireBindingProvider)1 AbstractOneWireControlBindingConfig (org.openhab.binding.onewire.internal.control.AbstractOneWireControlBindingConfig)1 AbstractOneWireDevicePropertyBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyBindingConfig)1 AbstractOneWireDevicePropertyWritableBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.AbstractOneWireDevicePropertyWritableBindingConfig)1 OneWireDevicePropertyExecutableBindingConfig (org.openhab.binding.onewire.internal.deviceproperties.OneWireDevicePropertyExecutableBindingConfig)1 NumberItem (org.openhab.core.library.items.NumberItem)1