2 * Copyright (c) 2010-2023 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;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.smartmeter.internal.ObisCode;
17 import org.openhab.core.thing.ThingTypeUID;
20 * The {@link SmartMeterBindingConstants} class defines common constants, which are
21 * used across the whole binding.
23 * @author Matthias Steigenberger - Initial contribution
26 public class SmartMeterBindingConstants {
28 public static final String BINDING_ID = "smartmeter";
29 // List of all Thing Type UIDs
30 public static final ThingTypeUID THING_TYPE_SMLREADER = new ThingTypeUID(BINDING_ID, "meter");
31 public static final String CONFIGURATION_PORT = "port";
32 public static final String CONFIGURATION_SERIAL_MODE = "mode";
33 public static final String CONFIGURATION_BAUDRATE = "baudrate";
34 public static final String CONFIGURATION_CONFORMITY = "conformity";
35 public static final String CONFIGURATION_INIT_MESSAGE = "initMessage";
36 public static final String CONFIGURATION_CONVERSION = "conversionRatio";
37 public static final String CONFIGURATION_CHANNEL_NEGATE = "negate";
38 public static final String CHANNEL_PROPERTY_OBIS = "obis";
39 public static final String OBIS_PATTERN_CHANNELID = getObisChannelIdPattern(ObisCode.OBIS_PATTERN);
41 public static final String OBIS_FORMAT_MINIMAL = "%d-%d:%d.%d.%d";
43 public static final String OBIS_FORMAT = OBIS_FORMAT_MINIMAL + "*%d";
44 public static final String CHANNEL_TYPE_METERREADER_OBIS = "channel-type:" + BINDING_ID + ":obis";
46 public static String getObisChannelIdPattern(String obis) {
47 return obis.replace(".", "-").replaceAll(":|\\*", "_");
50 public static String getObisChannelId(String obis) {
51 return getObisChannelIdPattern(obis).replaceAll("[^\\w-]", "");