]> git.basschouten.com Git - openhab-addons.git/blob
f8a57d5a70a06f420c3ea1fd6d44eac3a6bc7aab
[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.rme.internal;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.thing.ThingTypeUID;
17
18 /**
19  * The {@link RMEBinding} class defines common constants, which are used across
20  * the whole binding.
21  *
22  * @author Karel Goderis - Initial contribution
23  */
24 @NonNullByDefault
25 public class RMEBindingConstants {
26
27     public static final String BINDING_ID = "rme";
28
29     // List of all Thing Type UIDs
30     public static final ThingTypeUID THING_TYPE_MANAGER = new ThingTypeUID(BINDING_ID, "manager");
31
32     // List of all Channel ids
33     public enum DataField {
34
35         LEVEL("waterlevel", 1),
36         MODE("mode", 2),
37         SOURCE("source", 3),
38         EXITPUMP("exitpump", 4),
39         ENTRYPUMP("entrypump", 5),
40         WATEREXCHANGE("waterexchange", 6),
41         CISTERNSUPPLYALARM("cisternsupplyalarm", 7),
42         OVERFLOWALARM("overflowalarm", 8),
43         CISTERNBLOCKEDALARM("cisternblockedalarm", 9),
44         FILTERCLEANING("filtercleaning", 10);
45
46         private final String id;
47         private final int number;
48
49         private DataField(final String id, final int number) {
50             this.number = number;
51             this.id = id;
52         }
53
54         @Override
55         public String toString() {
56             return String.valueOf(number);
57         }
58
59         public int toNumber() {
60             return number;
61         }
62
63         public static DataField get(int valueSelectorNumber) throws IllegalArgumentException {
64             for (DataField c : DataField.values()) {
65                 if (c.number == valueSelectorNumber) {
66                     return c;
67                 }
68             }
69
70             throw new IllegalArgumentException("Not a valid value selector");
71         }
72
73         public static DataField get(String valueSelectorText) throws IllegalArgumentException {
74             for (DataField c : DataField.values()) {
75                 if (c.id.equals(valueSelectorText)) {
76                     return c;
77                 }
78             }
79
80             throw new IllegalArgumentException("Not a valid value selector");
81         }
82
83         public String channelID() {
84             return this.id;
85         }
86     }
87 }