]> git.basschouten.com Git - openhab-addons.git/blob
570a03ba13f9a51212e8d05dac999bf8dd028ff4
[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.elroconnects.internal;
14
15 import java.util.Map;
16 import java.util.Set;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.thing.ThingTypeUID;
22
23 /**
24  * The {@link ElroConnectsBindingConstants} class defines common constants, which are
25  * used across the whole binding.
26  *
27  * @author Mark Herwege - Initial contribution
28  */
29 @NonNullByDefault
30 public class ElroConnectsBindingConstants {
31
32     static final String BINDING_ID = "elroconnects";
33
34     // List of all Thing Type UIDs
35     public static final String TYPE_ACCOUNT = "account";
36     public static final ThingTypeUID THING_TYPE_ACCOUNT = new ThingTypeUID(BINDING_ID, TYPE_ACCOUNT);
37
38     public static final String TYPE_CONNECTOR = "connector";
39     public static final ThingTypeUID THING_TYPE_CONNECTOR = new ThingTypeUID(BINDING_ID, TYPE_CONNECTOR);
40
41     public static final String TYPE_SMOKEALARM = "smokealarm";
42     public static final String TYPE_COALARM = "coalarm";
43     public static final String TYPE_HEATALARM = "heatalarm";
44     public static final String TYPE_WATERALARM = "wateralarm";
45     public static final String TYPE_ENTRYSENSOR = "entrysensor";
46     public static final String TYPE_MOTIONSENSOR = "motionsensor";
47     public static final String TYPE_THSENSOR = "temperaturesensor";
48     public static final String TYPE_POWERSOCKET = "powersocket";
49     public static final ThingTypeUID THING_TYPE_SMOKEALARM = new ThingTypeUID(BINDING_ID, TYPE_SMOKEALARM);
50     public static final ThingTypeUID THING_TYPE_COALARM = new ThingTypeUID(BINDING_ID, TYPE_COALARM);
51     public static final ThingTypeUID THING_TYPE_HEATALARM = new ThingTypeUID(BINDING_ID, TYPE_HEATALARM);
52     public static final ThingTypeUID THING_TYPE_WATERALARM = new ThingTypeUID(BINDING_ID, TYPE_WATERALARM);
53     public static final ThingTypeUID THING_TYPE_ENTRYSENSOR = new ThingTypeUID(BINDING_ID, TYPE_ENTRYSENSOR);
54     public static final ThingTypeUID THING_TYPE_MOTIONSENSOR = new ThingTypeUID(BINDING_ID, TYPE_MOTIONSENSOR);
55     public static final ThingTypeUID THING_TYPE_THSENSOR = new ThingTypeUID(BINDING_ID, TYPE_THSENSOR);
56     public static final ThingTypeUID THING_TYPE_POWERSOCKET = new ThingTypeUID(BINDING_ID, TYPE_POWERSOCKET);
57
58     public static final Set<ThingTypeUID> SUPPORTED_ACCOUNT_TYPE_UIDS = Set.of(THING_TYPE_ACCOUNT);
59     public static final Set<ThingTypeUID> SUPPORTED_CONNECTOR_TYPES_UIDS = Set.of(THING_TYPE_CONNECTOR);
60     public static final Set<ThingTypeUID> SUPPORTED_DEVICE_TYPES_UIDS = Set.of(THING_TYPE_SMOKEALARM,
61             THING_TYPE_COALARM, THING_TYPE_HEATALARM, THING_TYPE_WATERALARM, THING_TYPE_ENTRYSENSOR,
62             THING_TYPE_MOTIONSENSOR, THING_TYPE_THSENSOR, THING_TYPE_POWERSOCKET);
63     public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_TYPES_UIDS = Stream
64             .concat(SUPPORTED_ACCOUNT_TYPE_UIDS.stream(), SUPPORTED_CONNECTOR_TYPES_UIDS.stream())
65             .collect(Collectors.toSet());
66     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream
67             .concat(SUPPORTED_BRIDGE_TYPES_UIDS.stream(), SUPPORTED_DEVICE_TYPES_UIDS.stream())
68             .collect(Collectors.toSet());
69
70     // List of all Channel ids
71     public static final String SCENE = "scene";
72
73     public static final String SIGNAL_STRENGTH = "signal";
74     public static final String BATTERY_LEVEL = "battery";
75     public static final String LOW_BATTERY = "lowBattery";
76     public static final String MUTE_ALARM = "muteAlarm";
77     public static final String TEST_ALARM = "testAlarm";
78
79     public static final String ENTRY = "entry";
80     public static final String MOTION = "motion";
81
82     public static final String POWER_STATE = "powerState";
83
84     public static final String TEMPERATURE = "temperature";
85     public static final String HUMIDITY = "humidity";
86
87     public static final String ALARM = "alarm";
88     public static final String SMOKE_ALARM = "smokeAlarm";
89     public static final String CO_ALARM = "coAlarm";
90     public static final String HEAT_ALARM = "heatAlarm";
91     public static final String WATER_ALARM = "waterAlarm";
92     public static final String ENTRY_ALARM = "entryAlarm";
93     public static final String MOTION_ALARM = "motionAlarm";
94
95     // Config properties
96     public static final String CONFIG_USERNAME = "username";
97     public static final String CONFIG_PASSWORD = "password";
98     public static final String CONFIG_CONNECTOR_ID = "connectorId";
99     public static final String CONFIG_IP_ADDRESS = "ipAddress";
100     public static final String CONFIG_REFRESH_INTERVAL_S = "refreshInterval";
101     public static final String CONFIG_LEGACY_FIRMWARE = "legacyFirmware";
102     public static final String CONFIG_DEVICE_ID = "deviceId";
103     public static final String CONFIG_DEVICE_TYPE = "deviceType";
104
105     // ELRO cmd constants
106     public static final int ELRO_DEVICE_CONTROL = 101;
107     public static final int ELRO_GET_DEVICE_NAME = 14;
108     public static final int ELRO_GET_DEVICE_STATUSES = 15;
109     public static final int ELRO_REC_DEVICE_NAME = 17;
110     public static final int ELRO_REC_DEVICE_STATUS = 119;
111     public static final int ELRO_SYNC_DEVICES = 29;
112
113     public static final int ELRO_DEVICE_JOIN = 2;
114     public static final int ELRO_DEVICE_CANCEL_JOIN = 7;
115     public static final int ELRO_DEVICE_REPLACE = 103;
116     public static final int ELRO_DEVICE_REMOVE = 104;
117     public static final int ELRO_DEVICE_RENAME = 105;
118
119     public static final int ELRO_SELECT_SCENE = 106;
120     public static final int ELRO_GET_SCENE = 18;
121     public static final int ELRO_REC_SCENE = 128;
122     public static final int ELRO_REC_SCENE_NAME = 126;
123     public static final int ELRO_REC_SCENE_TYPE = 127;
124     public static final int ELRO_SYNC_SCENES = 131;
125
126     public static final int ELRO_REC_ALARM = 25;
127
128     public static final int ELRO_IGNORE_YES_NO = 11;
129
130     // Older firmware uses different cmd message codes
131     public static final Map<Integer, Integer> ELRO_LEGACY_MESSAGES = Map.ofEntries(Map.entry(ELRO_DEVICE_CONTROL, 1),
132             Map.entry(ELRO_DEVICE_REPLACE, 3), Map.entry(ELRO_DEVICE_REMOVE, 4), Map.entry(ELRO_DEVICE_RENAME, 5),
133             Map.entry(ELRO_SELECT_SCENE, 6), Map.entry(ELRO_SYNC_SCENES, 31), Map.entry(ELRO_REC_DEVICE_STATUS, 19),
134             Map.entry(ELRO_REC_SCENE, 28), Map.entry(ELRO_REC_SCENE_NAME, 26), Map.entry(ELRO_REC_SCENE_TYPE, 27));
135     public static final Map<Integer, Integer> ELRO_NEW_MESSAGES = ELRO_LEGACY_MESSAGES.entrySet().stream()
136             .collect(Collectors.toUnmodifiableMap(Map.Entry::getValue, Map.Entry::getKey));
137
138     // ELRO device types
139     public enum ElroDeviceType {
140         ENTRY_SENSOR,
141         CO_ALARM,
142         CXSM_ALARM,
143         MOTION_SENSOR,
144         SM_ALARM,
145         POWERSOCKET,
146         THERMAL_ALARM,
147         TH_SENSOR,
148         WT_ALARM,
149         DEFAULT
150     }
151
152     public static final Map<ElroDeviceType, ThingTypeUID> THING_TYPE_MAP = Map.ofEntries(
153             Map.entry(ElroDeviceType.ENTRY_SENSOR, THING_TYPE_ENTRYSENSOR),
154             Map.entry(ElroDeviceType.CO_ALARM, THING_TYPE_COALARM),
155             Map.entry(ElroDeviceType.CXSM_ALARM, THING_TYPE_SMOKEALARM),
156             Map.entry(ElroDeviceType.MOTION_SENSOR, THING_TYPE_MOTIONSENSOR),
157             Map.entry(ElroDeviceType.SM_ALARM, THING_TYPE_SMOKEALARM),
158             Map.entry(ElroDeviceType.THERMAL_ALARM, THING_TYPE_HEATALARM),
159             Map.entry(ElroDeviceType.WT_ALARM, THING_TYPE_WATERALARM),
160             Map.entry(ElroDeviceType.TH_SENSOR, THING_TYPE_THSENSOR),
161             Map.entry(ElroDeviceType.POWERSOCKET, THING_TYPE_POWERSOCKET));
162
163     public static final Map<ElroDeviceType, String> TYPE_NAMES = Map.ofEntries(
164             Map.entry(ElroDeviceType.ENTRY_SENSOR, TYPE_ENTRYSENSOR), Map.entry(ElroDeviceType.CO_ALARM, TYPE_COALARM),
165             Map.entry(ElroDeviceType.CXSM_ALARM, TYPE_SMOKEALARM),
166             Map.entry(ElroDeviceType.MOTION_SENSOR, TYPE_MOTIONSENSOR),
167             Map.entry(ElroDeviceType.SM_ALARM, TYPE_SMOKEALARM),
168             Map.entry(ElroDeviceType.THERMAL_ALARM, TYPE_HEATALARM),
169             Map.entry(ElroDeviceType.WT_ALARM, TYPE_WATERALARM), Map.entry(ElroDeviceType.TH_SENSOR, TYPE_THSENSOR),
170             Map.entry(ElroDeviceType.POWERSOCKET, TYPE_POWERSOCKET));
171
172     public static final Set<String> T_ENTRY_SENSOR = Set.of("0101", "1101", "2101");
173     public static final Set<String> T_POWERSOCKET = Set.of("0200", "1200", "2200");
174     public static final Set<String> T_MOTION_SENSOR = Set.of("0100", "1100", "2100");
175     public static final Set<String> T_CO_ALARM = Set.of("0000", "1000", "2000", "0008", "1008", "2008", "000E", "100E",
176             "200E");
177     public static final Set<String> T_SM_ALARM = Set.of("0001", "1001", "2001", "0009", "1009", "2009", "000F", "100F",
178             "200F");
179     public static final Set<String> T_WT_ALARM = Set.of("0004", "1004", "2004", "000C", "100C", "200C", "0012", "1012",
180             "2012");
181     public static final Set<String> T_TH_SENSOR = Set.of("0102", "1102", "2102");
182     public static final Set<String> T_CXSM_ALARM = Set.of("0005", "1109", "2109", "000D", "100D", "200D", "0013",
183             "1013", "2013");
184     public static final Set<String> T_THERMAL_ALARM = Set.of("0003", "1003", "2003", "000B", "100B", "200B", "0011",
185             "1011", "2011");
186
187     public static final Map<ElroDeviceType, Set<String>> DEVICE_TYPE_MAP = Map.ofEntries(
188             Map.entry(ElroDeviceType.ENTRY_SENSOR, T_ENTRY_SENSOR), Map.entry(ElroDeviceType.CO_ALARM, T_CO_ALARM),
189             Map.entry(ElroDeviceType.CXSM_ALARM, T_CXSM_ALARM),
190             Map.entry(ElroDeviceType.MOTION_SENSOR, T_MOTION_SENSOR), Map.entry(ElroDeviceType.SM_ALARM, T_SM_ALARM),
191             Map.entry(ElroDeviceType.POWERSOCKET, T_POWERSOCKET),
192             Map.entry(ElroDeviceType.THERMAL_ALARM, T_THERMAL_ALARM), Map.entry(ElroDeviceType.TH_SENSOR, T_TH_SENSOR),
193             Map.entry(ElroDeviceType.WT_ALARM, T_WT_ALARM));
194
195     public static final Map<String, ElroDeviceType> TYPE_MAP = DEVICE_TYPE_MAP.entrySet().stream()
196             .flatMap(e -> e.getValue().stream().map(v -> Map.entry(v, e.getKey())))
197             .collect(Collectors.toUnmodifiableMap(Map.Entry::getKey, Map.Entry::getValue));
198
199     // ELRO device status
200     public enum ElroDeviceStatus {
201         NORMAL,
202         TRIGGERED,
203         TEST,
204         SILENCE,
205         OPEN,
206         FAULT,
207         UNDEF
208     }
209
210     // Listener threadname prefix
211     public static final String THREAD_NAME_PREFIX = "binding-";
212 }