]> git.basschouten.com Git - openhab-addons.git/blob
ce204a8548b771ceae039dbe43249dda2b6525e8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.shelly.internal.api2;
14
15 import java.util.ArrayList;
16
17 import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusResult;
18 import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2RpcBaseMessage.Shelly2RpcMessageError;
19
20 import com.google.gson.annotations.SerializedName;
21
22 /**
23  * {@link Shelly2ApiJsonDTO} wraps the Shelly REST API and provides various low level function to access the device api
24  * (not
25  * cloud api).
26  *
27  * @author Markus Michels - Initial contribution
28  */
29 public class Shelly2ApiJsonDTO {
30     public static final String SHELLYRPC_METHOD_CLASS_SHELLY = "Shelly";
31     public static final String SHELLYRPC_METHOD_CLASS_SWITCH = "Switch";
32
33     public static final String SHELLYRPC_METHOD_GETDEVCONFIG = "GetDeviceInfo";
34     public static final String SHELLYRPC_METHOD_GETSYSCONFIG = "GetSysConfig"; // only sys
35     public static final String SHELLYRPC_METHOD_GETCONFIG = "GetConfig"; // sys + components
36     public static final String SHELLYRPC_METHOD_GETSYSSTATUS = "GetSysStatus"; // only sys
37     public static final String SHELLYRPC_METHOD_GETSTATUS = "GetStatus"; // sys + components
38     public static final String SHELLYRPC_METHOD_REBOOT = "Shelly.Reboot";
39     public static final String SHELLYRPC_METHOD_RESET = "Shelly.FactoryReset";
40     public static final String SHELLYRPC_METHOD_CHECKUPD = "Shelly.CheckForUpdate";
41     public static final String SHELLYRPC_METHOD_UPDATE = "Shelly.Update";
42     public static final String SHELLYRPC_METHOD_AUTHSET = "Shelly.SetAuth";
43     public static final String SHELLYRPC_METHOD_SWITCH_STATUS = "Switch.GetStatus";
44     public static final String SHELLYRPC_METHOD_SWITCH_SET = "Switch.Set";
45     public static final String SHELLYRPC_METHOD_SWITCH_SETCONFIG = "Switch.SetConfig";
46     public static final String SHELLYRPC_METHOD_COVER_SETPOS = "Cover.GoToPosition";
47     public static final String SHELLY2_COVER_CMD_OPEN = "Open";
48     public static final String SHELLY2_COVER_CMD_CLOSE = "Close";
49     public static final String SHELLY2_COVER_CMD_STOP = "Stop";
50     public static final String SHELLYRPC_METHOD_WIFIGETCONG = "Wifi.GetConfig";
51     public static final String SHELLYRPC_METHOD_WIFISETCONG = "Wifi.SetConfig";
52     public static final String SHELLYRPC_METHOD_ETHGETCONG = "Eth.GetConfig";
53     public static final String SHELLYRPC_METHOD_ETHSETCONG = "Eth.SetConfig";
54     public static final String SHELLYRPC_METHOD_BLEGETCONG = "BLE.GetConfig";
55     public static final String SHELLYRPC_METHOD_BLESETCONG = "BLE.SetConfig";
56     public static final String SHELLYRPC_METHOD_CLOUDSET = "Cloud.SetConfig";
57     public static final String SHELLYRPC_METHOD_WSGETCONFIG = "WS.GetConfig";
58     public static final String SHELLYRPC_METHOD_WSSETCONFIG = "WS.SetConfig";
59
60     public static final String SHELLYRPC_METHOD_NOTIFYSTATUS = "NotifyStatus"; // inbound status
61     public static final String SHELLYRPC_METHOD_NOTIFYFULLSTATUS = "NotifyFullStatus"; // inbound status from bat device
62     public static final String SHELLYRPC_METHOD_NOTIFYEVENT = "NotifyEvent"; // inbound event
63
64     // Component types
65     public static final String SHELLY2_PROFILE_RELAY = "switch";
66     public static final String SHELLY2_PROFILE_ROLLER = "cover";
67
68     // Button types/modes
69     public static final String SHELLY2_BTNT_MOMENTARY = "momentary";
70     public static final String SHELLY2_BTNT_FLIP = "flip";
71     public static final String SHELLY2_BTNT_FOLLOW = "follow";
72     public static final String SHELLY2_BTNT_DETACHED = "detached";
73
74     // Input types
75     public static final String SHELLY2_INPUTT_SWITCH = "switch";
76     public static final String SHELLY2_INPUTT_BUTTON = "button";
77
78     // Switcm modes
79     public static final String SHELLY2_API_MODE_DETACHED = "detached";
80     public static final String SHELLY2_API_MODE_FOLLOW = "follow";
81
82     // Initial switch states
83     public static final String SHELLY2_API_ISTATE_ON = "on";
84     public static final String SHELLY2_API_ISTATE_OFF = "off";
85     public static final String SHELLY2_API_ISTATE_FOLLOWLAST = "restore_last";
86     public static final String SHELLY2_API_ISTATE_MATCHINPUT = "match_input";
87
88     // Cover/Roller modes
89     public static final String SHELLY2_RMODE_SINGLE = "single";
90     public static final String SHELLY2_RMODE_DUAL = "dual";
91     public static final String SHELLY2_RMODE_DETACHED = "detached";
92
93     public static final String SHELLY2_RSTATE_OPENING = "opening";
94     public static final String SHELLY2_RSTATE_OPEN = "open";
95     public static final String SHELLY2_RSTATE_CLOSING = "closing";
96     public static final String SHELLY2_RSTATE_CLOSED = "closed";
97     public static final String SHELLY2_RSTATE_STOPPED = "stopped";
98     public static final String SHELLY2_RSTATE_CALIB = "calibrating";
99
100     // Event notifications
101     public static final String SHELLY2_EVENT_BTNUP = "btn_up";
102     public static final String SHELLY2_EVENT_BTNDOWN = "btn_down";
103     public static final String SHELLY2_EVENT_1PUSH = "single_push";
104     public static final String SHELLY2_EVENT_2PUSH = "double_push";
105     public static final String SHELLY2_EVENT_3PUSH = "triple_push";
106     public static final String SHELLY2_EVENT_LPUSH = "long_push";
107     public static final String SHELLY2_EVENT_SLPUSH = "short_long_push";
108     public static final String SHELLY2_EVENT_LSPUSH = "long_short_push";
109
110     public static final String SHELLY2_EVENT_SLEEP = "sleep";
111     public static final String SHELLY2_EVENT_CFGCHANGED = "config_changed";
112     public static final String SHELLY2_EVENT_OTASTART = "ota_begin";
113     public static final String SHELLY2_EVENT_OTAPROGRESS = "ota_progress";
114     public static final String SHELLY2_EVENT_OTADONE = "ota_success";
115     public static final String SHELLY2_EVENT_WIFICONNFAILED = "sta_connect_fail";
116     public static final String SHELLY2_EVENT_WIFIDISCONNECTED = "sta_disconnected";
117
118     // Error Codes
119     public static final String SHELLY2_ERROR_OVERPOWER = "overpower";
120     public static final String SHELLY2_ERROR_OVERTEMP = "overtemp";
121     public static final String SHELLY2_ERROR_OVERVOLTAGE = "overvoltage";
122
123     // Wakeup reasons (e.g. Plus HT)
124     public static final String SHELLY2_WAKEUPO_BOOT_POWERON = "poweron";
125     public static final String SHELLY2_WAKEUPO_BOOT_RESTART = "software_restart";
126     public static final String SHELLY2_WAKEUPO_BOOT_WAKEUP = "deepsleep_wake";
127     public static final String SHELLY2_WAKEUPO_BOOT_INTERNAL = "internal";
128     public static final String SHELLY2_WAKEUPO_BOOT_UNKNOWN = "unknown";
129
130     public static final String SHELLY2_WAKEUPOCAUSE_BUTTON = "button";
131     public static final String SHELLY2_WAKEUPOCAUSE_USB = "usb";
132     public static final String SHELLY2_WAKEUPOCAUSE_PERIODIC = "periodic";
133     public static final String SHELLY2_WAKEUPOCAUSE_UPDATE = "status_update";
134     public static final String SHELLY2_WAKEUPOCAUSE_UNDEFINED = "undefined";
135
136     public class Shelly2DevConfigBle {
137         public Boolean enable;
138     }
139
140     public class Shelly2DevConfigEth {
141         public Boolean enable;
142         public String ipv4mode;
143         public String ip;
144         public String netmask;
145         public String gw;
146         public String nameserver;
147     }
148
149     public static class Shelly2DeviceSettings {
150         public String name;
151         public String id;
152         public String mac;
153         public String model;
154         public Integer gen;
155         @SerializedName("fw_id")
156         public String firmware;
157         public String ver;
158         public String app;
159         @SerializedName("auth_en")
160         public Boolean authEnable;
161         @SerializedName("auth_domain")
162         public String authDomain;
163     }
164
165     public static class Shelly2DeviceConfigAp {
166         public static class Shelly2DeviceConfigApRE {
167             public Boolean enable;
168         }
169
170         public Boolean enable;
171         public String ssid;
172         public String password;
173         @SerializedName("is_open")
174         public Boolean isOpen;
175         @SerializedName("range_extender")
176         Shelly2DeviceConfigApRE rangeExtender;
177     }
178
179     public static class Shelly2DeviceConfig {
180         public class Shelly2DeviceConfigSys {
181             public class Shelly2DeviceConfigDevice {
182                 public String name;
183                 public String mac;
184                 @SerializedName("fw_id")
185                 public String fwId;
186                 public String profile;
187                 @SerializedName("eco_mode")
188                 public Boolean ecoMode;
189                 public Boolean discoverable;
190             }
191
192             public class Shelly2DeviceConfigLocation {
193                 public String tz;
194                 public Double lat;
195                 public Double lon;
196             }
197
198             public class Shelly2DeviceConfigSntp {
199                 public String server;
200             }
201
202             public class Shelly2DeviceConfigSleep {
203                 @SerializedName("wakeup_period")
204                 public Integer wakeupPeriod;
205             }
206
207             public class Shelly2DeviceConfigDebug {
208                 public class Shelly2DeviceConfigDebugMqtt {
209                     public Boolean enable;
210                 }
211
212                 public class Shelly2DeviceConfigDebugWebSocket {
213                     public Boolean enable;
214                 }
215
216                 public class Shelly2DeviceConfigDebugUdp {
217                     public String addr;
218                 }
219
220                 public Shelly2DeviceConfigDebugMqtt mqtt;
221                 public Shelly2DeviceConfigDebugWebSocket websocket;
222                 public Shelly2DeviceConfigDebugUdp udp;
223             }
224
225             public class Shelly2DeviceConfigUiData {
226                 public String cover; // hold comma seperated list of roller favorites
227             }
228
229             public class Shelly2DeviceConfigRpcUdp {
230                 @SerializedName("dst_addr")
231                 public String dstAddr;
232                 @SerializedName("listenPort")
233                 public String listenPort;
234             }
235
236             @SerializedName("cfg_rev")
237             public Integer cfgRevision;
238             public Shelly2DeviceConfigDevice device;
239             public Shelly2DeviceConfigLocation location;
240             public Shelly2DeviceConfigSntp sntp;
241             public Shelly2DeviceConfigSleep sleep;
242             public Shelly2DeviceConfigDebug debug;
243             @SerializedName("ui_data")
244             public Shelly2DeviceConfigUiData uiData;
245             @SerializedName("rpc_udp")
246             public Shelly2DeviceConfigRpcUdp rpcUdp;
247         }
248
249         public class Shelly2DevConfigInput {
250             public String id;
251             public String name;
252             public String type;
253             public Boolean invert;
254             @SerializedName("factory_reset")
255             public Boolean factoryReset;
256         }
257
258         public class Shelly2DevConfigSwitch {
259             public String id;
260             public String name;
261
262             @SerializedName("in_mode")
263             public String mode;
264
265             @SerializedName("initial_state")
266             public String initialState;
267             @SerializedName("auto_on")
268             public Boolean autoOn;
269             @SerializedName("auto_on_delay")
270             public Double autoOnDelay;
271             @SerializedName("auto_off")
272             public Boolean autoOff;
273             @SerializedName("auto_off_delay")
274             public Double autoOffDelay;
275             @SerializedName("power_limit")
276             public Integer powerLimit;
277             @SerializedName("voltage_limit")
278             public Integer voltageLimit;
279             @SerializedName("current_limit")
280             public Double currentLimit;
281         }
282
283         public class Shelly2DevConfigCover {
284             public class Shelly2DeviceConfigCoverMotor {
285                 @SerializedName("idle_power_thr")
286                 public Double idle_powerThr;
287             }
288
289             public class Shelly2DeviceConfigCoverSafetySwitch {
290                 public Boolean enable;
291                 public String direction;
292                 public String action;
293                 @SerializedName("allowed_move")
294                 public String allowedMove;
295             }
296
297             public class Shelly2DeviceConfigCoverObstructionDetection {
298                 public Boolean enable;
299                 public String direction;
300                 public String action;
301                 @SerializedName("power_thr")
302                 public Integer powerThr;
303                 public Double holdoff;
304             }
305
306             public String id;
307             public String name;
308             public Shelly2DeviceConfigCoverMotor motor;
309             @SerializedName("maxtime_open")
310             public Double maxtimeOpen;
311             @SerializedName("maxtime_close")
312             public Double maxtimeClose;
313             @SerializedName("initial_state")
314             public String initialState;
315             @SerializedName("invert_directions")
316             public Boolean invertDirections;
317             @SerializedName("in_mode")
318             public String inMode;
319             @SerializedName("swap_inputs")
320             public Boolean swapInputs;
321             @SerializedName("safety_switch")
322             public Shelly2DeviceConfigCoverSafetySwitch safetySwitch;
323             @SerializedName("power_limit")
324             public Integer powerLimit;
325             @SerializedName("voltage_limit")
326             public Integer voltageLimit;
327             @SerializedName("current_limit")
328             public Double currentLimit;
329             @SerializedName("obstruction_detection")
330             public Shelly2DeviceConfigCoverObstructionDetection obstructionDetection;
331         }
332
333         public static class Shelly2GetConfigResult {
334
335             public class Shelly2DevConfigCloud {
336                 public Boolean enable;
337                 public String server;
338             }
339
340             public class Shelly2DevConfigMqtt {
341                 public Boolean enable;
342                 public String server;
343                 public String user;
344                 @SerializedName("topic_prefix:0")
345                 public String topicPrefix;
346                 @SerializedName("rpc_ntf")
347                 public String rpcNtf;
348                 @SerializedName("status_ntf")
349                 public String statusNtf;
350             }
351
352             public Shelly2DevConfigBle ble;
353             public Shelly2DevConfigEth eth;
354             public Shelly2DevConfigCloud cloud;
355             public Shelly2DevConfigMqtt mqtt;
356             public Shelly2DeviceConfigSys sys;
357             public Shelly2DeviceConfigWiFi wifi;
358
359             @SerializedName("input:0")
360             public Shelly2DevConfigInput input0;
361             @SerializedName("input:1")
362             public Shelly2DevConfigInput input1;
363             @SerializedName("input:2")
364             public Shelly2DevConfigInput input2;
365             @SerializedName("input:3")
366             public Shelly2DevConfigInput input3;
367
368             @SerializedName("switch:0")
369             public Shelly2DevConfigSwitch switch0;
370             @SerializedName("switch:1")
371             public Shelly2DevConfigSwitch switch1;
372             @SerializedName("switch:2")
373             public Shelly2DevConfigSwitch switch2;
374             @SerializedName("switch:3")
375             public Shelly2DevConfigSwitch switch3;
376
377             @SerializedName("cover:0")
378             public Shelly2DevConfigCover cover0;
379         }
380
381         public class Shelly2DeviceConfigSta {
382             public String ssid;
383             public String password;
384             @SerializedName("is_open")
385             public Boolean isOpen;
386             public Boolean enable;
387             public String ipv4mode;
388             public String ip;
389             public String netmask;
390             public String gw;
391             public String nameserver;
392         }
393
394         public class Shelly2DeviceConfigRoam {
395             @SerializedName("rssi_thr")
396             public Integer rssiThr;
397             public Integer interval;
398         }
399
400         public class Shelly2DeviceConfigWiFi {
401             public Shelly2DeviceConfigAp ap;
402             public Shelly2DeviceConfigSta sta;
403             public Shelly2DeviceConfigSta sta1;
404             public Shelly2DeviceConfigRoam roam;
405         }
406
407         public String id;
408         public String src;
409         public Shelly2GetConfigResult result;
410     }
411
412     public static class Shelly2DeviceStatus {
413         public class Shelly2InputStatus {
414             public Integer id;
415             public Boolean state;
416         }
417
418         public static class Shelly2DeviceStatusResult {
419             public class Shelly2DeviceStatusBle {
420
421             }
422
423             public class Shelly2DeviceStatusCloud {
424                 public Boolean connected;
425             }
426
427             public class Shelly2DeviceStatusMqqt {
428                 public Boolean connected;
429             }
430
431             public class Shelly2CoverStatus {
432                 public Integer id;
433                 public String source;
434                 public String state;
435                 public Double apower;
436                 public Double voltage;
437                 public Double current;
438                 public Double pf;
439                 public Shelly2Energy aenergy;
440                 @SerializedName("current_pos")
441                 public Integer currentPos;
442                 @SerializedName("target_pos")
443                 public Integer targetPos;
444                 @SerializedName("move_timeout")
445                 public Double moveTimeout;
446                 @SerializedName("move_started_at")
447                 public Double moveStartedAt;
448                 @SerializedName("pos_control")
449                 public Boolean posControl;
450                 public Shelly2DeviceStatusTemp temperature;
451                 public ArrayList<String> errors;
452             }
453
454             public class Shelly2DeviceStatusHumidity {
455                 public Integer id;
456                 public Double rh;
457             }
458
459             public class Shelly2DeviceStatusTempId extends Shelly2DeviceStatusTemp {
460                 public Integer id;
461             }
462
463             public static class Shelly2DeviceStatusPower {
464                 public static class Shelly2DeviceStatusBattery {
465                     @SerializedName("V")
466                     public Double volt;
467                     public Double percent;
468                 }
469
470                 public static class Shelly2DeviceStatusCharger {
471                     public Boolean present;
472                 }
473
474                 public Integer id;
475                 public Shelly2DeviceStatusBattery battery;
476                 public Shelly2DeviceStatusCharger external;
477             }
478
479             public Shelly2DeviceStatusBle ble;
480             public Shelly2DeviceStatusCloud cloud;
481             public Shelly2DeviceStatusMqqt mqtt;
482             public Shelly2DeviceStatusSys sys;
483             public Shelly2DeviceStatusSysWiFi wifi;
484
485             @SerializedName("input:0")
486             public Shelly2InputStatus input0;
487             @SerializedName("input:1")
488             public Shelly2InputStatus input1;
489             @SerializedName("input:2")
490             public Shelly2InputStatus input2;
491             @SerializedName("input:3")
492             public Shelly2InputStatus input3;
493
494             @SerializedName("switch:0")
495             public Shelly2RelayStatus switch0;
496             @SerializedName("switch:1")
497             public Shelly2RelayStatus switch1;
498             @SerializedName("switch:2")
499             public Shelly2RelayStatus switch2;
500             @SerializedName("switch:3")
501             public Shelly2RelayStatus switch3;
502
503             @SerializedName("cover:0")
504             public Shelly2CoverStatus cover0;
505
506             @SerializedName("humidity:0")
507             public Shelly2DeviceStatusHumidity humidity0;
508             @SerializedName("temperature:0")
509             public Shelly2DeviceStatusTempId temperature0;
510             @SerializedName("devicepower:0")
511             public Shelly2DeviceStatusPower devicepower0;
512         }
513
514         public class Shelly2DeviceStatusSys {
515             public class Shelly2DeviceStatusSysAvlUpdate {
516                 public class Shelly2DeviceStatusSysUpdate {
517                     public String version;
518                 }
519
520                 public Shelly2DeviceStatusSysUpdate stable;
521                 public Shelly2DeviceStatusSysUpdate beta;
522             }
523
524             public class Shelly2DeviceStatusWakeup {
525                 public String boot;
526                 public String cause;
527             }
528
529             public String mac;
530             @SerializedName("restart_required")
531             public Boolean restartRequired;
532             public String time;
533             public Long unixtime;
534             public Long uptime;
535             @SerializedName("ram_size")
536             public Long ramSize;
537             @SerializedName("ram_free")
538             public Long ramFree;
539             @SerializedName("fs_size")
540             public Long fsSize;
541             @SerializedName("fs_free")
542             public Long fsFree;
543             @SerializedName("cfg_rev")
544             public Integer cfg_rev;
545             @SerializedName("available_updates")
546             public Shelly2DeviceStatusSysAvlUpdate availableUpdates;
547             @SerializedName("webhook_rev")
548             public Integer webHookRev;
549             @SerializedName("wakeup_reason")
550             public Shelly2DeviceStatusWakeup wakeUpReason;
551             @SerializedName("wakeup_period")
552             public Integer wakeupPeriod;
553         }
554
555         public class Shelly2DeviceStatusSysWiFi {
556             @SerializedName("sta_ip")
557             public String staIP;
558             public String status;
559             public String ssid;
560             public Integer rssi;
561             @SerializedName("ap_client_count")
562             public Integer apClientCount;
563         }
564
565         public String id;
566         public String src;
567         public Shelly2DeviceStatusResult result;
568     }
569
570     public static class Shelly2RelayStatus {
571         public Integer id;
572         public String source;
573         public Boolean output;
574         @SerializedName("timer_started_at")
575         public Double timerStartetAt;
576         @SerializedName("timer_duration")
577         public Integer timerDuration;
578         public Double apower;
579         public Double voltage;
580         public Double current;
581         public Double pf;
582         public Shelly2Energy aenergy;
583         public Shelly2DeviceStatusTemp temperature;
584         public String[] errors;
585     }
586
587     public static class Shelly2DeviceStatusTemp {
588         public Double tC;
589         public Double tF;
590     }
591
592     public static class Shelly2Energy {
593         // "switch:1":{"id":1,"aenergy":{"total":0.003,"by_minute":[0.000,0.000,0.000],"minute_ts":1619910239}}}}
594         public Double total;
595         @SerializedName("by_minute")
596         public Double[] byMinute;
597         @SerializedName("minute_ts")
598         public Long minuteTs;
599     }
600
601     public static class Shelly2ConfigParms {
602         public String name;
603         public Boolean enable;
604         public String server;
605         @SerializedName("ssl_ca")
606         public String sslCA;
607
608         // WiFi.SetConfig
609         public Shelly2DeviceConfigAp ap;
610
611         // Switch.SetConfig
612         @SerializedName("auto_on")
613         public Boolean autoOn;
614         @SerializedName("auto_on_delay")
615         public Double autoOnDelay;
616         @SerializedName("auto_off")
617         public Boolean autoOff;
618         @SerializedName("auto_off_delay")
619         public Double autoOffDelay;
620     }
621
622     public static class Shelly2RpcRequest {
623         public Integer id = 0;
624         public String method;
625
626         public static class Shelly2RpcRequestParams {
627             public Integer id = 1;
628
629             // Cover
630             public Integer pos;
631             public Boolean on;
632
633             // Shelly.SetAuth
634             public String user;
635             public String realm;
636             public String ha1;
637
638             // Shelly.Update
639             public String stage;
640             public String url;
641
642             // Cloud.SetConfig
643             public Shelly2ConfigParms config;
644
645             public Shelly2RpcRequestParams withConfig() {
646                 config = new Shelly2ConfigParms();
647                 return this;
648             }
649         }
650
651         public Shelly2RpcRequestParams params = new Shelly2RpcRequestParams();
652
653         public Shelly2RpcRequest() {
654         }
655
656         public Shelly2RpcRequest withMethod(String method) {
657             this.method = method;
658             return this;
659         }
660
661         public Shelly2RpcRequest withId(int id) {
662             params.id = id;
663             return this;
664         }
665
666         public Shelly2RpcRequest withPos(int pos) {
667             params.pos = pos;
668             return this;
669         }
670     }
671
672     public static class Shelly2WsConfigResponse {
673         public Integer id;
674         public String src;
675
676         public static class Shelly2WsConfigResult {
677             @SerializedName("restart_required")
678             public Boolean restartRequired;
679         }
680
681         public Shelly2WsConfigResult result;
682     }
683
684     public static class Shelly2RpcBaseMessage {
685         // Basic message format, e.g.
686         // {"id":1,"src":"localweb528","method":"Shelly.GetConfig"}
687         public class Shelly2RpcMessageError {
688             public Integer code;
689             public String message;
690         }
691
692         public Integer id;
693         public String src;
694         public String dst;
695         public String method;
696         public Object params;
697         public Object result;
698         public Shelly2AuthRequest auth;
699         public Shelly2RpcMessageError error;
700     }
701
702     public static class Shelly2RpcNotifyStatus {
703         public static class Shelly2NotifyStatus extends Shelly2DeviceStatusResult {
704             public Double ts;
705         }
706
707         public Integer id;
708         public String src;
709         public String dst;
710         public String method;
711         public Shelly2NotifyStatus params;
712         public Shelly2NotifyStatus result;
713         public Shelly2RpcMessageError error;
714     }
715
716     public static String SHELLY2_AUTHTTYPE_DIGEST = "digest";
717     public static String SHELLY2_AUTHTTYPE_STRING = "string";
718     public static String SHELLY2_AUTHALG_SHA256 = "SHA-256";
719     // = ':auth:'+HexHash("dummy_method:dummy_uri");
720     public static String SHELLY2_AUTH_NOISE = "6370ec69915103833b5222b368555393393f098bfbfbb59f47e0590af135f062";
721
722     public static class Shelly2AuthRequest {
723         public String username;
724         public Long nonce;
725         public Long cnonce;
726         public Integer nc;
727         public String realm;
728         public String algorithm;
729         public String response;
730         @SerializedName("auth_type")
731         public String authType;
732     }
733
734     public static class Shelly2AuthResponse { // on 401 message contains the auth info
735         @SerializedName("auth_type")
736         public String authType;
737         public Long nonce;
738         public Integer nc;
739         public String realm;
740         public String algorithm;
741     }
742
743     public class Shelly2NotifyEvent {
744         public Integer id;
745         public Double ts;
746         public String component;
747         public String event;
748         public String msg;
749         public Integer reason;
750         @SerializedName("cfg_rev")
751         public Integer cfgRev;
752     }
753
754     public class Shelly2NotifyEventData {
755         public Double ts;
756         public ArrayList<Shelly2NotifyEvent> events;
757     }
758
759     public static class Shelly2RpcNotifyEvent {
760         public Double ts;
761         Shelly2NotifyEventData params;
762     }
763 }