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