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