]> git.basschouten.com Git - openhab-addons.git/blob
e722399f579341d0e0710eba4865c73b5fef06b0
[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.keba.internal;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.openhab.core.thing.ThingTypeUID;
20
21 /**
22  * The {@link KebaBindingConstants} class defines common constants, which are used across
23  * the whole binding.
24  *
25  * @author Karel Goderis - Initial contribution
26  */
27 @NonNullByDefault
28 public class KebaBindingConstants {
29
30     public static final String BINDING_ID = "keba";
31
32     // List of all Thing Type UIDs
33     public static final ThingTypeUID THING_TYPE_KECONTACTP20 = new ThingTypeUID(BINDING_ID, "kecontact");
34
35     // List of all Channel ids
36     public static final String CHANNEL_MODEL = "model";
37     public static final String CHANNEL_FIRMWARE = "firmware";
38     public static final String CHANNEL_STATE = "state";
39     public static final String CHANNEL_ERROR_1 = "error1";
40     public static final String CHANNEL_ERROR_2 = "error2";
41     public static final String CHANNEL_WALLBOX = "wallbox";
42     public static final String CHANNEL_VEHICLE = "vehicle";
43     public static final String CHANNEL_PLUG_LOCKED = "locked";
44     public static final String CHANNEL_ENABLED_SYSTEM = "enabledsystem";
45     public static final String CHANNEL_ENABLED_USER = "enableduser";
46     public static final String CHANNEL_PILOT_CURRENT = "maxpilotcurrent";
47     public static final String CHANNEL_PILOT_PWM = "maxpilotcurrentdutycyle";
48     public static final String CHANNEL_MAX_SYSTEM_CURRENT = "maxsystemcurrent";
49     public static final String CHANNEL_MAX_PRESET_CURRENT_RANGE = "maxpresetcurrentrange";
50     public static final String CHANNEL_MAX_PRESET_CURRENT = "maxpresetcurrent";
51     public static final String CHANNEL_FAILSAFE_CURRENT = "failsafecurrent";
52     public static final String CHANNEL_INPUT = "input";
53     public static final String CHANNEL_OUTPUT = "output";
54     public static final String CHANNEL_SERIAL = "serial";
55     public static final String CHANNEL_UPTIME = "uptime";
56     public static final String CHANNEL_I1 = "I1";
57     public static final String CHANNEL_I2 = "I2";
58     public static final String CHANNEL_I3 = "I3";
59     public static final String CHANNEL_U1 = "U1";
60     public static final String CHANNEL_U2 = "U2";
61     public static final String CHANNEL_U3 = "U3";
62     public static final String CHANNEL_POWER = "power";
63     public static final String CHANNEL_POWER_FACTOR = "powerfactor";
64     public static final String CHANNEL_SESSION_CONSUMPTION = "sessionconsumption";
65     public static final String CHANNEL_TOTAL_CONSUMPTION = "totalconsumption";
66     public static final String CHANNEL_DISPLAY = "display";
67     public static final String CHANNEL_AUTHON = "authon";
68     public static final String CHANNEL_AUTHREQ = "authreq";
69     public static final String CHANNEL_SESSION_RFID_TAG = "sessionrfidtag";
70     public static final String CHANNEL_SESSION_RFID_CLASS = "sessionrfidclass";
71     public static final String CHANNEL_SESSION_SESSION_ID = "sessionid";
72     public static final String CHANNEL_SETENERGY = "setenergylimit";
73     public static final String CHANNEL_AUTHENTICATE = "authenticate";
74
75     public enum KebaType {
76         P20,
77         P30
78     }
79
80     public enum KebaSeries {
81
82         E('0'),
83         B('1'),
84         C('2', '3'),
85         X('A', 'B', 'C', 'D', 'E', 'G', 'H');
86
87         private final List<Character> things = new ArrayList<>();
88
89         KebaSeries(char... e) {
90             for (char c : e) {
91                 things.add(c);
92             }
93         }
94
95         public boolean matchesSeries(char c) {
96             return things.contains(c);
97         }
98
99         public static KebaSeries getSeries(char text) throws IllegalArgumentException {
100             for (KebaSeries c : KebaSeries.values()) {
101                 if (c.matchesSeries(text)) {
102                     return c;
103                 }
104             }
105
106             throw new IllegalArgumentException("Not a valid series: '" + text + "'");
107         }
108     }
109 }