]> git.basschouten.com Git - openhab-addons.git/blob
d0fad1779eec9158524008ba48f180980789a99e
[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.digitalstrom.internal.lib.event.constants;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 /**
19  * The {@link EventResponseEnum} contains digitalSTROM-Event properties of the events at {@link EventNames}.
20  *
21  * @author Michael Ochel
22  * @author Mathias Siegele
23  */
24 public enum EventResponseEnum {
25
26     // general
27     NAME("Name"),
28     PROPERTIES("properties"),
29     SOURCE("source"),
30     SET("set"),
31     DSID("dsid"),
32     ZONEID("zoneID"),
33     GROUPID("groupID"),
34     IS_APARTMENT("isApartment"),
35     IS_GROUP("isGroup"),
36     IS_DEVICE("isDevice"),
37     IS_SERVICE("isService"),
38
39     // scene event
40     FORCED("forced"),
41     ORIGEN_TOKEN("originToken"),
42     CALL_ORIGEN("callOrigin"),
43     ORIGEN_DSUID("originDSUID"),
44     SCENEID("sceneID"),
45     ORIGIN_DEVICEID("originDeviceID"),
46
47     // device/zone sensor value
48     SENSOR_VALUE_FLOAT("sensorValueFloat"),
49     SENSOR_TYPE("sensorType"),
50     SENSOR_VALUE("sensorValue"),
51     SENSOR_INDEX("sensorIndex"),
52
53     // state changed
54     OLD_VALUE("oldvalue"),
55     STATE_NAME("statename"),
56     STATE("state"),
57     VALUE("value"),
58
59     // operation mode
60     ACTIONS("actions"),
61     OPERATION_MODE("operationMode"),
62     FORCED_UPDATE("forceUpdate"),
63
64     // binary input
65     INPUT_TYPE("inputType"),
66     INPUT_STATE("inputState"),
67     INPUT_INDEX("inputIndex");
68
69     private final String id;
70     static final Map<String, EventResponseEnum> EVENT_RESPONSE_FIELDS = new HashMap<>();
71
72     static {
73         for (EventResponseEnum ev : EventResponseEnum.values()) {
74             EVENT_RESPONSE_FIELDS.put(ev.getId(), ev);
75         }
76     }
77
78     /**
79      * Returns true, if the given property exists at the event properties, otherwise false.
80      *
81      * @param property to check
82      * @return contains property (true = yes | false = no)
83      */
84     public static boolean containsId(String property) {
85         return EVENT_RESPONSE_FIELDS.keySet().contains(property);
86     }
87
88     /**
89      * Returns the {@link EventResponseEnum} to the given property.
90      *
91      * @param property to get
92      * @return EventPropertyEnum
93      */
94     public static EventResponseEnum getProperty(String property) {
95         return EVENT_RESPONSE_FIELDS.get(property);
96     }
97
98     private EventResponseEnum(String id) {
99         this.id = id;
100     }
101
102     /**
103      * Returns the id of this {@link EventResponseEnum}.
104      *
105      * @return id of this {@link EventResponseEnum}
106      */
107     public String getId() {
108         return id;
109     }
110 }