]> git.basschouten.com Git - openhab-addons.git/blob
47abd04089cacebac5719d745cf73f893d52bed2
[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.shelly.internal;
14
15 import static org.openhab.binding.shelly.internal.discovery.ShellyThingCreator.*;
16
17 import java.util.Collections;
18 import java.util.Set;
19 import java.util.stream.Collectors;
20 import java.util.stream.Stream;
21
22 import org.eclipse.jdt.annotation.NonNullByDefault;
23 import org.openhab.core.thing.ThingTypeUID;
24
25 /**
26  * The {@link ShellyBindingConstants} class defines common constants, which are
27  * used across the whole binding.
28  *
29  * @author Markus Michels - Initial contribution
30  */
31 @NonNullByDefault
32 public class ShellyBindingConstants {
33
34     public static final String VENDOR = "Shelly";
35     public static final String BINDING_ID = "shelly";
36     public static final String SYSTEM_ID = "system";
37
38     public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(Stream
39             .of(THING_TYPE_SHELLY1, THING_TYPE_SHELLY1L, THING_TYPE_SHELLY1PM, THING_TYPE_SHELLYEM,
40                     THING_TYPE_SHELLY3EM, THING_TYPE_SHELLY2_RELAY, THING_TYPE_SHELLY25_RELAY,
41                     THING_TYPE_SHELLY25_ROLLER, THING_TYPE_SHELLY4PRO, THING_TYPE_SHELLYPLUG, THING_TYPE_SHELLYPLUGS,
42                     THING_TYPE_SHELLYPLUGU1, THING_TYPE_SHELLYUNI, THING_TYPE_SHELLYDIMMER, THING_TYPE_SHELLYDIMMER2,
43                     THING_TYPE_SHELLYIX3, THING_TYPE_SHELLYBULB, THING_TYPE_SHELLYDUO, THING_TYPE_SHELLYVINTAGE,
44                     THING_TYPE_SHELLYDUORGBW, THING_TYPE_SHELLYRGBW2_COLOR, THING_TYPE_SHELLYRGBW2_WHITE,
45                     THING_TYPE_SHELLYHT, THING_TYPE_SHELLYTRV, THING_TYPE_SHELLYSENSE, THING_TYPE_SHELLYEYE,
46                     THING_TYPE_SHELLYSMOKE, THING_TYPE_SHELLYGAS, THING_TYPE_SHELLYFLOOD, THING_TYPE_SHELLYDOORWIN,
47                     THING_TYPE_SHELLYDOORWIN2, THING_TYPE_SHELLYBUTTON1, THING_TYPE_SHELLYBUTTON2,
48                     THING_TYPE_SHELLMOTION, THING_TYPE_SHELLMOTION, THING_TYPE_SHELLYPLUS1, THING_TYPE_SHELLYPLUS1PM,
49                     THING_TYPE_SHELLYPLUS2PM_RELAY, THING_TYPE_SHELLYPLUS2PM_ROLLER, THING_TYPE_SHELLYPRO1,
50                     THING_TYPE_SHELLYPRO1PM, THING_TYPE_SHELLYPRO2_RELAY, THING_TYPE_SHELLYPRO2PM_RELAY,
51                     THING_TYPE_SHELLYPRO2PM_ROLLER, THING_TYPE_SHELLYPRO3, THING_TYPE_SHELLYPRO4PM,
52                     THING_TYPE_SHELLYPLUSI4, THING_TYPE_SHELLYPLUSI4DC, THING_TYPE_SHELLYPLUSHT,
53                     THING_TYPE_SHELLYPLUSPLUGUS, THING_TYPE_SHELLYPROTECTED, THING_TYPE_SHELLYUNKNOWN)
54             .collect(Collectors.toSet()));
55
56     // Thing Configuration Properties
57     public static final String CONFIG_DEVICEIP = "deviceIp";
58     public static final String CONFIG_HTTP_USERID = "userId";
59     public static final String CONFIG_HTTP_PASSWORD = "password";
60     public static final String CONFIG_UPDATE_INTERVAL = "updateInterval";
61
62     public static final String PROPERTY_SERVICE_NAME = "serviceName";
63     public static final String PROPERTY_DEV_NAME = "deviceName";
64     public static final String PROPERTY_DEV_TYPE = "deviceType";
65     public static final String PROPERTY_DEV_MODE = "deviceMode";
66     public static final String PROPERTY_DEV_GEN = "deviceGeneration";
67     public static final String PROPERTY_HWREV = "deviceHwRev";
68     public static final String PROPERTY_HWBATCH = "deviceHwBatch";
69     public static final String PROPERTY_UPDATE_PERIOD = "devUpdatePeriod";
70     public static final String PROPERTY_NUM_RELAYS = "numberRelays";
71     public static final String PROPERTY_NUM_ROLLERS = "numberRollers";
72     public static final String PROPERTY_NUM_METER = "numberMeters";
73     public static final String PROPERTY_LAST_ACTIVE = "lastActive";
74     public static final String PROPERTY_WIFI_NETW = "wifiNetwork";
75     public static final String PROPERTY_UPDATE_STATUS = "updateStatus";
76     public static final String PROPERTY_UPDATE_AVAILABLE = "updateAvailable";
77     public static final String PROPERTY_UPDATE_CURR_VERS = "updateCurrentVersion";
78     public static final String PROPERTY_UPDATE_NEW_VERS = "updateNewVersion";
79     public static final String PROPERTY_COAP_DESCR = "coapDeviceDescr";
80     public static final String PROPERTY_COAP_VERSION = "coapVersion";
81     public static final String PROPERTY_COIOTAUTO = "coiotAutoEnable";
82
83     // Relay
84     public static final String CHANNEL_GROUP_RELAY_CONTROL = "relay";
85     public static final String CHANNEL_OUTPUT_NAME = "outputName";
86     public static final String CHANNEL_OUTPUT = "output";
87     public static final String CHANNEL_INPUT = "input";
88     public static final String CHANNEL_INPUT1 = "input1";
89     public static final String CHANNEL_INPUT2 = "input2";
90     public static final String CHANNEL_BRIGHTNESS = "brightness";
91
92     public static final String CHANNEL_TIMER_AUTOON = "autoOn";
93     public static final String CHANNEL_TIMER_AUTOOFF = "autoOff";
94     public static final String CHANNEL_TIMER_ACTIVE = "timerActive";
95
96     // Roller
97     public static final String CHANNEL_GROUP_ROL_CONTROL = "roller";
98     public static final String CHANNEL_ROL_CONTROL_CONTROL = "control";
99     public static final String CHANNEL_ROL_CONTROL_POS = "rollerpos";
100     public static final String CHANNEL_ROL_CONTROL_FAV = "rollerFav";
101     public static final String CHANNEL_ROL_CONTROL_TIMER = "timer";
102     public static final String CHANNEL_ROL_CONTROL_STATE = "state";
103     public static final String CHANNEL_ROL_CONTROL_STOPR = "stopReason";
104     public static final String CHANNEL_ROL_CONTROL_SAFETY = "safety";
105
106     // Dimmer
107     public static final String CHANNEL_GROUP_DIMMER_CONTROL = CHANNEL_GROUP_RELAY_CONTROL;
108
109     // Power meter
110     public static final String CHANNEL_GROUP_METER = "meter";
111     public static final String CHANNEL_METER_CURRENTWATTS = "currentWatts";
112     public static final String CHANNEL_METER_LASTMIN = "lastPower";
113     public static final String CHANNEL_METER_LASTMIN1 = CHANNEL_METER_LASTMIN + "1";
114     public static final String CHANNEL_METER_TOTALKWH = "totalKWH";
115     public static final String CHANNEL_EMETER_TOTALRET = "returnedKWH";
116     public static final String CHANNEL_EMETER_REACTWATTS = "reactiveWatts";
117     public static final String CHANNEL_EMETER_VOLTAGE = "voltage";
118     public static final String CHANNEL_EMETER_CURRENT = "current";
119     public static final String CHANNEL_EMETER_PFACTOR = "powerFactor";
120
121     public static final String CHANNEL_GROUP_SENSOR = "sensors";
122     public static final String CHANNEL_SENSOR_TEMP = "temperature";
123     public static final String CHANNEL_SENSOR_HUM = "humidity";
124     public static final String CHANNEL_SENSOR_LUX = "lux";
125     public static final String CHANNEL_SENSOR_PPM = "ppm";
126     public static final String CHANNEL_SENSOR_VOLTAGE = "voltage";
127     public static final String CHANNEL_SENSOR_ILLUM = "illumination";
128     public static final String CHANNEL_SENSOR_VIBRATION = "vibration";
129     public static final String CHANNEL_SENSOR_TILT = "tilt";
130     public static final String CHANNEL_SENSOR_FLOOD = "flood";
131     public static final String CHANNEL_SENSOR_SMOKE = "smoke";
132     public static final String CHANNEL_SENSOR_STATE = "state";
133     public static final String CHANNEL_SENSOR_VALVE = "valve";
134     public static final String CHANNEL_SENSOR_SSTATE = "status"; // Shelly Gas
135     public static final String CHANNEL_SENSOR_MOTION_ACT = "motionActive";
136     public static final String CHANNEL_SENSOR_MOTION = "motion";
137     public static final String CHANNEL_SENSOR_MOTION_TS = "motionTimestamp";
138     public static final String CHANNEL_SENSOR_SLEEPTIME = "sensorSleepTime";
139     public static final String CHANNEL_SENSOR_ALARM_STATE = "alarmState";
140     public static final String CHANNEL_SENSOR_ERROR = "lastError";
141
142     // TRV
143     public static final String CHANNEL_CONTROL_SETTEMP = "targetTemp";
144     public static final String CHANNEL_CONTROL_POSITION = "position";
145     public static final String CHANNEL_CONTROL_MODE = "mode";
146     public static final String CHANNEL_CONTROL_BCONTROL = "boost";
147     public static final String CHANNEL_CONTROL_BTIMER = "boostTimer";
148     public static final String CHANNEL_CONTROL_SCHEDULE = "schedule";
149     public static final String CHANNEL_CONTROL_PROFILE = "selectedProfile";
150
151     // External sensors for Shelly1/1PM
152     public static final String CHANNEL_ESENDOR_TEMP1 = CHANNEL_SENSOR_TEMP + "1";
153     public static final String CHANNEL_ESENDOR_TEMP2 = CHANNEL_SENSOR_TEMP + "2";
154     public static final String CHANNEL_ESENDOR_TEMP3 = CHANNEL_SENSOR_TEMP + "3";
155     public static final String CHANNEL_ESENDOR_HUMIDITY = CHANNEL_SENSOR_HUM;
156
157     public static final String CHANNEL_GROUP_CONTROL = "control";
158     public static final String CHANNEL_SENSE_KEY = "key";
159
160     public static final String CHANNEL_GROUP_BATTERY = "battery";
161     public static final String CHANNEL_SENSOR_BAT_LEVEL = "batteryLevel";
162     public static final String CHANNEL_SENSOR_BAT_LOW = "lowBattery";
163
164     public static final String CHANNEL_GROUP_LIGHT_CONTROL = "control";
165     public static final String CHANNEL_LIGHT_COLOR_MODE = "mode";
166     public static final String CHANNEL_LIGHT_POWER = "power";
167     public static final String CHANNEL_LIGHT_DEFSTATE = "defaultState";
168     public static final String CHANNEL_GROUP_LIGHT_CHANNEL = "channel";
169
170     // Bulb/RGBW2 in color mode
171     public static final String CHANNEL_GROUP_COLOR_CONTROL = "color";
172     public static final String CHANNEL_COLOR_PICKER = "hsb";
173     public static final String CHANNEL_COLOR_FULL = "full";
174     public static final String CHANNEL_COLOR_RED = "red";
175     public static final String CHANNEL_COLOR_GREEN = "green";
176     public static final String CHANNEL_COLOR_BLUE = "blue";
177     public static final String CHANNEL_COLOR_WHITE = "white";
178     public static final String CHANNEL_COLOR_GAIN = "gain";
179     public static final String CHANNEL_COLOR_EFFECT = "effect";
180
181     // Bulb/RGBW2/Dup in White Mode
182     public static final String CHANNEL_GROUP_WHITE_CONTROL = "white";
183     public static final String CHANNEL_COLOR_TEMP = "temperature";
184
185     // Device Status
186     public static final String CHANNEL_GROUP_DEV_STATUS = "device";
187     public static final String CHANNEL_DEVST_NAME = "deviceName";
188     public static final String CHANNEL_DEVST_UPTIME = "uptime";
189     public static final String CHANNEL_DEVST_HEARTBEAT = "heartBeat";
190     public static final String CHANNEL_DEVST_RSSI = "wifiSignal";
191     public static final String CHANNEL_DEVST_ITEMP = "internalTemp";
192     public static final String CHANNEL_DEVST_WAKEUP = "wakeupReason";
193     public static final String CHANNEL_DEVST_ALARM = "alarm";
194     public static final String CHANNEL_DEVST_ACCUWATTS = "accumulatedWatts";
195     public static final String CHANNEL_DEVST_ACCUTOTAL = "accumulatedWTotal";
196     public static final String CHANNEL_DEVST_ACCURETURNED = "accumulatedReturned";
197     public static final String CHANNEL_DEVST_CHARGER = "charger";
198     public static final String CHANNEL_DEVST_UPDATE = "updateAvailable";
199     public static final String CHANNEL_DEVST_SELFTTEST = "selfTest";
200     public static final String CHANNEL_DEVST_VOLTAGE = "supplyVoltage";
201     public static final String CHANNEL_DEVST_CALIBRATED = "calibrated";
202
203     public static final String CHANNEL_LED_STATUS_DISABLE = "statusLed";
204     public static final String CHANNEL_LED_POWER_DISABLE = "powerLed";
205     // Button/xi3
206     public static final String CHANNEL_GROUP_STATUS = "status";
207     public static final String CHANNEL_STATUS_EVENTTYPE = "lastEvent";
208     public static final String CHANNEL_STATUS_EVENTTYPE1 = CHANNEL_STATUS_EVENTTYPE + "1";
209     public static final String CHANNEL_STATUS_EVENTTYPE2 = CHANNEL_STATUS_EVENTTYPE + "2";
210     public static final String CHANNEL_STATUS_EVENTCOUNT = "eventCount";
211     public static final String CHANNEL_STATUS_EVENTCOUNT1 = CHANNEL_STATUS_EVENTCOUNT + "1";
212     public static final String CHANNEL_STATUS_EVENTCOUNT2 = CHANNEL_STATUS_EVENTCOUNT + "2";
213
214     // General
215     public static final String CHANNEL_LAST_UPDATE = "lastUpdate";
216     public static final String CHANNEL_EVENT_TRIGGER = "event";
217     public static final String CHANNEL_BUTTON_TRIGGER = "button";
218     public static final String CHANNEL_BUTTON_TRIGGER1 = CHANNEL_BUTTON_TRIGGER + "1";
219     public static final String CHANNEL_BUTTON_TRIGGER2 = CHANNEL_BUTTON_TRIGGER + "2";
220
221     public static final String SERVICE_TYPE = "_http._tcp.local.";
222     public static final String SHELLY_API_MIN_FWVERSION = "v1.8.2";
223     public static final String SHELLY_API_MIN_FWCOIOT = "v1.6";// v1.6.0+
224     public static final String SHELLY_API_FWCOIOT2 = "v1.8";// CoAP 2 with FW 1.8+
225     public static final String SHELLY_API_FW_110 = "v1.10"; // FW 1.10 or newer detected, activates some add feature
226     public static final String SHELLY2_API_MIN_FWVERSION = "v0.10.2"; // Gen 2 minimum FW
227
228     // Alarm types/messages
229     public static final String ALARM_TYPE_NONE = "NONE";
230     public static final String ALARM_TYPE_RESTARTED = "RESTARTED";
231     public static final String ALARM_TYPE_OVERTEMP = "OVERTEMP";
232     public static final String ALARM_TYPE_OVERPOWER = "OVERPOWER";
233     public static final String ALARM_TYPE_OVERLOAD = "OVERLOAD";
234     public static final String ALARM_TYPE_LOADERR = "LOAD_ERROR";
235     public static final String ALARM_TYPE_SENSOR_ERROR = "SENSOR_ERROR";
236     public static final String ALARM_TYPE_LOW_BATTERY = "LOW_BATTERY";
237     public static final String ALARM_TYPE_VALVE_ERROR = "VALVE_ERROR";
238     public static final String EVENT_TYPE_VIBRATION = "VIBRATION";
239
240     // Event types
241     public static final String EVENT_TYPE_RELAY = "relay";
242     public static final String EVENT_TYPE_ROLLER = "roller";
243     public static final String EVENT_TYPE_LIGHT = "light";
244     public static final String EVENT_TYPE_SENSORDATA = "report";
245
246     // URI for the EventServlet
247     public static final String SHELLY1_CALLBACK_URI = "/shelly/event";
248     public static final String SHELLY2_CALLBACK_URI = "/shelly/wsevent";
249
250     public static final int DIM_STEPSIZE = 5;
251
252     // Formatting: Number of scaling digits
253     public static final int DIGITS_NONE = 0;
254     public static final int DIGITS_WATT = 2;
255     public static final int DIGITS_KWH = 3;
256     public static final int DIGITS_VOLT = 1;
257     public static final int DIGITS_TEMP = 1;
258     public static final int DIGITS_LUX = 0;
259     public static final int DIGITS_PERCENT = 1;
260
261     public static final int SHELLY_API_TIMEOUT_MS = 15000;
262     public static final int UPDATE_STATUS_INTERVAL_SECONDS = 3; // check for updates every x sec
263     public static final int UPDATE_SKIP_COUNT = 20; // update every x triggers or when a key was pressed
264     public static final int UPDATE_MIN_DELAY = 15;// update every x triggers or when a key was pressed
265     public static final int UPDATE_SETTINGS_INTERVAL_SECONDS = 60; // check for updates every x sec
266     public static final int HEALTH_CHECK_INTERVAL_SEC = 300; // Health check interval, 5min
267     public static final int VIBRATION_FILTER_SEC = 5; // Absore duplicate vibration events for xx sec
268 }