]> git.basschouten.com Git - openhab-addons.git/blob
4cf98d396280352b3dd426ffc1e79e8b6a50a64c
[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.api1;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.openhab.binding.shelly.internal.api1.Shelly1ApiJsonDTO.ShellyStatusSensor.ShellyMotionSettings;
19 import org.openhab.core.thing.CommonTriggerEvents;
20
21 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * The {@link Shelly1ApiJsonDTO} is used for the JSon/GSon mapping
25  *
26  * @author Markus Michels - Initial contribution
27  */
28 public class Shelly1ApiJsonDTO {
29     public static final String SHELLY_NULL_URL = "null";
30     public static final String SHELLY_URL_DEVINFO = "/shelly";
31     public static final String SHELLY_URL_STATUS = "/status";
32     public static final String SHELLY_URL_SETTINGS = "/settings";
33     public static final String SHELLY_URL_SETTINGS_AP = "/settings/ap";
34     public static final String SHELLY_URL_SETTINGS_STA = "/settings/sta";
35     public static final String SHELLY_URL_SETTINGS_LOGIN = "/settings/sta";
36     public static final String SHELLY_URL_SETTINGS_CLOUD = "/settings/cloud";
37     public static final String SHELLY_URL_LIST_IR = "/ir/list";
38     public static final String SHELLY_URL_SEND_IR = "/ir/emit";
39     public static final String SHELLY_URL_RESTART = "/reboot";
40
41     public static final String SHELLY_URL_SETTINGS_RELAY = "/settings/relay";
42     public static final String SHELLY_URL_STATUS_RELEAY = "/status/relay";
43     public static final String SHELLY_URL_CONTROL_RELEAY = "/relay";
44
45     public static final String SHELLY_URL_SETTINGS_EMETER = "/settings/emeter";
46     public static final String SHELLY_URL_STATUS_EMETER = "/emeter";
47     public static final String SHELLY_URL_DATA_EMETER = "/emeter/{0}/em_data.csv";
48
49     public static final String SHELLY_URL_CONTROL_ROLLER = "/roller";
50     public static final String SHELLY_URL_SETTINGS_ROLLER = "/settings/roller";
51
52     public static final String SHELLY_URL_SETTINGS_LIGHT = "/settings/light";
53     public static final String SHELLY_URL_STATUS_LIGHT = "/light";
54     public static final String SHELLY_URL_CONTROL_LIGHT = "/light";
55
56     public static final String SHELLY_URL_SETTINGS_DIMMER = "/settings/light";
57
58     // Wakeup reasons
59     public static final String SHELLY_WAKEUPT_SENSOR = "SENSOR"; // new sensordata
60     public static final String SHELLY_WAKEUPT_PERIODIC = "PERIODIC"; // periodic wakeup
61     public static final String SHELLY_WAKEUPT_BUTTON = "BUTTON"; // button pressed
62     public static final String SHELLY_WAKEUPT_POWERON = "POWERON"; // device powered up
63     public static final String SHELLY_WAKEUPT_EXT_POWER = "EXT_POWER"; // charger connected
64     public static final String SHELLY_WAKEUPT_UNKNOWN = "UNKNOWN"; // other event
65
66     //
67     // Action URLs according to the device type
68     //
69     public static final String SHELLY_EVENTURL_SUFFIX = "_url";
70
71     // Relay
72     public static final String SHELLY_EVENT_BTN_ON = "btn_on";
73     public static final String SHELLY_EVENT_BTN_OFF = "btn_off";
74     public static final String SHELLY_EVENT_OUT_ON = "out_on";
75     public static final String SHELLY_EVENT_OUT_OFF = "out_off";
76     public static final String SHELLY_EVENT_SHORTPUSH = "shortpush";
77     public static final String SHELLY_EVENT_LONGPUSH = "longpush";
78     // Button
79     public static final String SHELLY_EVENT_DOUBLE_SHORTPUSH = "double_shortpush";
80     public static final String SHELLY_EVENT_TRIPLE_SHORTPUSH = "triple_shortpush";
81     public static final String SHELLY_EVENT_SHORT_LONGTPUSH = "shortpush_longpush";
82     public static final String SHELLY_EVENT_LONG_SHORTPUSH = "longpush_shortpush";
83
84     // Dimmer
85     public static final String SHELLY_EVENT_BTN1_ON = "btn1_on";
86     public static final String SHELLY_EVENT_BTN1_OFF = "btn1_off";
87     public static final String SHELLY_EVENT_BTN2_ON = "btn2_on";
88     public static final String SHELLY_EVENT_BTN2_OFF = "btn2_off";
89     public static final String SHELLY_EVENT_SHORTPUSH1 = "btn1_shortpush";
90     public static final String SHELLY_EVENT_LONGPUSH1 = "btn1_longpush";
91     public static final String SHELLY_EVENT_SHORTPUSH2 = "btn2_shortpush";
92     public static final String SHELLY_EVENT_LONGPUSH2 = "btn2_longpush";
93
94     // Roller
95     public static final String SHELLY_EVENT_ROLLER_OPEN = "roller_open";
96     public static final String SHELLY_EVENT_ROLLER_CLOSE = "roller_close";
97     public static final String SHELLY_EVENT_ROLLER_STOP = "roller_stop";
98     public static final String SHELLY_EVENT_ROLLER_CALIB = "roller_calibrating";
99
100     // Roller states
101     public static final String SHELLY_RSTATE_OPEN = "open";
102     public static final String SHELLY_RSTATE_STOP = "stop";
103     public static final String SHELLY_RSTATE_CLOSE = "close";
104
105     // Sensors
106     public static final String SHELLY_EVENT_SENSORREPORT = "report";
107     public static final String SHELLY_EVENT_DARK = "dark";
108     public static final String SHELLY_EVENT_TWILIGHT = "twilight";
109     public static final String SHELLY_EVENT_BRIGHT = "bright";
110     public static final String SHELLY_EVENT_FLOOD_DETECTED = "flood_detected";
111     public static final String SHELLY_EVENT_FLOOD_GONE = "flood_gone";
112     public static final String SHELLY_EVENT_VIBRATION = "vibration"; // DW 1.6.5+
113     public static final String SHELLY_EVENT_OPEN = "open"; // DW 1.6.5+
114     public static final String SHELLY_EVENT_CLOSE = "close"; // DW 1.6.5+
115     public static final String SHELLY_EVENT_TEMP_OVER = "temp_over"; // FW 1.7
116     public static final String SHELLY_EVENT_TEMP_UNDER = "temp_under"; // FW 1.7
117
118     // Gas
119     public static final String SHELLY_EVENT_ALARM_MILD = "alarm_mild"; // DW 1.7+
120     public static final String SHELLY_EVENT_ALARM_HEAVY = "alarm_heavy"; // DW 1.7+
121     public static final String SHELLY_EVENT_ALARM_OFF = "alarm_off"; // DW 1.7+
122
123     //
124     // API values
125     //
126     public static final double SHELLY_API_INVTEMP = -999.0;
127
128     public static final String SHELLY_BTNT_MOMENTARY = "momentary";
129     public static final String SHELLY_BTNT_MOM_ON_RELEASE = "momentary_on_release";
130     public static final String SHELLY_BTNT_ONE_BUTTON = "one_button";
131     public static final String SHELLY_BTNT_TWO_BUTTON = "dual_button";
132     public static final String SHELLY_BTNT_TOGGLE = "toggle";
133     public static final String SHELLY_BTNT_EDGE = "edge";
134     public static final String SHELLY_BTNT_DETACHED = "detached";
135
136     public static final String SHELLY_STATE_LAST = "last";
137     public static final String SHELLY_STATE_STOP = "stop";
138
139     public static final String SHELLY_INP_MODE_OPENCLOSE = "openclose";
140     public static final String SHELLY_INP_MODE_ONEBUTTON = "onebutton";
141
142     public static final String SHELLY_OBSTMODE_DISABLED = "disabled";
143     public static final String SHELLY_SAFETYM_WHILEOPENING = "while_opening";
144
145     public static final String SHELLY_ALWD_TRIGGER_NONE = "none";
146     public static final String SHELLY_ALWD_ROLLER_TURN_OPEN = "open";
147     public static final String SHELLY_ALWD_ROLLER_TURN_CLOSE = "close";
148     public static final String SHELLY_ALWD_ROLLER_TURN_STOP = "stop";
149
150     // API Error Codes
151     public static final String SHELLY_APIERR_UNAUTHORIZED = "Unauthorized";
152     public static final String SHELLY_APIERR_TIMEOUT = "Timeout";
153     public static final String SHELLY_APIERR_NOT_CALIBRATED = "Not calibrated!";
154
155     // API device types / properties
156     public static final String SHELLY_CLASS_RELAY = "relay"; // Relay: relay mode
157     public static final String SHELLY_CLASS_ROLLER = "roller"; // Relay: roller mode
158     public static final String SHELLY_CLASS_LIGHT = "light"; // Bulb: color mode
159     public static final String SHELLY_CLASS_EMETER = "emeter"; // EM/EM3: emeter
160
161     public static final String SHELLY_API_ON = "on";
162     public static final String SHELLY_API_OFF = "off";
163     public static final String SHELLY_API_TRUE = "true";
164     public static final String SHELLY_API_FALSE = "false";
165
166     public static final String SHELLY_API_MODE = "mode";
167     public static final String SHELLY_MODE_RELAY = "relay"; // Relay: relay mode
168     public static final String SHELLY_MODE_ROLLER = "roller"; // Relay: roller mode
169     public static final String SHELLY_MODE_COLOR = "color"; // Bulb/RGBW2: color mode
170     public static final String SHELLY_MODE_WHITE = "white"; // Bulb/RGBW2: white mode
171
172     public static final String SHELLY_LED_STATUS_DISABLE = "led_status_disable";
173     public static final String SHELLY_LED_POWER_DISABLE = "led_power_disable";
174
175     public static final String SHELLY_API_STOPR_NORMAL = "normal";
176     public static final String SHELLY_API_STOPR_SAFETYSW = "safety_switch";
177     public static final String SHELLY_API_STOPR_OBSTACLE = "obstacle";
178     public static final String SHELLY_API_STOPR_OVERPOWER = "overpower";
179
180     public static final String SHELLY_TIMER_AUTOON = "auto_on";
181     public static final String SHELLY_TIMER_AUTOOFF = "auto_off";
182     public static final String SHELLY_TIMER_ACTIVE = "has_timer";
183
184     public static final String SHELLY_LIGHT_TURN = "turn";
185     public static final String SHELLY_LIGHT_DEFSTATE = "def_state";
186     public static final String SHELLY_LIGHTTIMER = "timer";
187
188     public static final String SHELLY_COLOR_RED = "red";
189     public static final String SHELLY_COLOR_BLUE = "blue";
190     public static final String SHELLY_COLOR_GREEN = "green";
191     public static final String SHELLY_COLOR_YELLOW = "yellow";
192     public static final String SHELLY_COLOR_WHITE = "white";
193     public static final String SHELLY_COLOR_GAIN = "gain";
194     public static final String SHELLY_COLOR_BRIGHTNESS = "brightness";
195     public static final String SHELLY_COLOR_TEMP = "temp";
196     public static final String SHELLY_COLOR_EFFECT = "effect";
197
198     public static final int SHELLY_MIN_ROLLER_POS = 0;
199     public static final int SHELLY_MAX_ROLLER_POS = 100;
200     public static final int SHELLY_MIN_BRIGHTNESS = 0;
201     public static final int SHELLY_MAX_BRIGHTNESS = 100;
202     public static final int SHELLY_MIN_GAIN = 0;
203     public static final int SHELLY_MAX_GAIN = 100;
204     public static final int SHELLY_MIN_COLOR = 0;
205     public static final int SHELLY_MAX_COLOR = 255;
206     public static final int SHELLY_DIM_STEPSIZE = 10;
207
208     // color temperature: 3000 = warm, 4750 = white, 6565 = cold; gain: 0..100
209     public static final int MIN_COLOR_TEMP_BULB = 3000;
210     public static final int MAX_COLOR_TEMP_BULB = 6500;
211     public static final int MIN_COLOR_TEMP_DUO = 2700;
212     public static final int MAX_COLOR_TEMP_DUO = 6500;
213     public static final int COLOR_TEMP_RANGE_BULB = MAX_COLOR_TEMP_DUO - MIN_COLOR_TEMP_DUO;
214     public static final int COLOR_TEMP_RANGE_DUO = MAX_COLOR_TEMP_DUO - MIN_COLOR_TEMP_DUO;
215     public static final double MIN_BRIGHTNESS = 0.0;
216     public static final double MAX_BRIGHTNESS = 100.0;
217     public static final double SATURATION_FACTOR = 2.55;
218     public static final double GAIN_FACTOR = SHELLY_MAX_GAIN / 100;
219     public static final double BRIGHTNESS_FACTOR = SHELLY_MAX_BRIGHTNESS / 100;
220
221     // Door/Window
222     public static final String SHELLY_API_ILLUM_DARK = "dark";
223     public static final String SHELLY_API_ILLUM_TWILIGHT = "twilight";
224     public static final String SHELLY_API_ILLUM_BRIGHT = "bright";
225     public static final String SHELLY_API_DWSTATE_OPEN = "open";
226     public static final String SHELLY_API_DWSTATE_CLOSE = "close";
227
228     // Shelly Sense
229     public static final String SHELLY_IR_CODET_STORED = "stored";
230     public static final String SHELLY_IR_CODET_PRONTO = "pronto";
231     public static final String SHELLY_IR_CODET_PRONTO_HEX = "pronto_hex";
232
233     // Bulb/Duo/RGBW2
234     public static final int SHELLY_MIN_EFFECT = 0;
235     public static final int SHELLY_MAX_EFFECT = 6;
236
237     // Button
238     public static final String SHELLY_BTNEVENT_1SHORTPUSH = "S";
239     public static final String SHELLY_BTNEVENT_2SHORTPUSH = "SS";
240     public static final String SHELLY_BTNEVENT_3SHORTPUSH = "SSS";
241     public static final String SHELLY_BTNEVENT_LONGPUSH = "L";
242     public static final String SHELLY_BTNEVENT_SHORTLONGPUSH = "SL";
243     public static final String SHELLY_BTNEVENT_LONGSHORTPUSH = "LS";
244
245     public static final String SHELLY_TEMP_CELSIUS = "C";
246     public static final String SHELLY_TEMP_FAHRENHEIT = "F";
247
248     // Motion
249     public static final int SHELLY_MOTION_SLEEPTIME_OFFSET = 3; // we need to substract and offset
250
251     // TRV
252     public static final int SHELLY_TRV_MIN_TEMP = 5; // < 5: means: lowest (valve fully closed)
253     public static final int SHELLY_TRV_MAX_TEMP = 30; // > 30: means: highest (valve fully open)
254
255     public static final String SHELLY_TRV_MODE_MANUAL = "manual";
256     public static final String SHELLY_TRV_MODE_AUTO = "automatic";
257
258     // CoIoT Multicast setting
259     public static final String SHELLY_COIOT_MCAST = "mcast";
260
261     public static class ShellySettingsDevice {
262         public String type;
263         public String mac;
264         public String hostname;
265         public String fw;
266         public Boolean auth;
267         public Integer gen;
268
269         @SerializedName("coiot") // Shelly Motion Multicast Endpoint
270         public String coiot;
271         public Integer longid;
272
273         @SerializedName("num_outputs")
274         public Integer numOutputs;
275         @SerializedName("num_meters")
276         public Integer numMeters;
277         @SerializedName("num_emeters")
278         public Integer numEMeters;
279         @SerializedName("num_rollers")
280         public Integer numRollers;
281     }
282
283     public static class ShellySettingsWiFiAp {
284         public Boolean enabled;
285         public String ssid;
286         public String key;
287     }
288
289     public static class ShellySettingsWiFiNetwork {
290         public Boolean enabled;
291         public String ssid;
292         public Integer rssi;
293
294         @SerializedName("ipv4_method")
295         public String ipv4Method;
296         public String ip;
297         public String gw;
298         public String mask;
299         public String dns;
300     }
301
302     public static class ShellySettingsMqtt {
303         public Boolean enable;
304         public String server;
305         public String user;
306         @SerializedName("reconnect_timeout_max")
307         public Double reconnectTimeoutMax;
308         @SerializedName("reconnect_timeout_min")
309         public Double reconnectTimeoutMin;
310         @SerializedName("clean_session")
311         public Boolean cleanSession;
312         @SerializedName("keep_alive")
313         public Integer keepAlive;
314         @SerializedName("will_topic")
315         public String willTopic;
316         @SerializedName("will_message")
317         public String willMessage;
318         @SerializedName("max_qos")
319         public Integer maxQOS;
320         public Boolean retain;
321         @SerializedName("update_period")
322         public Integer updatePeriod;
323     }
324
325     public static class ShellySettingsCoiot { // FW 1.6+
326         @SerializedName("update_period")
327         public Integer updatePeriod;
328         public Boolean enabled; // Motion 1.0.7: Coap can be disabled
329         public String peer; // if set the device uses singlecast CoAP, mcast=set back to Multicast
330     }
331
332     public static class ShellyStatusMqtt {
333         public Boolean connected;
334     }
335
336     public static class ShellySettingsSntp {
337         public String server;
338         public Boolean enabled;
339     }
340
341     public static class ShellySettingsLogin {
342         public Boolean enabled;
343         public Boolean unprotected;
344         public String username;
345         public String password;
346     }
347
348     public static class ShellySettingsBuildInfo {
349         @SerializedName("build_id")
350         public String buildId;
351         @SerializedName("build_timestamp")
352         public String buildTimestamp;
353         @SerializedName("build_version")
354         public String buildVersion;
355     }
356
357     public static class ShellyStatusCloud {
358         public Boolean enabled;
359         public Boolean connected;
360     }
361
362     public static class ShellySettingsHwInfo {
363         @SerializedName("hw_revision")
364         public String hwRevision;
365         @SerializedName("batch_id")
366         public Integer batchId;
367     }
368
369     public static class ShellySettingsScheduleRules {
370     }
371
372     public static class ShellySettingsRelay {
373         public String name;
374         @SerializedName("default_state")
375         public String defaultState; // Accepted values: off, on, last, switch
376         @SerializedName("btn_type")
377         public String btnType; // Accepted values: momentary, toggle, edge, detached - // see SHELLY_BTNT_xxx
378         @SerializedName("btn1_type") // Shelly 1L
379         public String btnType1;
380         @SerializedName("btn2_type") // Shelly 1L
381         public String btnType2;
382         @SerializedName("has_timer")
383         public Boolean hasTimer; // Whether a timer is currently armed for this channel
384         @SerializedName("auto_on")
385         public Double autoOn; // Automatic flip back timer, seconds. Will engage after turning Shelly1 OFF.
386         @SerializedName("auto_off")
387         public Double autoOff; // Automatic flip back timer, seconds. Will engage after turning Shelly1 ON.
388         @SerializedName("btn_on_url")
389         public String btnOnUrl; // input is activated
390         @SerializedName("btnOffUrl")
391         public String btnOffUrl; // input is deactivated
392         @SerializedName("out_on_url")
393         public String outOnUrl; // output is activated
394         @SerializedName("out_off_url")
395         public String outOffUrl; // output is deactivated
396         @SerializedName("roller_open_url")
397         public String rollerOpenUrl; // to access when roller reaches open position
398         @SerializedName("roller_close_url")
399         public String rollerCloseUrl; // to access when roller reaches close position
400         @SerializedName("roller_stop_url")
401         public String rollerStopUrl; // to access when roller stopped
402         @SerializedName("longpush_url")
403         public String pushLongUrl; // to access when roller stopped
404         @SerializedName("shortpush_url")
405         public String pushShortUrl; // to access when roller stopped
406
407         // Status information
408         public Boolean ison;
409         public Boolean overpower;
410         @SerializedName("is_valid")
411         public Boolean isValid;
412         @SerializedName("ext_temperature")
413         public ShellyStatusSensor.ShellyExtTemperature extTemperature; // Shelly 1/1PM: sensor values
414         @SerializedName("ext_humidity")
415         public ShellyStatusSensor.ShellyExtHumidity extHumidity; // Shelly 1/1PM: sensor values
416     }
417
418     public static class ShellySettingsDimmer {
419         public String name; // unique name of the device
420         public Boolean ison; // true: output is ON
421         @SerializedName("default_state")
422         public String defaultState; // Accepted values: off, on, last, switch
423         @SerializedName("auto_on")
424         public Double autoOn; // Automatic flip back timer, seconds. Will engage after turning Shelly1 OFF.
425         @SerializedName("auto_off")
426         public Double autoOff; // Automatic flip back timer, seconds. Will engage after turning Shelly1 ON.
427         @SerializedName("btn1_on_url")
428         public String btn1OnUrl; // URL to access when SW input is activated
429         @SerializedName("btn1_off_url")
430         public String btn1OffUrl; // URL to access when SW input is deactivated
431         @SerializedName("btn2_on_url")
432         public String btn2OnUrl; // URL to access when SW input is activated
433         @SerializedName("btn2_off_url")
434         public String btn2OoffUrl; // URL to access when SW input is deactivated
435         @SerializedName("out_on_url")
436         public String outOnUrl; // URL to access when output is activated
437         @SerializedName("out_off_url")
438         public String outOffUrl; // URL to access when output is deactivated
439         @SerializedName("longpush_url")
440         public String pushLongUrl; // long push button event
441         @SerializedName("shortpush_url")
442         public String pushShortUrl; // short push button event
443         @SerializedName("btn_type")
444         public String btnType; // Accepted values: momentary, toggle, edge, detached - // see SHELLY_BTNT_xxx
445         @SerializedName("btn1_type")
446         public String btnType1; // Accepted values: momentary, toggle, edge, detached - // see SHELLY_BTNT_xxx
447         @SerializedName("btn2_type")
448         public String btnType2; // Accepted values: momentary, toggle, edge, detached - // see SHELLY_BTNT_xxx
449         @SerializedName("swap_inputs")
450         public Integer swapInputs; // 0=no
451     }
452
453     public static class ShellySettingsRoller {
454         public Double maxtime;
455         @SerializedName("maxtime_open")
456         public Double maxtimeOpen;
457         @SerializedName("maxtime_close")
458         public Double maxtimeClose;
459         @SerializedName("default_state")
460         public String defaultState; // see SHELLY_STATE_xxx
461         public Boolean swap;
462         @SerializedName("swap_inputs")
463         public Boolean swapInputs;
464         @SerializedName("input_mode")
465         public String inputMode; // see SHELLY_INP_MODE_OPENCLOSE
466         @SerializedName("button_type")
467         public String buttonType; // // see SHELLY_BTNT_xxx
468         @SerializedName("btn_Reverse")
469         public Integer btnReverse;
470         public String state;
471         public Double power;
472         @SerializedName("is_valid")
473         public Boolean isValid;
474         @SerializedName("safety_switch")
475         public Boolean safetySwitch;
476         @SerializedName("obstacle_mode")
477         public String obstaclMode; // SHELLY_OBSTMODE_
478         @SerializedName("obstacle_action")
479         public String obstacleAction; // see SHELLY_STATE_xxx
480         @SerializedName("obstacle_power")
481         public Integer obstaclePower;
482         @SerializedName("obstacle_delay")
483         public Integer obstacleDelay;
484         @SerializedName("safety_mode")
485         public String safetyMode; // see SHELLY_SAFETYM_xxx
486         @SerializedName("safety_action")
487         public String safetyAction; // see SHELLY_STATE_xxx
488         @SerializedName("safety_allowed_on_trigger")
489         public String safetyAllowedOnTrigger; // see SHELLY_ALWD_TRIGGER_xxx
490         @SerializedName("off_power")
491         public Integer offPower;
492         public Boolean positioning;
493     }
494
495     public static class ShellySettingsRgbwLight {
496         public String name;
497         public Boolean ison; // true: output is ON
498         public Integer brightness;
499         public Integer temp;
500         public Integer transition;
501         @SerializedName("default_state")
502         public String defaultState;
503         @SerializedName("auto_on")
504         public Double autoOn; // Automatic flip back timer, seconds. Will engage after turning Shelly1 OFF.
505         @SerializedName("auto_off")
506         public Double autoOff; // Automatic flip back timer, seconds. Will engage after turning Shelly1 ON.
507         public Boolean schedule;
508         @SerializedName("btn_type")
509         public String btnType; // Accepted values: momentary, toggle, edge, detached - // see SHELLY_BTNT_xxx
510         @SerializedName("btn_reverse")
511         public Integer btnReverse; // Accepted values: momentary, toggle, edge, detached - // see SHELLY_BTNT_xxx
512         @SerializedName("out_on_url")
513         public String outOnUrl; // output is activated
514         @SerializedName("out_off_url")
515         public String outOffUrl; // output is deactivated
516     }
517
518     public static class ShellyFavPos { // FW 1.9.2+ in roller mode
519         public String name;
520         public Integer pos;
521     }
522
523     public static class ShellyInputState {
524         public Integer input;
525
526         // Shelly Button
527         public String event;
528         @SerializedName("event_cnt")
529         public Integer eventCount;
530     }
531
532     public static class ShellySettingsMeter {
533         @SerializedName("is_valid")
534         public Boolean isValid;
535         public Double power;
536         public Double[] counters = { 0.0, 0.0, 0.0 };
537         public Double total;
538         public Long timestamp;
539     }
540
541     public static class ShellySettingsEMeter { // ShellyEM meter
542         @SerializedName("is_valid")
543         public Boolean isValid; // Whether the associated meter is functioning properly
544         public Double power; // Instantaneous power, Watts
545         public Double reactive; // Instantaneous reactive power, Watts
546         public Double voltage; // RMS voltage, Volts
547         public Double total; // Total consumed energy, Wh
548         @SerializedName("total_returned")
549         public Double totalReturned; // Total returned energy, Wh
550
551         public Double pf; // 3EM
552         public Double current; // 3EM
553     }
554
555     public static class ShellySettingsUpdate {
556         public String status;
557         @SerializedName("has_update")
558         public Boolean hasUpdate;
559         @SerializedName("new_version")
560         public String newVersion;
561         @SerializedName("old_version")
562         public String oldVersion;
563         @SerializedName("beta_version")
564         public String betaVersion;
565     }
566
567     public static class ShellySettingsGlobal {
568         // https://shelly-api-docs.shelly.cloud/#shelly1pm-settings
569         public ShellySettingsDevice device;
570         @SerializedName("wifi_ap")
571         public ShellySettingsWiFiAp wifiAp;
572         @SerializedName("wifi_sta")
573         public ShellySettingsWiFiNetwork wifiSta;
574         @SerializedName("wifi_sta1")
575         public ShellySettingsWiFiNetwork wifiSta1;
576         @SerializedName("wifirecovery_reboot_enabled")
577         public Boolean wifiRecoveryReboot; // FW 1.10+
578         @SerializedName("ap_roaming")
579         public ShellyApRoaming apRoaming; // FW 1.10+
580
581         public ShellySettingsMqtt mqtt; // not used for now
582         public ShellySettingsSntp sntp; // not used for now
583         public ShellySettingsCoiot coiot; // Firmware 1.6+
584         public ShellySettingsLogin login;
585         @SerializedName("pin_code")
586         public String pinCode;
587         @SerializedName("coiot_execute_enable")
588         public Boolean coiotExecuteEnable;
589         public String name;
590         public Boolean discoverable; // FW 1.6+
591         public String fw;
592         @SerializedName("build_info")
593         public ShellySettingsBuildInfo buildInfo;
594         public ShellyStatusCloud cloud;
595         @SerializedName("sleep_mode")
596         public ShellySensorSleepMode sleepMode; // FW 1.6
597         @SerializedName("external_power")
598         public Integer externalPower; // H&T FW 1.6, seems to be the same like charger for the Sense
599         @SerializedName("debug_enable") // FW 1.10+
600         public Boolean debugEnable;
601
602         public String timezone;
603         public Double lat;
604         public Double lng;
605         public Boolean tzautodetect;
606         public String time;
607
608         public ShellySettingsHwInfo hwinfo;
609         public String mode;
610         @SerializedName("max_power")
611         public Double maxPower;
612         public Boolean calibrated;
613
614         public ArrayList<ShellySettingsRelay> relays;
615         public ArrayList<ShellySettingsRoller> rollers;
616         public ArrayList<ShellySettingsDimmer> dimmers;
617         public ArrayList<ShellySettingsRgbwLight> lights;
618         public ArrayList<ShellySettingsEMeter> emeters;
619         public ArrayList<ShellySettingsInput> inputs; // ix3
620         public ArrayList<ShellyThermnostat> thermostats; // TRV
621
622         public Double voltage; // AC voltage for Shelly 2.5
623         @SerializedName("supply_voltage")
624         public Long supplyVoltage; // Shelly 1PM/1L: 0=110V, 1=220V
625
626         @SerializedName("temperature_units")
627         public String temperatureUnits = "C"; // Either'C'or'F'
628
629         @SerializedName("led_status_disable")
630         public Boolean ledStatusDisable; // PlugS only Disable LED indication for network
631                                          // status
632         @SerializedName("led_power_disable")
633         public Boolean ledPowerDisable; // PlugS only Disable LED indication for network
634                                         // status
635         @SerializedName("light_sensor")
636         public String lightSensor; // Sense: sensor type
637         @SerializedName("rain_sensor")
638         public Boolean rainSensor; // Flood: true=in rain mode
639
640         // FW 1.5.7: Door Window
641         @SerializedName("dark_treshold")
642         public Integer darkTreshold; // Illumination definition for "dark" in lux
643         @SerializedName("twilight_treshold")
644         public Integer twiLightTreshold; // Illumination definition for "twilight" in lux
645         @SerializedName("dark_url")
646         public String darkUrl; // URL to report to when luminance <= dark_threshold
647         @SerializedName("twilight_url")
648         public String twiLightUrl; // URL reports when luminance > dark_threshold AND luminance <=
649         @SerializedName("close_url")
650         public String closeUrl; // URL reports when DW contact is closed FW 1.6.5+
651         @SerializedName("vibration_url")
652         public String vibrationUrl; // URL reports when DW detects vibration FW 1.6.5+
653
654         // Gas FW 1.7
655         @SerializedName("set_volume")
656         public Integer volume; // Speaker volume for alarm
657         @SerializedName("alarm_off_url")
658         public String alarmOffUrl; // URL reports when alarm went off
659         @SerializedName("alarm_mild_url")
660         public String alarmMidUrl; // URL reports middle alarm
661         @SerializedName("alarm_heavy_url")
662         public String alarmHeavyfUrl; // URL reports heavy alarm
663
664         // Roller with FW 1.9.2+
665         @SerializedName("favorites_enabled")
666         public Boolean favoritesEnabled = false;
667         public ArrayList<ShellyFavPos> favorites;
668
669         // Motion
670         public ShellyMotionSettings motion;
671         @SerializedName("tamper_sensitivity")
672         public Integer tamperSensitivity;
673         @SerializedName("dark_threshold")
674         public Integer darkThreshold;
675         @SerializedName("twilight_threshold")
676         public Integer twilightThreshold;
677
678         @SerializedName("sleep_time") // Shelly Motion
679         public Integer sleepTime;
680     }
681
682     public static class ShellySettingsAttributes {
683         @SerializedName("device_type")
684         public String deviceType; // Device model identifier
685         @SerializedName("device_mac")
686         public String deviceMac; // MAC address of the device in hexadecimal
687         @SerializedName("wifi_ap")
688         public String wifiAp; // WiFi access poInteger configuration, see /settings/ap for details
689         @SerializedName("wifi_sta")
690         public String wifiSta; // WiFi client configuration. See /settings/sta for details
691         public String login; // credentials used for HTTP Basic authentication for the REST interface. If
692                              // enabled is true clients must include an Authorization: Basic ... HTTP header with valid
693                              // credentials when performing TP requests.
694         public String name; // unique name of the device.
695         public String fw; // current FW version
696     }
697
698     public static class ShellyActionsStats {
699         public Integer skipped;
700     }
701
702     public static class ShellySettingsStatus {
703         public String name; // FW 1.8: Symbolic Device name is configurable
704
705         @SerializedName("wifi_sta")
706         public ShellySettingsWiFiNetwork wifiSta; // WiFi client configuration. See /settings/sta for details
707         public ShellyStatusCloud cloud;
708         public ShellyStatusMqtt mqtt;
709
710         public String time;
711         public Integer serial = -1;
712         @SerializedName("has_update")
713         public Boolean hasUpdate;
714         public String mac;
715         public Boolean discoverable; // FW 1.6+
716         @SerializedName("cfg_changed_cnt")
717         public Integer cfgChangedCount; // FW 1.8
718         @SerializedName("actions_stats")
719         public ShellyActionsStats astats;
720
721         public ArrayList<ShellySettingsRelay> relays;
722         public Double voltage; // Shelly 2.5
723
724         public ArrayList<ShellySettingsRoller> rollers;
725         public Integer input; // RGBW2 has no JSON array
726         public ArrayList<ShellyInputState> inputs;
727         public ArrayList<ShellySettingsLight> lights;
728         public ArrayList<ShellyShortLightStatus> dimmers;
729         public ArrayList<ShellySettingsMeter> meters;
730         public ArrayList<ShellySettingsEMeter> emeters;
731
732         // Internal device temp
733         public ShellySensorTmp tmp; // Shelly 1PM
734         public Double temperature = SHELLY_API_INVTEMP; // Shelly 2.5
735         public Boolean overtemperature;
736
737         // Shelly Dimmer only
738         public Boolean loaderror;
739         public Boolean overload;
740
741         // Shelly TRV
742         public Boolean calibrated;
743         public ArrayList<ShellyThermnostat> thermostats;
744
745         public ShellySettingsUpdate update;
746         @SerializedName("ram_total")
747         public Long ramTotal;
748         @SerializedName("ram_free")
749         public Long ramFree;
750         @SerializedName("fs_size")
751         public Long fsSize;
752         @SerializedName("fs_free")
753         public Long fsFree;
754         public Long uptime;
755
756         @SerializedName("sleep_time") // Shelly Motion
757         public Integer sleepTime;
758
759         public String json;
760     }
761
762     public static class ShellySettingsInput {
763         @SerializedName("btn_type")
764         public String btnType;
765     }
766
767     public static class ShellyControlRelay {
768         // https://shelly-api-docs.shelly.cloud/#shelly1-1pm-settings-relay-0
769         @SerializedName("is_valid")
770         public Boolean isValid;
771         @SerializedName("has_timer")
772         public Boolean hasTimer; // Whether a timer is currently armed for this channel
773         @SerializedName("timer_remaining")
774         public Integer timerRemaining; // FW 1.6+
775         public Boolean overpower; // Shelly1PM only if maximum allowed power was exceeded
776
777         public String turn; // Accepted values are on and off. This will turn ON/OFF the respective output
778                             // channel when request is sent .
779         public Integer timer; // A one-shot flip-back timer in seconds.
780     }
781
782     public static class ShellyShortStatusRelay {
783         public String name; // FW 1.8+: Channel could now have a logical name
784         @SerializedName("is_valid")
785         public Boolean isValid;
786         public Boolean ison; // Whether output channel is on or off
787         @SerializedName("has_timer")
788         public Boolean hasTimer; // Whether a timer is currently armed for this channel
789         @SerializedName("timer_remaining")
790         public Integer timerRemaining;
791         public Boolean overpower; // Shelly1PM only if maximum allowed power was exceeded
792         public Double temperature; // Internal device temperature
793         public Boolean overtemperature; // Device over heated
794     }
795
796     public static class ShellyShortLightStatus {
797         public Boolean ison; // Whether output channel is on or off
798         public String mode; // color or white - valid only for Bulb and RGBW2 even Dimmer returns it also
799         public Integer brightness; // brightness: 0.100%
800
801         @SerializedName("has_timer")
802         public Boolean hasTimer;
803     }
804
805     public static class ShellyStatusRelay {
806         public String name; // FW 1.8: Symbolic channel name is configurable
807
808         @SerializedName("wifi_sta")
809         public ShellySettingsWiFiNetwork wifiSta; // WiFi status
810         public ShellySettingsCoiot coiot; // Firmware 1.6+
811         public Integer serial;
812         public String mac; // MAC
813         public ArrayList<ShellyShortStatusRelay> relays; // relay status
814         public ArrayList<ShellySettingsMeter> meters; // current meter value
815         public ArrayList<ShellyInputState> inputs; // Firmware 1.5.6+
816
817         @SerializedName("ext_temperature")
818         public ShellyStatusSensor.ShellyExtTemperature extTemperature; // Shelly 1/1PM: sensor values
819         @SerializedName("ext_humidity")
820         public ShellyStatusSensor.ShellyExtHumidity extHumidity; // Shelly 1/1PM: sensor values
821
822         public Double temperature; // device temp acc. on the selected temp unit
823         public ShellySensorTmp tmp;
824     }
825
826     public static class ShellyStatusDimmer {
827         @SerializedName("wifi_sta")
828         public ShellySettingsWiFiNetwork wifiSta; // WiFi status
829         public ArrayList<ShellyShortLightStatus> lights; // relay status
830         public ArrayList<ShellySettingsMeter> meters; // current meter value
831
832         public ShellySensorTmp tmp;
833         public Boolean overtemperature;
834
835         public Boolean loaderror;
836         public Boolean overload;
837     }
838
839     public static class ShellyRollerStatus {
840         public String name; // FW 1.8: Symbolic name is configurable
841
842         @SerializedName("roller_pos")
843         public Integer rollerPos; // number Desired position in percent
844         public Integer duration; // If specified, the motor will move for this period in seconds. If missing, the
845                                  // value of maxtime in /settings/roller/N will be used.
846         public String state; // One of stop, open, close
847         public Double power; // Current power consumption in Watts
848         @SerializedName("is_valid")
849         public Boolean isValid; // If the power meter functions properly
850         @SerializedName("safety_switch")
851         public Boolean safetySwitch; // Whether the safety input is currently triggered
852         public Boolean overtemperature;
853         @SerializedName("stop_reason")
854         public String stopReason; // Last cause for stopping: normal, safety_switch, obstacle
855         @SerializedName("last_direction")
856         public String lastDirection; // Last direction of motion, open or close
857         public Boolean calibrating;
858         public Boolean positioning; // true when calibration was performed
859         @SerializedName("current_pos")
860         public Integer currentPos; // current position 0..100, 100=open
861     }
862
863     public static class ShellyOtaCheckResult {
864         public String status;
865     }
866
867     public static class ShellyApRoaming {
868         public Boolean enabled;
869         public Integer threshold;
870     }
871
872     public static class ShellySensorSleepMode {
873         public Integer period;
874         public String unit;
875     }
876
877     // Shelly TRV
878     public class ShellyThermnostat {
879         public class ShellyThermTargetTemp {
880             public Boolean enabled;
881             public Double value;
882             public String unit;
883         }
884
885         public class ShellyThermTemp {
886             public Double value;
887             public String units;
888             @SerializedName("is_valid")
889             public Boolean isValid;
890         }
891
892         public Double pos;
893         @SerializedName("target_t")
894         public ShellyThermTargetTemp targetTemp;
895         public Boolean schedule;
896         @SerializedName("schedule_profile")
897         public Integer profile;
898         @SerializedName("schedule_profile_names")
899         public String[] profileNames;
900         public ShellyThermTemp tmp;
901         @SerializedName("boost_minutes")
902         public Integer boostMinutes;
903     }
904
905     public static class ShellySensorTmp {
906         public Double value; // Temperature in configured unites
907         public String units; // 'C' or 'F'
908         public Double tC; // temperature in deg C
909         public Double tF; // temperature in deg F
910         @SerializedName("is_valid")
911         public Boolean isValid; // whether the internal sensor is operating properly
912     }
913
914     public static class ShellyStatusSensor {
915         // https://shelly-api-docs.shelly.cloud/#h-amp-t-settings
916         public static class ShellySensorHum {
917             public Double value; // relative humidity in %
918         }
919
920         public static class ShellySensorBat {
921             public Double value; // estimated remaining battery capacity in %
922             public Double voltage; // battery voltage
923         };
924
925         // Door/Window sensor
926         public static class ShellySensorState {
927             @SerializedName("is_valid")
928             public Boolean isValid; // whether the internal sensor is operating properly
929             public String state; // Shelly Door/Window
930
931             // Shelly Motion
932             public Boolean motion;
933             public Boolean vibration;
934             @SerializedName("timestamp")
935             public Long motionTimestamp;
936             @SerializedName("active")
937             public Boolean motionActive;
938         }
939
940         public static class ShellySensorLux {
941             @SerializedName("is_valid")
942             public Boolean isValid; // whether the internal sensor is operating properly
943             public Double value;
944
945             public String illumination;
946         }
947
948         public static class ShellySensorAccel {
949             public Integer tilt; // Tilt in °
950             public Integer vibration; // Whether vibration is detected
951         }
952
953         public static class ShellyMotionSettings {
954             public Integer sensitivity;
955             @SerializedName("blind_time_minutes")
956             public Integer blindTimeMinutes;
957             @SerializedName("pulse_count")
958             public Integer pulseCount;
959             @SerializedName("operating_mode")
960             public Integer operatingMode;
961             public Boolean enabled;
962         }
963
964         public static class ShellyExtTemperature {
965             public static class ShellyShortTemp {
966                 public Double tC; // temperature in deg C
967                 public Double tF; // temperature in deg F
968             }
969
970             // Shelly 1/1PM have up to 3 sensors
971             // for whatever reasons it's not an array, but 3 independent elements
972             @SerializedName("0")
973             public ShellyShortTemp sensor1;
974             @SerializedName("1")
975             public ShellyShortTemp sensor2;
976             @SerializedName("2")
977             public ShellyShortTemp sensor3;
978         }
979
980         public static class ShellyExtHumidity {
981             public static class ShellyShortHum {
982                 public Double hum; // Humidity reading of sensor 0, percent
983             }
984
985             // Shelly 1/1PM have up to 3 sensors
986             // for whatever reasons it's not an array, but 3 independent elements
987             @SerializedName("0")
988             public ShellyShortHum sensor1;
989         }
990
991         public static class ShellyADC {
992             public Double voltage;
993         }
994
995         public ShellySensorTmp tmp;
996         public ShellySensorHum hum;
997         public ShellySensorLux lux;
998         public ShellySensorAccel accel;
999         public ShellySensorBat bat;
1000         @SerializedName("sensor")
1001         public ShellySensorState sensor;
1002         public Boolean smoke; // SHelly Smoke
1003         public Boolean flood; // Shelly Flood: true = flood condition detected
1004         @SerializedName("rain_sensor")
1005         public Boolean rainSensor; // Shelly Flood: true=in rain mode
1006
1007         public Boolean motion; // Shelly Sense: true=motion detected
1008         public Boolean charger; // Shelly Sense, TRV: true=charger connected
1009
1010         @SerializedName("act_reasons")
1011         public List<Object> actReasons; // HT/Smoke/Flood: list of reasons which woke up the device
1012
1013         @SerializedName("sensor_error")
1014         public String sensorError; // 1.5.7: Only displayed in case of error
1015
1016         // FW 1.7: Shelly Gas
1017         @SerializedName("gas_sensor")
1018         public ShellyStatusGasSensor gasSensor;
1019         @SerializedName("concentration")
1020         public ShellyStatusGasConcentration concentration;
1021         public ArrayList<ShellyStatusValve> valves;
1022
1023         // FW 1.7 Button
1024         @SerializedName("connect_retries")
1025         public Integer connectRetries;
1026         public ArrayList<ShellyInputState> inputs; // Firmware 1.5.6+
1027
1028         // Shelly UNI FW 1.9+
1029         public ArrayList<ShellyADC> adcs;
1030
1031         // Shelly TRV
1032         public Boolean calibrated;
1033         public ArrayList<ShellyThermnostat> thermostats;
1034     }
1035
1036     public static class ShellySettingsSmoke {
1037         @SerializedName("temperature_units")
1038         public String temperatureUnits; // Either 'C' or 'F'
1039         @SerializedName("temperature_threshold")
1040         public Integer temperatureThreshold; // Temperature delta (in configured degree units) which triggers an update
1041         @SerializedName("sleep_mode_period")
1042         public Integer sleepModePeriod; // Periodic update period in hours, between 1 and 24
1043     }
1044
1045     // Shelly Gas
1046     // "gas_sensor":{"sensor_state":"normal","self_test_state":"not_completed","alarm_state":"none"},
1047     // "concentration":{"ppm":0,"is_valid":true},
1048     public static class ShellyStatusGasSensor {
1049         @SerializedName("sensor_state")
1050         public String sensorState;
1051         @SerializedName("self_test_state")
1052         public String selfTestState;
1053         @SerializedName("alarm_state")
1054         public String alarmState;
1055     }
1056
1057     public static class ShellyStatusGasConcentration {
1058         public Integer ppm;
1059         @SerializedName("is_valid")
1060         public Boolean isValid;
1061     }
1062
1063     public static class ShellyStatusValve {
1064         public String state; // closed/opened/not_connected/failure/closing/opening/checking
1065     }
1066
1067     public static class ShellySettingsLight {
1068         public Integer red; // red brightness, 0..255, applies in mode="color"
1069         public Integer green; // green brightness, 0..255, applies in mode="color"
1070         public Integer blue; // blue brightness, 0..255, applies in mode="color"
1071         public Integer white; // white brightness, 0..255, applies in mode="color"
1072         public Integer gain; // gain for all channels, 0..100, applies in mode="color"
1073         public Integer temp; // color temperature in K, 3000..6500, applies in mode="white"
1074         public Integer brightness; // brightness, 0..100, applies in mode="white"
1075         public Integer effect; // Currently applied effect, description: 0: Off, 1: Meteor Shower, 2: Gradual
1076                                // Change, 3: Breath,
1077                                // 4: Flash, 5: On/Off Gradual, 6: Red/Green Change
1078         @SerializedName("default_state")
1079         public String defaultState; // one of on, off or last
1080         @SerializedName("auto_on")
1081         public Double autoOn; // see above
1082         @SerializedName("auto_off")
1083         public Double autoOff; // see above
1084
1085         public Integer dcpower; // RGW2:Set to true for 24 V power supply, false for 12 V
1086
1087         // Shelly Dimmer
1088         public String mode;
1089         public Boolean ison;
1090     }
1091
1092     public static class ShellySettingsNightMode { // FW1.5.7+
1093         public Integer enabled;
1094         @SerializedName("start_time")
1095         public String startTime;
1096         @SerializedName("end_time")
1097         public String endTime;
1098         public Integer brightness;
1099     }
1100
1101     public static class ShellyStatusLightChannel {
1102         public Boolean ison;
1103         public Double power;
1104         public Boolean overpower;
1105         @SerializedName("has_timer")
1106         public Boolean hasTimer;
1107         @SerializedName("timer_started")
1108         public Integer timerStarted;
1109         @SerializedName("timer_duration")
1110         public Integer timerDuration;
1111         @SerializedName("timer_remaining")
1112         public Integer timerRemaining;
1113
1114         public Integer red; // red brightness, 0..255, applies in mode="color"
1115         public Integer green; // green brightness, 0..255, applies in mode="color"
1116         public Integer blue; // blue brightness, 0..255, applies in mode="color"
1117         public Integer white; // white brightness, 0..255, applies in mode="color"
1118         public Integer gain; // gain for all channels, 0..100, applies in mode="color"
1119         public Integer temp; // color temperature in K, 3000..6500, applies in mode="white"
1120         public Integer brightness; // brightness, 0..100, applies in mode="white"
1121         public Integer effect; // Currently applied effect, description: 0: Off, 1: Meteor Shower, 2: Gradual
1122                                // Change, 3: Breath,
1123     }
1124
1125     public static class ShellyStatusLight {
1126         public Boolean ison; // Whether output channel is on or off
1127         public Integer input;
1128
1129         public ArrayList<ShellyStatusLightChannel> lights;
1130         public ArrayList<ShellySettingsMeter> meters;
1131     }
1132
1133     public static class ShellySenseKeyCode {
1134         String id; // ID of the stored IR code into Shelly Sense.
1135         String name; // Short description or name of the stored IR code.
1136     }
1137
1138     public static class ShellySendKeyList {
1139         @SerializedName("key_codes")
1140         public ArrayList<ShellySenseKeyCode> keyCodes;
1141     }
1142
1143     /**
1144      * Shelly Dimmer returns light[]. However, the structure doesn't match the lights[] of a Bulb/RGBW2.
1145      * The tag lights[] will be replaced with dimmers[] so this could be mapped to a different Gson structure.
1146      * The function requires that it's only called when the device is a dimmer - on get settings and get status
1147      *
1148      * @param json Input Json as received by the API
1149      * @return Modified Json
1150      */
1151     public static String fixDimmerJson(String json) {
1152         return !json.contains("\"lights\":[") ? json
1153                 : json.replaceFirst(java.util.regex.Pattern.quote("\"lights\":["), "\"dimmers\":[");
1154     }
1155
1156     /**
1157      * Convert Shelly Button events into OH button states
1158      *
1159      * @param eventType S/SS/SSS or L
1160      * @return OH button states
1161      */
1162     public static String mapButtonEvent(String eventType) {
1163         // decode different codings
1164         // 0..2: CoAP
1165         // S/SS/SSS/L: CoAP for Button and xi3
1166         // shortpush/double_shortpush/triple_shortpush/longpush: REST
1167         switch (eventType) {
1168             case "0":
1169                 return CommonTriggerEvents.RELEASED;
1170             case "1":
1171             case SHELLY_BTNEVENT_1SHORTPUSH:
1172             case SHELLY_EVENT_SHORTPUSH:
1173                 return CommonTriggerEvents.SHORT_PRESSED;
1174             case SHELLY_BTNEVENT_2SHORTPUSH:
1175             case SHELLY_EVENT_DOUBLE_SHORTPUSH:
1176                 return CommonTriggerEvents.DOUBLE_PRESSED;
1177             case SHELLY_BTNEVENT_3SHORTPUSH:
1178             case SHELLY_EVENT_TRIPLE_SHORTPUSH:
1179                 return "TRIPLE_PRESSED";
1180             case "2":
1181             case SHELLY_BTNEVENT_LONGPUSH:
1182             case SHELLY_EVENT_LONGPUSH:
1183                 return CommonTriggerEvents.LONG_PRESSED;
1184             case SHELLY_BTNEVENT_SHORTLONGPUSH:
1185             case SHELLY_EVENT_SHORT_LONGTPUSH:
1186                 return "SHORT_LONG_PRESSED";
1187             case SHELLY_BTNEVENT_LONGSHORTPUSH:
1188             case SHELLY_EVENT_LONG_SHORTPUSH:
1189                 return "LONG_SHORT_PRESSED";
1190             default:
1191                 return "";
1192         }
1193     }
1194 }