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