]> git.basschouten.com Git - openhab-addons.git/blob
417225b934828b84604625ba80109f04511fb6cc
[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 = "enabled";
45     public static final String CHANNEL_PILOT_CURRENT = "maxpilotcurrent";
46     public static final String CHANNEL_PILOT_PWM = "maxpilotcurrentdutycyle";
47     public static final String CHANNEL_MAX_SYSTEM_CURRENT = "maxsystemcurrent";
48     public static final String CHANNEL_MAX_PRESET_CURRENT_RANGE = "maxpresetcurrentrange";
49     public static final String CHANNEL_MAX_PRESET_CURRENT = "maxpresetcurrent";
50     public static final String CHANNEL_FAILSAFE_CURRENT = "failsafecurrent";
51     public static final String CHANNEL_INPUT = "input";
52     public static final String CHANNEL_OUTPUT = "output";
53     public static final String CHANNEL_SERIAL = "serial";
54     public static final String CHANNEL_UPTIME = "uptime";
55     public static final String CHANNEL_I1 = "I1";
56     public static final String CHANNEL_I2 = "I2";
57     public static final String CHANNEL_I3 = "I3";
58     public static final String CHANNEL_U1 = "U1";
59     public static final String CHANNEL_U2 = "U2";
60     public static final String CHANNEL_U3 = "U3";
61     public static final String CHANNEL_POWER = "power";
62     public static final String CHANNEL_POWER_FACTOR = "powerfactor";
63     public static final String CHANNEL_SESSION_CONSUMPTION = "sessionconsumption";
64     public static final String CHANNEL_TOTAL_CONSUMPTION = "totalconsumption";
65     public static final String CHANNEL_DISPLAY = "display";
66     public static final String CHANNEL_AUTHON = "authon";
67     public static final String CHANNEL_AUTHREQ = "authreq";
68     public static final String CHANNEL_SESSION_RFID_TAG = "sessionrfidtag";
69     public static final String CHANNEL_SESSION_RFID_CLASS = "sessionrfidclass";
70     public static final String CHANNEL_SESSION_SESSION_ID = "sessionid";
71     public static final String CHANNEL_SETENERGY = "setenergylimit";
72     public static final String CHANNEL_AUTHENTICATE = "authenticate";
73
74     public enum KebaType {
75         P20,
76         P30
77     }
78
79     public enum KebaSeries {
80
81         E('0'),
82         B('1'),
83         C('2', '3'),
84         X('A', 'B', 'C', 'D', 'E', 'G', 'H');
85
86         private final List<Character> things = new ArrayList<>();
87
88         KebaSeries(char... e) {
89             for (char c : e) {
90                 things.add(c);
91             }
92         }
93
94         public boolean matchesSeries(char c) {
95             return things.contains(c);
96         }
97
98         public static KebaSeries getSeries(char text) throws IllegalArgumentException {
99             for (KebaSeries c : KebaSeries.values()) {
100                 if (c.matchesSeries(text)) {
101                     return c;
102                 }
103             }
104
105             throw new IllegalArgumentException("Not a valid series: '" + text + "'");
106         }
107     }
108 }