]> git.basschouten.com Git - openhab-addons.git/blob
bfaeac087b3ff792af31bf218683e77ce141bc0c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.smartmeter;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.smartmeter.internal.ObisCode;
17 import org.openhab.core.thing.ThingTypeUID;
18
19 /**
20  * The {@link SmlReaderBinding} class defines common constants, which are
21  * used across the whole binding.
22  *
23  * @author Matthias Steigenberger - Initial contribution
24  */
25 @NonNullByDefault
26 public class SmartMeterBindingConstants {
27
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);
40     /** Obis format */
41     public static final String OBIS_FORMAT_MINIMAL = "%d-%d:%d.%d.%d";
42     /** Obis format */
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";
45
46     public static String getObisChannelIdPattern(String obis) {
47         return obis.replace(".", "-").replaceAll(":|\\*", "_");
48     }
49
50     public static String getObisChannelId(String obis) {
51         return getObisChannelIdPattern(obis).replaceAll("[^\\w-]", "");
52     }
53 }