use of org.openhab.binding.withings.internal.model.MeasureType in project openhab1-addons by openhab.
the class WithingsGenericBindingProvider method processBindingConfiguration.
@Override
public void processBindingConfiguration(String context, Item item, String bindingConfig) throws BindingConfigParseException {
super.processBindingConfiguration(context, item, bindingConfig);
String[] configElements = bindingConfig.split(":");
String accountId = null;
MeasureType measureType = null;
if (configElements.length == 1) {
measureType = MeasureType.valueOf(configElements[0].toUpperCase());
} else if (configElements.length == 2) {
accountId = configElements[0];
measureType = MeasureType.valueOf(configElements[1].toUpperCase());
} else {
throw new BindingConfigParseException("Unknown Binding configuration '{}'. The Binding " + "configuration should consists of either one or two elements.");
}
if (measureType == null) {
throw new BindingConfigParseException("Could not convert string '" + bindingConfig + "' to according measure type.");
}
WithingsBindingConfig config = new WithingsBindingConfig(accountId, measureType);
addBindingConfig(item, config);
}
use of org.openhab.binding.withings.internal.model.MeasureType in project openhab1-addons by openhab.
the class WithingsBinding method updateItemState.
private void updateItemState(String itemName, WithingsBindingConfig withingsBindingConfig, List<MeasureGroup> measures) {
MeasureType measureType = withingsBindingConfig.measureType;
Float lastMeasureValue = findLastMeasureValue(measures, measureType);
if (lastMeasureValue != null) {
eventPublisher.postUpdate(itemName, new DecimalType(lastMeasureValue));
}
}
Aggregations