2 * Copyright (c) 2010-2020 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.shelly.internal;
15 import java.util.Collections;
17 import java.util.stream.Collectors;
18 import java.util.stream.Stream;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.thing.ThingTypeUID;
24 * The {@link ShellyBindingConstants} class defines common constants, which are
25 * used across the whole binding.
27 * @author Markus Michels - Initial contribution
30 public class ShellyBindingConstants {
32 public static final String VENDOR = "Shelly";
33 public static final String BINDING_ID = "shelly";
34 public static final String SYSTEM_ID = "system";
37 public static final String THING_TYPE_SHELLY1_STR = "shelly1";
38 public static final String THING_TYPE_SHELLY1PM_STR = "shelly1pm";
39 public static final String THING_TYPE_SHELLYEM_STR = "shellyem";
40 public static final String THING_TYPE_SHELLY3EM_STR = "shellyem3"; // bad: misspelled product name, it's 3EM
41 public static final String THING_TYPE_SHELLY2_PREFIX = "shellyswitch";
42 public static final String THING_TYPE_SHELLY2_RELAY_STR = "shelly2-relay";
43 public static final String THING_TYPE_SHELLY2_ROLLER_STR = "shelly2-roller";
44 public static final String THING_TYPE_SHELLY25_PREFIX = "shellyswitch25";
45 public static final String THING_TYPE_SHELLY25_RELAY_STR = "shelly25-relay";
46 public static final String THING_TYPE_SHELLY25_ROLLER_STR = "shelly25-roller";
47 public static final String THING_TYPE_SHELLY4PRO_STR = "shelly4pro";
48 public static final String THING_TYPE_SHELLYPLUG_STR = "shellyplug";
49 public static final String THING_TYPE_SHELLYPLUGS_STR = "shellyplugs";
50 public static final String THING_TYPE_SHELLYPLUGU1_STR = "shellyplugu1"; // Shely Plug US
51 public static final String THING_TYPE_SHELLYDIMMER_STR = "shellydimmer";
52 public static final String THING_TYPE_SHELLYDIMMER2_STR = "shellydimmer2";
53 public static final String THING_TYPE_SHELLYIX3_STR = "shellyix3";
54 public static final String THING_TYPE_SHELLYBULB_STR = "shellybulb";
55 public static final String THING_TYPE_SHELLYDUO_STR = "shellybulbduo";
56 public static final String THING_TYPE_SHELLYVINTAGE_STR = "shellyvintage";
57 public static final String THING_TYPE_SHELLYRGBW2_PREFIX = "shellyrgbw2";
58 public static final String THING_TYPE_SHELLYRGBW2_COLOR_STR = "shellyrgbw2-color";
59 public static final String THING_TYPE_SHELLYRGBW2_WHITE_STR = "shellyrgbw2-white";
60 public static final String THING_TYPE_SHELLYHT_STR = "shellyht";
61 public static final String THING_TYPE_SHELLYSMOKE_STR = "shellysmoke";
62 public static final String THING_TYPE_SHELLYGAS_STR = "shellygas";
63 public static final String THING_TYPE_SHELLYFLOOD_STR = "shellyflood";
64 public static final String THING_TYPE_SHELLYDOORWIN_STR = "shellydw";
65 public static final String THING_TYPE_SHELLYDOORWIN2_STR = "shellydw2";
66 public static final String THING_TYPE_SHELLYEYE_STR = "shellyseye";
67 public static final String THING_TYPE_SHELLYSENSE_STR = "shellysense";
68 public static final String THING_TYPE_SHELLYBUTTON1_STR = "shellybutton1";
69 public static final String THING_TYPE_SHELLYPROTECTED_STR = "shellydevice";
70 public static final String THING_TYPE_SHELLYUNKNOWN_STR = "shellyunknown";
73 public static final String SHELLYDT_1 = "SHSW-1";
74 public static final String SHELLYDT_1PM = "SHSW-PM";
75 public static final String SHELLYDT_SHPLG = "SHPLG-1";
76 public static final String SHELLYDT_SHPLG_S = "SHPLG-S";
77 public static final String SHELLYDT_SHPLG_U1 = "SHPLG-U1";
78 public static final String SHELLYDT_SHELLY2 = "SHSW-21";
79 public static final String SHELLYDT_SHELLY25 = "SHSW-25";
80 public static final String SHELLYDT_SHPRO = "SHSW-44";
81 public static final String SHELLYDT_EM = "SHEM";
82 public static final String SHELLYDT_3EM = "SHEM-3";
83 public static final String SHELLYDT_HT = "SHHT-1";
84 public static final String SHELLYDT_DW = "SHDW-1";
85 public static final String SHELLYDT_DW2 = "SHDW-2";
86 public static final String SHELLYDT_SENSE = "SHSEN-1";
87 public static final String SHELLYDT_GAS = "SHGS-1";
88 public static final String SHELLYDT_DIMMER = "SHDM-1";
89 public static final String SHELLYDT_DIMMER2 = "SHDM-2";
90 public static final String SHELLYDT_IX3 = "SHIX3-1";
91 public static final String SHELLYDT_BULB = "SHBLB-1";
92 public static final String SHELLYDT_DUO = "SHBDUO-1";
93 public static final String SHELLYDT_VINTAGE = "SHVIN-1";
94 public static final String SHELLYDT_RGBW2 = "SHRGBW2";
95 public static final String SHELLYDT_BUTTON1 = "SHBTN-1";
97 // List of all Thing Type UIDs
98 public static final ThingTypeUID THING_TYPE_SHELLY1 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY1_STR);
99 public static final ThingTypeUID THING_TYPE_SHELLY1PM = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY1PM_STR);
100 public static final ThingTypeUID THING_TYPE_SHELLYEM = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYEM_STR);
101 public static final ThingTypeUID THING_TYPE_SHELLY3EM = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY3EM_STR);
102 public static final ThingTypeUID THING_TYPE_SHELLY2_RELAY = new ThingTypeUID(BINDING_ID,
103 THING_TYPE_SHELLY2_RELAY_STR);
104 public static final ThingTypeUID THING_TYPE_SHELLY2_ROLLER = new ThingTypeUID(BINDING_ID,
105 THING_TYPE_SHELLY2_ROLLER_STR);
106 public static final ThingTypeUID THING_TYPE_SHELLY25_RELAY = new ThingTypeUID(BINDING_ID,
107 THING_TYPE_SHELLY25_RELAY_STR);
108 public static final ThingTypeUID THING_TYPE_SHELLY25_ROLLER = new ThingTypeUID(BINDING_ID,
109 THING_TYPE_SHELLY25_ROLLER_STR);
110 public static final ThingTypeUID THING_TYPE_SHELLY4PRO = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLY4PRO_STR);
111 public static final ThingTypeUID THING_TYPE_SHELLYPLUG = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUG_STR);
112 public static final ThingTypeUID THING_TYPE_SHELLYPLUGS = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYPLUGS_STR);
113 public static final ThingTypeUID THING_TYPE_SHELLYPLUGU1 = new ThingTypeUID(BINDING_ID,
114 THING_TYPE_SHELLYPLUGU1_STR);
115 public static final ThingTypeUID THING_TYPE_SHELLYDIMMER = new ThingTypeUID(BINDING_ID,
116 THING_TYPE_SHELLYDIMMER_STR);
117 public static final ThingTypeUID THING_TYPE_SHELLYDIMMER2 = new ThingTypeUID(BINDING_ID,
118 THING_TYPE_SHELLYDIMMER2_STR);
119 public static final ThingTypeUID THING_TYPE_SHELLYIX3 = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYIX3_STR);
120 public static final ThingTypeUID THING_TYPE_SHELLYBULB = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYBULB_STR);
121 public static final ThingTypeUID THING_TYPE_SHELLYDUO = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYDUO_STR);
122 public static final ThingTypeUID THING_TYPE_SHELLYVINTAGE = new ThingTypeUID(BINDING_ID,
123 THING_TYPE_SHELLYVINTAGE_STR);
124 public static final ThingTypeUID THING_TYPE_SHELLYHT = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYHT_STR);
125 public static final ThingTypeUID THING_TYPE_SHELLYSENSE = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYSENSE_STR);
126 public static final ThingTypeUID THING_TYPE_SHELLYSMOKE = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYSMOKE_STR);
127 public static final ThingTypeUID THING_TYPE_SHELLYGAS = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYGAS_STR);
128 public static final ThingTypeUID THING_TYPE_SHELLYFLOOD = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYFLOOD_STR);
129 public static final ThingTypeUID THING_TYPE_SHELLYDOORWIN = new ThingTypeUID(BINDING_ID,
130 THING_TYPE_SHELLYDOORWIN_STR);
131 public static final ThingTypeUID THING_TYPE_SHELLYDOORWIN2 = new ThingTypeUID(BINDING_ID,
132 THING_TYPE_SHELLYDOORWIN2_STR);
133 public static final ThingTypeUID THING_TYPE_SHELLYBUTTON1 = new ThingTypeUID(BINDING_ID,
134 THING_TYPE_SHELLYBUTTON1_STR);
135 public static final ThingTypeUID THING_TYPE_SHELLYEYE = new ThingTypeUID(BINDING_ID, THING_TYPE_SHELLYEYE_STR);
136 public static final ThingTypeUID THING_TYPE_SHELLYRGBW2_COLOR = new ThingTypeUID(BINDING_ID,
137 THING_TYPE_SHELLYRGBW2_COLOR_STR);
138 public static final ThingTypeUID THING_TYPE_SHELLYRGBW2_WHITE = new ThingTypeUID(BINDING_ID,
139 THING_TYPE_SHELLYRGBW2_WHITE_STR);
140 public static final ThingTypeUID THING_TYPE_SHELLYPROTECTED = new ThingTypeUID(BINDING_ID,
141 THING_TYPE_SHELLYPROTECTED_STR);
142 public static final ThingTypeUID THING_TYPE_SHELLYUNKNOWN = new ThingTypeUID(BINDING_ID,
143 THING_TYPE_SHELLYUNKNOWN_STR);
145 public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(
146 Stream.of(THING_TYPE_SHELLY1, THING_TYPE_SHELLY1PM, THING_TYPE_SHELLYEM, THING_TYPE_SHELLY3EM,
147 THING_TYPE_SHELLY2_RELAY, THING_TYPE_SHELLY2_ROLLER, THING_TYPE_SHELLY25_RELAY,
148 THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY4PRO, THING_TYPE_SHELLYPLUG, THING_TYPE_SHELLYPLUGS,
149 THING_TYPE_SHELLYPLUGU1, THING_TYPE_SHELLYDIMMER, THING_TYPE_SHELLYDIMMER2, THING_TYPE_SHELLYIX3,
150 THING_TYPE_SHELLYBULB, THING_TYPE_SHELLYDUO, THING_TYPE_SHELLYVINTAGE, THING_TYPE_SHELLYRGBW2_COLOR,
151 THING_TYPE_SHELLYRGBW2_WHITE, THING_TYPE_SHELLYHT, THING_TYPE_SHELLYSENSE, THING_TYPE_SHELLYEYE,
152 THING_TYPE_SHELLYSMOKE, THING_TYPE_SHELLYGAS, THING_TYPE_SHELLYFLOOD, THING_TYPE_SHELLYDOORWIN,
153 THING_TYPE_SHELLYDOORWIN2, THING_TYPE_SHELLYBUTTON1, THING_TYPE_SHELLYPROTECTED,
154 THING_TYPE_SHELLYUNKNOWN).collect(Collectors.toSet()));
156 // Thing Configuration Properties
157 public static final String CONFIG_DEVICEIP = "deviceIp";
158 public static final String CONFIG_HTTP_USERID = "userId";
159 public static final String CONFIG_HTTP_PASSWORD = "password";
160 public static final String CONFIG_UPDATE_INTERVAL = "updateInterval";
162 public static final String PROPERTY_SERVICE_NAME = "serviceName";
163 public static final String PROPERTY_DEV_NAME = "deviceName";
164 public static final String PROPERTY_DEV_TYPE = "deviceType";
165 public static final String PROPERTY_DEV_MODE = "deviceMode";
166 public static final String PROPERTY_HWREV = "deviceHwRev";
167 public static final String PROPERTY_HWBATCH = "deviceHwBatch";
168 public static final String PROPERTY_UPDATE_PERIOD = "devUpdatePeriod";
169 public static final String PROPERTY_NUM_RELAYS = "numberRelays";
170 public static final String PROPERTY_NUM_ROLLERS = "numberRollers";
171 public static final String PROPERTY_NUM_METER = "numberMeters";
172 public static final String PROPERTY_LAST_ACTIVE = "lastActive";
173 public static final String PROPERTY_WIFI_NETW = "wifiNetwork";
174 public static final String PROPERTY_UPDATE_STATUS = "updateStatus";
175 public static final String PROPERTY_UPDATE_AVAILABLE = "updateAvailable";
176 public static final String PROPERTY_UPDATE_CURR_VERS = "updateCurrentVersion";
177 public static final String PROPERTY_UPDATE_NEW_VERS = "updateNewVersion";
178 public static final String PROPERTY_COAP_DESCR = "coapDeviceDescr";
179 public static final String PROPERTY_COAP_VERSION = "coapVersion";
180 public static final String PROPERTY_STATS_TIMEOUTS = "statsTimeoutErrors";
181 public static final String PROPERTY_STATS_TRECOVERED = "statsTimeoutsRecovered";
182 public static final String PROPERTY_COIOTAUTO = "coiotAutoEnable";
183 public static final String PROPERTY_COIOTREFRESH = "coiotAutoRefresh";
186 public static final String CHANNEL_GROUP_RELAY_CONTROL = "relay";
187 public static final String CHANNEL_OUTPUT_NAME = "outputName";
188 public static final String CHANNEL_OUTPUT = "output";
189 public static final String CHANNEL_INPUT = "input";
190 public static final String CHANNEL_INPUT1 = "input1";
191 public static final String CHANNEL_INPUT2 = "input2";
192 public static final String CHANNEL_BRIGHTNESS = "brightness";
194 public static final String CHANNEL_TIMER_AUTOON = "autoOn";
195 public static final String CHANNEL_TIMER_AUTOOFF = "autoOff";
196 public static final String CHANNEL_TIMER_ACTIVE = "timerActive";
199 public static final String CHANNEL_GROUP_ROL_CONTROL = "roller";
200 public static final String CHANNEL_ROL_CONTROL_CONTROL = "control";
201 public static final String CHANNEL_ROL_CONTROL_POS = "rollerpos";
202 public static final String CHANNEL_ROL_CONTROL_TIMER = "timer";
203 public static final String CHANNEL_ROL_CONTROL_STATE = "state";
204 public static final String CHANNEL_ROL_CONTROL_STOPR = "stopReason";
207 public static final String CHANNEL_GROUP_DIMMER_CONTROL = CHANNEL_GROUP_RELAY_CONTROL;
210 public static final String CHANNEL_GROUP_METER = "meter";
211 public static final String CHANNEL_METER_CURRENTWATTS = "currentWatts";
212 public static final String CHANNEL_METER_LASTMIN = "lastPower";
213 public static final String CHANNEL_METER_LASTMIN1 = CHANNEL_METER_LASTMIN + "1";
214 public static final String CHANNEL_METER_TOTALKWH = "totalKWH";
215 public static final String CHANNEL_EMETER_TOTALRET = "returnedKWH";
216 public static final String CHANNEL_EMETER_REACTWATTS = "reactiveWatts";
217 public static final String CHANNEL_EMETER_VOLTAGE = "voltage";
218 public static final String CHANNEL_EMETER_CURRENT = "current";
219 public static final String CHANNEL_EMETER_PFACTOR = "powerFactor";
221 public static final String CHANNEL_GROUP_SENSOR = "sensors";
222 public static final String CHANNEL_SENSOR_TEMP = "temperature";
223 public static final String CHANNEL_SENSOR_HUM = "humidity";
224 public static final String CHANNEL_SENSOR_LUX = "lux";
225 public static final String CHANNEL_SENSOR_PPM = "ppm";
226 public static final String CHANNEL_SENSOR_ILLUM = "illumination";
227 public static final String CHANNEL_SENSOR_VIBRATION = "vibration";
228 public static final String CHANNEL_SENSOR_TILT = "tilt";
229 public static final String CHANNEL_SENSOR_FLOOD = "flood";
230 public static final String CHANNEL_SENSOR_SMOKE = "smoke";
231 public static final String CHANNEL_SENSOR_CONTACT = "state";
232 public static final String CHANNEL_SENSOR_VALVE = "valve";
233 public static final String CHANNEL_SENSOR_SSTATE = "status"; // Shelly Gas
234 public static final String CHANNEL_SENSOR_ALARM_STATE = "alarmState";
235 public static final String CHANNEL_SENSOR_MOTION = "motion";
236 public static final String CHANNEL_SENSOR_ERROR = "lastError";
238 // External sensors for Shelly1/1PM
239 public static final String CHANNEL_ESENDOR_TEMP1 = CHANNEL_SENSOR_TEMP + "1";
240 public static final String CHANNEL_ESENDOR_TEMP2 = CHANNEL_SENSOR_TEMP + "2";
241 public static final String CHANNEL_ESENDOR_TEMP3 = CHANNEL_SENSOR_TEMP + "3";
242 public static final String CHANNEL_ESENDOR_HUMIDITY = CHANNEL_SENSOR_HUM;
244 public static final String CHANNEL_GROUP_SENSE_CONTROL = "control";
245 public static final String CHANNEL_SENSE_KEY = "key";
247 public static final String CHANNEL_GROUP_BATTERY = "battery";
248 public static final String CHANNEL_SENSOR_BAT_LEVEL = "batteryLevel";
249 public static final String CHANNEL_SENSOR_BAT_LOW = "lowBattery";
251 public static final String CHANNEL_GROUP_LIGHT_CONTROL = "control";
252 public static final String CHANNEL_LIGHT_COLOR_MODE = "mode";
253 public static final String CHANNEL_LIGHT_POWER = "power";
254 public static final String CHANNEL_LIGHT_DEFSTATE = "defaultState";
255 public static final String CHANNEL_GROUP_LIGHT_CHANNEL = "channel";
257 // Bulb/RGBW2 in color mode
258 public static final String CHANNEL_GROUP_COLOR_CONTROL = "color";
259 public static final String CHANNEL_COLOR_PICKER = "hsb";
260 public static final String CHANNEL_COLOR_FULL = "full";
261 public static final String CHANNEL_COLOR_RED = "red";
262 public static final String CHANNEL_COLOR_GREEN = "green";
263 public static final String CHANNEL_COLOR_BLUE = "blue";
264 public static final String CHANNEL_COLOR_WHITE = "white";
265 public static final String CHANNEL_COLOR_GAIN = "gain";
266 public static final String CHANNEL_COLOR_EFFECT = "effect";
268 // Bulb/RGBW2/Dup in White Mode
269 public static final String CHANNEL_GROUP_WHITE_CONTROL = "white";
270 public static final String CHANNEL_COLOR_TEMP = "temperature";
273 public static final String CHANNEL_GROUP_DEV_STATUS = "device";
274 public static final String CHANNEL_DEVST_NAME = "deviceName";
275 public static final String CHANNEL_DEVST_UPTIME = "uptime";
276 public static final String CHANNEL_DEVST_HEARTBEAT = "heartBeat";
277 public static final String CHANNEL_DEVST_RSSI = "wifiSignal";
278 public static final String CHANNEL_DEVST_ITEMP = "internalTemp";
279 public static final String CHANNEL_DEVST_WAKEUP = "wakeupReason";
280 public static final String CHANNEL_DEVST_ALARM = "alarm";
281 public static final String CHANNEL_DEVST_ACCUWATTS = "accumulatedWatts";
282 public static final String CHANNEL_DEVST_ACCUTOTAL = "accumulatedWTotal";
283 public static final String CHANNEL_DEVST_ACCURETURNED = "accumulatedReturned";
284 public static final String CHANNEL_DEVST_CHARGER = "charger";
285 public static final String CHANNEL_DEVST_UPDATE = "updateAvailable";
286 public static final String CHANNEL_DEVST_SELFTTEST = "selfTest";
288 public static final String CHANNEL_LED_STATUS_DISABLE = "statusLed";
289 public static final String CHANNEL_LED_POWER_DISABLE = "powerLed";
291 public static final String CHANNEL_GROUP_STATUS = "status";
292 public static final String CHANNEL_STATUS_EVENTTYPE = "lastEvent";
293 public static final String CHANNEL_STATUS_EVENTCOUNT = "eventCount";
296 public static final String CHANNEL_LAST_UPDATE = "lastUpdate";
297 public static final String CHANNEL_EVENT_TRIGGER = "event";
298 public static final String CHANNEL_BUTTON_TRIGGER = "button";
300 public static final String SERVICE_TYPE = "_http._tcp.local.";
301 public static final String SHELLY_API_MIN_FWVERSION = "v1.5.7";// v1.5.7+
302 public static final String SHELLY_API_MIN_FWCOIOT = "v1.6";// v1.6.0+
303 public static final String SHELLY_API_FWCOIOT2 = "v1.8";// CoAP 2 with FW 1.8+
305 // Alarm types/messages
306 public static final String ALARM_TYPE_NONE = "NONE";
307 public static final String ALARM_TYPE_RESTARTED = "RESTARTED";
308 public static final String ALARM_TYPE_OVERTEMP = "OVERTEMP";
309 public static final String ALARM_TYPE_OVERPOWER = "OVERPOWER";
310 public static final String ALARM_TYPE_OVERLOAD = "OVERLOAD";
311 public static final String ALARM_TYPE_LOADERR = "LOAD_ERROR";
312 public static final String ALARM_TYPE_LOW_BATTERY = "LOW_BATTERY";
315 public static final String EVENT_TYPE_RELAY = "relay";
316 public static final String EVENT_TYPE_ROLLER = "roller";
317 public static final String EVENT_TYPE_LIGHT = "light";
318 public static final String EVENT_TYPE_SENSORDATA = "report";
320 // URI for the EventServlet
321 public static final String SHELLY_CALLBACK_URI = "/shelly/event";
323 public static final int DIM_STEPSIZE = 5;
325 // Formatting: Number of scaling digits
326 public static final int DIGITS_NONE = 0;
327 public static final int DIGITS_WATT = 1;
328 public static final int DIGITS_KWH = 3;
329 public static final int DIGITS_VOLT = 1;
330 public static final int DIGITS_TEMP = 1;
331 public static final int DIGITS_LUX = 1;
332 public static final int DIGITS_PERCENT = 1;
334 public static final int SHELLY_API_TIMEOUT_MS = 5000;
335 public static final int UPDATE_STATUS_INTERVAL_SECONDS = 3; // check for updates every x sec
336 public static final int UPDATE_SKIP_COUNT = 20; // update every x triggers or when a key was pressed
337 public static final int UPDATE_MIN_DELAY = 15;// update every x triggers or when a key was pressed
338 public static final int UPDATE_SETTINGS_INTERVAL_SECONDS = 60; // check for updates every x sec
339 public static final int HEALTH_CHECK_INTERVAL_SEC = 300; // Health check interval, 5min