Search in sources :

Example 1 with Datapoint

use of org.openhab.binding.fht.FHTBindingConfig.Datapoint in project openhab1-addons by openhab.

the class FHTGenericBindingProvider method processBindingConfiguration.

/**
     * Binding in the type of
     * {fht="housecode=<housecode>;address=<optional>;datapoint=<optional>"}
     * {@inheritDoc}
     */
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
    super.processBindingConfiguration(context, item, bindingConfig);
    String[] configParts = bindingConfig.split(";");
    String housecode = null;
    String address = null;
    Datapoint datapoint = null;
    for (String s : configParts) {
        String[] entryParts = s.split("=");
        if ("housecode".equals(entryParts[0])) {
            housecode = entryParts[1];
        } else if ("address".equals(entryParts[0])) {
            address = entryParts[1];
        } else if ("datapoint".equals(entryParts[0])) {
            datapoint = Datapoint.valueOf(entryParts[1]);
        }
    }
    if (housecode == null) {
        throw new BindingConfigParseException("housecode mustn't be null");
    }
    if (datapoint == null) {
        throw new BindingConfigParseException("datapoint must be one of MEASURED_TEMP, DESIRED_TEMP, BATTERY, WINDOW or VALVE");
    }
    if ((datapoint == Datapoint.WINDOW || datapoint == Datapoint.VALVE) && address == null) {
        throw new BindingConfigParseException("Address of window contact needed");
    }
    FHTBindingConfig config = new FHTBindingConfig(item, housecode, address, datapoint);
    addBindingConfig(item, config);
}
Also used : Datapoint(org.openhab.binding.fht.FHTBindingConfig.Datapoint) FHTBindingConfig(org.openhab.binding.fht.FHTBindingConfig) BindingConfigParseException(org.openhab.model.item.binding.BindingConfigParseException)

Aggregations

FHTBindingConfig (org.openhab.binding.fht.FHTBindingConfig)1 Datapoint (org.openhab.binding.fht.FHTBindingConfig.Datapoint)1 BindingConfigParseException (org.openhab.model.item.binding.BindingConfigParseException)1