2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.smartmeter.internal;
16 import java.util.ArrayList;
17 import java.util.Collection;
18 import java.util.List;
19 import java.util.Locale;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.openhab.binding.smartmeter.SmartMeterBindingConstants;
24 import org.openhab.binding.smartmeter.internal.conformity.Conformity;
25 import org.openhab.binding.smartmeter.internal.helper.Baudrate;
26 import org.openhab.binding.smartmeter.internal.helper.ProtocolMode;
27 import org.openhab.core.config.core.ConfigOptionProvider;
28 import org.openhab.core.config.core.ParameterOption;
29 import org.osgi.service.component.annotations.Component;
32 * Provides the configuration options for a meter device.
34 * @author Matthias Steigenberger - Initial contribution
37 @Component(service = ConfigOptionProvider.class)
39 public class SmartMeterConfigProvider implements ConfigOptionProvider {
42 public @Nullable Collection<ParameterOption> getParameterOptions(URI uri, String param, @Nullable Locale locale) {
43 return getParameterOptions(uri, param, null, locale);
47 public @Nullable Collection<ParameterOption> getParameterOptions(URI uri, String param, @Nullable String context,
48 @Nullable Locale locale) {
49 if (!SmartMeterBindingConstants.THING_TYPE_SMLREADER.getAsString().equals(uri.getSchemeSpecificPart())) {
54 case SmartMeterBindingConstants.CONFIGURATION_SERIAL_MODE:
55 List<ParameterOption> options = new ArrayList<>();
57 for (ProtocolMode mode : ProtocolMode.values()) {
58 options.add(new ParameterOption(mode.name(), mode.toString()));
62 case SmartMeterBindingConstants.CONFIGURATION_BAUDRATE:
63 options = new ArrayList<>();
65 for (Baudrate baudrate : Baudrate.values()) {
66 options.add(new ParameterOption(baudrate.getBaudrate() + "", baudrate.toString()));
70 case SmartMeterBindingConstants.CONFIGURATION_CONFORMITY:
71 options = new ArrayList<>();
73 for (Conformity conformity : Conformity.values()) {
74 options.add(new ParameterOption(conformity.name(), conformity.toString()));