]> git.basschouten.com Git - openhab-addons.git/blob
38961a9a0efdfab11dee3830cb6405f2e53fa018
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.knx.internal;
14
15 import java.io.IOException;
16 import java.io.InputStream;
17 import java.util.Map;
18 import java.util.Properties;
19 import java.util.Set;
20 import java.util.stream.Collectors;
21
22 import org.eclipse.jdt.annotation.NonNullByDefault;
23 import org.openhab.core.thing.ThingTypeUID;
24
25 /**
26  * The {@link KNXBindingConstants} class defines common constants, which are
27  * used across the whole binding.
28  *
29  * @author Karel Goderis - Initial contribution
30  */
31 @NonNullByDefault
32 public class KNXBindingConstants {
33
34     public static final String BINDING_ID = "knx";
35
36     // Global config
37     public static final String CONFIG_DISABLE_UOM = "disableUoM";
38     public static boolean disableUoM = false;
39
40     // Thing Type UIDs
41     public static final ThingTypeUID THING_TYPE_IP_BRIDGE = new ThingTypeUID(BINDING_ID, "ip");
42     public static final ThingTypeUID THING_TYPE_SERIAL_BRIDGE = new ThingTypeUID(BINDING_ID, "serial");
43     public static final ThingTypeUID THING_TYPE_DEVICE = new ThingTypeUID(BINDING_ID, "device");
44
45     // Property IDs
46     public static final String DEVICE_MASK_VERSION = "deviceMaskVersion";
47     public static final String DEVICE_PROFILE = "deviceProfile";
48     public static final String DEVICE_MEDIUM_TYPE = "deviceMediumType";
49     public static final String FRIENDLY_NAME = "deviceName";
50     public static final String MANUFACTURER_NAME = "manufacturerName";
51     public static final String MANUFACTURER_SERIAL_NO = "manufacturerSerialNumber";
52     public static final String MANUFACTURER_HARDWARE_TYPE = "manufacturerHardwareType";
53     public static final String MANUFACTURER_FIRMWARE_REVISION = "manufacturerFirmwareRevision";
54     public static final String MANUFACTURER_ORDER_INFO = "manufacturerOrderInfo";
55     public static final String MAX_APDU_LENGTH = "maxApduLength";
56
57     // Thing Configuration parameters
58     public static final String IP_ADDRESS = "ipAddress";
59     public static final String IP_CONNECTION_TYPE = "type";
60     public static final String LOCAL_IP = "localIp";
61     public static final String LOCAL_SOURCE_ADDRESS = "localSourceAddr";
62     public static final String PORT_NUMBER = "portNumber";
63     public static final String SERIAL_PORT = "serialPort";
64     public static final String USE_CEMI = "useCemi";
65     public static final String ROUTER_BACKBONE_GROUP_KEY = "routerBackboneGroupKey";
66     public static final String TUNNEL_USER_ID = "tunnelUserId";
67     public static final String TUNNEL_USER_PASSWORD = "tunnelUserPassword";
68     public static final String TUNNEL_DEVICE_AUTHENTICATION = "tunnelDeviceAuthentication";
69
70     // The default multicast ip address (see <a
71     // href="http://www.iana.org/assignments/multicast-addresses/multicast-addresses.xml">iana</a> EIBnet/IP
72     public static final String DEFAULT_MULTICAST_IP = "224.0.23.12";
73
74     // Channel Type IDs
75     public static final String CHANNEL_COLOR = "color";
76     public static final String CHANNEL_COLOR_CONTROL = "color-control";
77     public static final String CHANNEL_CONTACT = "contact";
78     public static final String CHANNEL_CONTACT_CONTROL = "contact-control";
79     public static final String CHANNEL_DATETIME = "datetime";
80     public static final String CHANNEL_DATETIME_CONTROL = "datetime-control";
81     public static final String CHANNEL_DIMMER = "dimmer";
82     public static final String CHANNEL_DIMMER_CONTROL = "dimmer-control";
83     public static final String CHANNEL_NUMBER = "number";
84     public static final String CHANNEL_NUMBER_CONTROL = "number-control";
85     public static final String CHANNEL_ROLLERSHUTTER = "rollershutter";
86     public static final String CHANNEL_ROLLERSHUTTER_CONTROL = "rollershutter-control";
87     public static final String CHANNEL_STRING = "string";
88     public static final String CHANNEL_STRING_CONTROL = "string-control";
89     public static final String CHANNEL_SWITCH = "switch";
90     public static final String CHANNEL_SWITCH_CONTROL = "switch-control";
91
92     public static final Set<String> CONTROL_CHANNEL_TYPES = Set.of( //
93             CHANNEL_COLOR_CONTROL, //
94             CHANNEL_CONTACT_CONTROL, //
95             CHANNEL_DATETIME_CONTROL, //
96             CHANNEL_DIMMER_CONTROL, //
97             CHANNEL_NUMBER_CONTROL, //
98             CHANNEL_ROLLERSHUTTER_CONTROL, //
99             CHANNEL_STRING_CONTROL, //
100             CHANNEL_SWITCH_CONTROL //
101     );
102
103     public static final String CHANNEL_RESET = "reset";
104
105     // Channel Configuration parameters
106     public static final String GA = "ga";
107     public static final String HSB_GA = "hsb";
108     public static final String INCREASE_DECREASE_GA = "increaseDecrease";
109     public static final String POSITION_GA = "position";
110     public static final String REPEAT_FREQUENCY = "frequency";
111     public static final String STOP_MOVE_GA = "stopMove";
112     public static final String SWITCH_GA = "switch";
113     public static final String UP_DOWN_GA = "upDown";
114
115     public static final Map<Integer, String> MANUFACTURER_MAP = readManufacturerMap();
116
117     private static Map<Integer, String> readManufacturerMap() {
118         ClassLoader classLoader = KNXBindingConstants.class.getClassLoader();
119         if (classLoader == null) {
120             return Map.of();
121         }
122
123         try (InputStream is = classLoader.getResourceAsStream("manufacturer.properties")) {
124             if (is == null) {
125                 return Map.of();
126             }
127
128             Properties properties = new Properties();
129             properties.load(is);
130             return properties.entrySet().stream()
131                     .collect(Collectors.toMap(e -> Integer.parseInt((String) e.getKey()), e -> (String) e.getValue()));
132         } catch (IOException e) {
133             return Map.of();
134         }
135     }
136 }