2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.shelly.internal.api2;
15 import java.util.ArrayList;
17 import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2DeviceStatus.Shelly2DeviceStatusResult;
18 import org.openhab.binding.shelly.internal.api2.Shelly2ApiJsonDTO.Shelly2RpcBaseMessage.Shelly2RpcMessageError;
20 import com.google.gson.annotations.SerializedName;
23 * {@link Shelly2ApiJsonDTO} wraps the Shelly REST API and provides various low level function to access the device api
27 * @author Markus Michels - Initial contribution
29 public class Shelly2ApiJsonDTO {
30 public static final String SHELLYRPC_METHOD_CLASS_SHELLY = "Shelly";
31 public static final String SHELLYRPC_METHOD_CLASS_SWITCH = "Switch";
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_LIGHT_STATUS = "Light.GetStatus";
51 public static final String SHELLYRPC_METHOD_LIGHT_SET = "Light.Set";
52 public static final String SHELLYRPC_METHOD_LIGHT_SETCONFIG = "Light.SetConfig";
53 public static final String SHELLYRPC_METHOD_LED_SETCONFIG = "WD_UI.SetConfig";
54 public static final String SHELLYRPC_METHOD_WIFIGETCONG = "Wifi.GetConfig";
55 public static final String SHELLYRPC_METHOD_WIFISETCONG = "Wifi.SetConfig";
56 public static final String SHELLYRPC_METHOD_ETHGETCONG = "Eth.GetConfig";
57 public static final String SHELLYRPC_METHOD_ETHSETCONG = "Eth.SetConfig";
58 public static final String SHELLYRPC_METHOD_BLEGETCONG = "BLE.GetConfig";
59 public static final String SHELLYRPC_METHOD_BLESETCONG = "BLE.SetConfig";
60 public static final String SHELLYRPC_METHOD_CLOUDSET = "Cloud.SetConfig";
61 public static final String SHELLYRPC_METHOD_WSGETCONFIG = "WS.GetConfig";
62 public static final String SHELLYRPC_METHOD_WSSETCONFIG = "WS.SetConfig";
63 public static final String SHELLYRPC_METHOD_EMDATARESET = "EMData.DeleteAllData";
64 public static final String SHELLYRPC_METHOD_EM1DATARESET = "EM1Data.DeleteAllData";
65 public static final String SHELLYRPC_METHOD_SMOKE_SETCONFIG = "Smoke.SetConfig";
66 public static final String SHELLYRPC_METHOD_SMOKE_MUTE = "Smoke.Mute";
67 public static final String SHELLYRPC_METHOD_SCRIPT_LIST = "Script.List";
68 public static final String SHELLYRPC_METHOD_SCRIPT_SETCONFIG = "Script.SetConfig";
69 public static final String SHELLYRPC_METHOD_SCRIPT_GETSTATUS = "Script.GetStatus";
70 public static final String SHELLYRPC_METHOD_SCRIPT_DELETE = "Script.Delete";
71 public static final String SHELLYRPC_METHOD_SCRIPT_CREATE = "Script.Create";
72 public static final String SHELLYRPC_METHOD_SCRIPT_GETCODE = "Script.GetCode";
73 public static final String SHELLYRPC_METHOD_SCRIPT_PUTCODE = "Script.PutCode";
74 public static final String SHELLYRPC_METHOD_SCRIPT_START = "Script.Start";
75 public static final String SHELLYRPC_METHOD_SCRIPT_STOP = "Script.Stop";
77 public static final String SHELLYRPC_METHOD_NOTIFYSTATUS = "NotifyStatus"; // inbound status
78 public static final String SHELLYRPC_METHOD_NOTIFYFULLSTATUS = "NotifyFullStatus"; // inbound status from bat device
79 public static final String SHELLYRPC_METHOD_NOTIFYEVENT = "NotifyEvent"; // inbound event
82 public static final String SHELLY2_PROFILE_RELAY = "switch";
83 public static final String SHELLY2_PROFILE_ROLLER = "cover";
86 public static final String SHELLY2_BTNT_MOMENTARY = "momentary";
87 public static final String SHELLY2_BTNT_FLIP = "flip";
88 public static final String SHELLY2_BTNT_FOLLOW = "follow";
89 public static final String SHELLY2_BTNT_DETACHED = "detached";
92 public static final String SHELLY2_INPUTT_SWITCH = "switch";
93 public static final String SHELLY2_INPUTT_BUTTON = "button";
94 public static final String SHELLY2_INPUTT_ANALOG = "analog"; // Shelly Addon: analogous input
97 public static final String SHELLY2_API_MODE_DETACHED = "detached";
98 public static final String SHELLY2_API_MODE_FOLLOW = "follow";
100 // Initial switch states
101 public static final String SHELLY2_API_ISTATE_ON = "on";
102 public static final String SHELLY2_API_ISTATE_OFF = "off";
103 public static final String SHELLY2_API_ISTATE_FOLLOWLAST = "restore_last";
104 public static final String SHELLY2_API_ISTATE_MATCHINPUT = "match_input";
106 // Cover/Roller modes
107 public static final String SHELLY2_RMODE_SINGLE = "single";
108 public static final String SHELLY2_RMODE_DUAL = "dual";
109 public static final String SHELLY2_RMODE_DETACHED = "detached";
111 public static final String SHELLY2_RSTATE_OPENING = "opening";
112 public static final String SHELLY2_RSTATE_OPEN = "open";
113 public static final String SHELLY2_RSTATE_CLOSING = "closing";
114 public static final String SHELLY2_RSTATE_CLOSED = "closed";
115 public static final String SHELLY2_RSTATE_STOPPED = "stopped";
116 public static final String SHELLY2_RSTATE_CALIB = "calibrating";
118 // Event notifications
119 public static final String SHELLY2_EVENT_BTNUP = "btn_up";
120 public static final String SHELLY2_EVENT_BTNDOWN = "btn_down";
121 public static final String SHELLY2_EVENT_1PUSH = "single_push";
122 public static final String SHELLY2_EVENT_2PUSH = "double_push";
123 public static final String SHELLY2_EVENT_3PUSH = "triple_push";
124 public static final String SHELLY2_EVENT_LPUSH = "long_push";
125 public static final String SHELLY2_EVENT_SLPUSH = "short_long_push";
126 public static final String SHELLY2_EVENT_LSPUSH = "long_short_push";
128 public static final String SHELLY2_EVENT_SLEEP = "sleep";
129 public static final String SHELLY2_EVENT_CFGCHANGED = "config_changed";
130 public static final String SHELLY2_EVENT_OTASTART = "ota_begin";
131 public static final String SHELLY2_EVENT_OTAPROGRESS = "ota_progress";
132 public static final String SHELLY2_EVENT_OTADONE = "ota_success";
133 public static final String SHELLY2_EVENT_WIFICONNFAILED = "sta_connect_fail";
134 public static final String SHELLY2_EVENT_WIFIDISCONNECTED = "sta_disconnected";
137 public static final String SHELLY2_BLU_GWSCRIPT = "oh-blu-scanner.js";
138 public static final String SHELLY2_EVENT_BLUPREFIX = "oh-blu.";
139 public static final String SHELLY2_EVENT_BLUSCAN = SHELLY2_EVENT_BLUPREFIX + "scan_result";
140 public static final String SHELLY2_EVENT_BLUDATA = SHELLY2_EVENT_BLUPREFIX + "data";
143 public static final String SHELLY2_ERROR_OVERPOWER = "overpower";
144 public static final String SHELLY2_ERROR_OVERTEMP = "overtemp";
145 public static final String SHELLY2_ERROR_OVERVOLTAGE = "overvoltage";
147 // Wakeup reasons (e.g. Plus HT)
148 public static final String SHELLY2_WAKEUPO_BOOT_POWERON = "poweron";
149 public static final String SHELLY2_WAKEUPO_BOOT_RESTART = "software_restart";
150 public static final String SHELLY2_WAKEUPO_BOOT_WAKEUP = "deepsleep_wake";
151 public static final String SHELLY2_WAKEUPO_BOOT_INTERNAL = "internal";
152 public static final String SHELLY2_WAKEUPO_BOOT_UNKNOWN = "unknown";
154 public static final String SHELLY2_WAKEUPOCAUSE_BUTTON = "button";
155 public static final String SHELLY2_WAKEUPOCAUSE_USB = "usb";
156 public static final String SHELLY2_WAKEUPOCAUSE_PERIODIC = "periodic";
157 public static final String SHELLY2_WAKEUPOCAUSE_UPDATE = "status_update";
158 public static final String SHELLY2_WAKEUPOCAUSE_UNDEFINED = "undefined";
160 // Dimmer US: LED power modes
161 public static final String SHELLY2_POWERLED_ON = "on";
162 public static final String SHELLY2_POWERLED_OFF = "off";
163 public static final String SHELLY2_POWERLED_MATCH = "match_output";
164 public static final String SHELLY2_POWERLED_INVERT = "inverted_output";
166 public class Shelly2DevConfigBle {
167 public Boolean enable;
170 public class Shelly2DevConfigEth {
171 public Boolean enable;
172 public String ipv4mode;
174 public String netmask;
176 public String nameserver;
179 public static class Shelly2DeviceSettings {
185 @SerializedName("fw_id")
186 public String firmware;
189 @SerializedName("auth_en")
190 public Boolean authEnable;
191 @SerializedName("auth_domain")
192 public String authDomain;
195 public static class Shelly2DeviceConfigAp {
196 public static class Shelly2DeviceConfigApRE {
197 public Boolean enable;
200 public Boolean enable;
202 public String password;
203 @SerializedName("is_open")
204 public Boolean isOpen;
205 @SerializedName("range_extender")
206 Shelly2DeviceConfigApRE rangeExtender;
209 public static class Shelly2DeviceConfig {
210 public class Shelly2DeviceConfigSys {
211 public class Shelly2DeviceConfigDevice {
214 @SerializedName("fw_id")
216 public String profile;
217 @SerializedName("eco_mode")
218 public Boolean ecoMode;
219 public Boolean discoverable;
222 public class Shelly2DeviceConfigLocation {
228 public class Shelly2DeviceConfigSntp {
229 public String server;
232 public class Shelly2DeviceConfigSleep {
233 @SerializedName("wakeup_period")
234 public Integer wakeupPeriod;
237 public class Shelly2DeviceConfigDebug {
238 public class Shelly2DeviceConfigDebugMqtt {
239 public Boolean enable;
242 public class Shelly2DeviceConfigDebugWebSocket {
243 public Boolean enable;
246 public class Shelly2DeviceConfigDebugUdp {
250 public Shelly2DeviceConfigDebugMqtt mqtt;
251 public Shelly2DeviceConfigDebugWebSocket websocket;
252 public Shelly2DeviceConfigDebugUdp udp;
255 public class Shelly2DeviceConfigUiData {
256 public String cover; // hold comma seperated list of roller favorites
259 public class Shelly2DeviceConfigRpcUdp {
260 @SerializedName("dst_addr")
261 public String dstAddr;
262 @SerializedName("listenPort")
263 public String listenPort;
266 @SerializedName("cfg_rev")
267 public Integer cfgRevision;
268 public Shelly2DeviceConfigDevice device;
269 public Shelly2DeviceConfigLocation location;
270 public Shelly2DeviceConfigSntp sntp;
271 public Shelly2DeviceConfigSleep sleep;
272 public Shelly2DeviceConfigDebug debug;
273 @SerializedName("ui_data")
274 public Shelly2DeviceConfigUiData uiData;
275 @SerializedName("rpc_udp")
276 public Shelly2DeviceConfigRpcUdp rpcUdp;
279 public class Shelly2DevConfigInput {
283 public Boolean invert;
284 @SerializedName("factory_reset")
285 public Boolean factoryReset;
286 @SerializedName("report_thr")
287 public Double reportTreshold; // only for type analog
290 public class Shelly2DevConfigSwitch {
294 @SerializedName("in_mode")
297 @SerializedName("initial_state")
298 public String initialState;
299 @SerializedName("auto_on")
300 public Boolean autoOn;
301 @SerializedName("auto_on_delay")
302 public Double autoOnDelay;
303 @SerializedName("auto_off")
304 public Boolean autoOff;
305 @SerializedName("auto_off_delay")
306 public Double autoOffDelay;
307 @SerializedName("power_limit")
308 public Integer powerLimit;
309 @SerializedName("voltage_limit")
310 public Integer voltageLimit;
311 @SerializedName("current_limit")
312 public Double currentLimit;
315 public static class Shelly2DevConfigEm {
318 @SerializedName("blink_mode_selector")
319 public String blinkModeSelector;
320 @SerializedName("phase_selector")
321 public String phase_selector;
322 @SerializedName("monitor_phase_sequence")
323 public Boolean monitorPhaseSequence;
326 public class Shelly2DevConfigPm1 {
331 public class Shelly2DevConfigCover {
332 public class Shelly2DeviceConfigCoverMotor {
333 @SerializedName("idle_power_thr")
334 public Double idle_powerThr;
337 public class Shelly2DeviceConfigCoverSafetySwitch {
338 public Boolean enable;
339 public String direction;
340 public String action;
341 @SerializedName("allowed_move")
342 public String allowedMove;
345 public class Shelly2DeviceConfigCoverObstructionDetection {
346 public Boolean enable;
347 public String direction;
348 public String action;
349 @SerializedName("power_thr")
350 public Integer powerThr;
351 public Double holdoff;
356 public Shelly2DeviceConfigCoverMotor motor;
357 @SerializedName("maxtime_open")
358 public Double maxtimeOpen;
359 @SerializedName("maxtime_close")
360 public Double maxtimeClose;
361 @SerializedName("initial_state")
362 public String initialState;
363 @SerializedName("invert_directions")
364 public Boolean invertDirections;
365 @SerializedName("in_mode")
366 public String inMode;
367 @SerializedName("swap_inputs")
368 public Boolean swapInputs;
369 @SerializedName("safety_switch")
370 public Shelly2DeviceConfigCoverSafetySwitch safetySwitch;
371 @SerializedName("power_limit")
372 public Integer powerLimit;
373 @SerializedName("voltage_limit")
374 public Integer voltageLimit;
375 @SerializedName("current_limit")
376 public Double currentLimit;
377 @SerializedName("obstruction_detection")
378 public Shelly2DeviceConfigCoverObstructionDetection obstructionDetection;
381 public static class Shelly2ConfigSmoke {
383 public Boolean alarm;
387 public static class Shelly2GetConfigLight {
388 public static class Shelly2GetConfigLightDefault {
389 public Integer brightness;
392 public static class Shelly2GetConfigLightNightMode {
393 public boolean enable;
394 public Integer brightness;
399 @SerializedName("initial_state")
400 public String initialState;
401 @SerializedName("auto_on")
402 public Boolean autoOn;
403 @SerializedName("auto_off")
404 public Boolean autoOff;
405 @SerializedName("auto_on_delay")
406 public Double autoOnDelay;
407 @SerializedName("auto_off_delay")
408 public Double autoOffDelay;
409 @SerializedName("default")
410 public Shelly2GetConfigLightDefault defaultCfg;
411 @SerializedName("night_mode")
412 public Shelly2GetConfigLightNightMode nightMode;
415 public class Shelly2DeviceConfigLed {
416 @SerializedName("sys_led_enable")
417 public Boolean sysLedEnable;
418 @SerializedName("power_led")
419 public String powerLed;
422 public static class Shelly2GetConfigResult {
424 public class Shelly2DevConfigCloud {
425 public Boolean enable;
426 public String server;
429 public class Shelly2DevConfigMqtt {
430 public Boolean enable;
431 public String server;
433 @SerializedName("topic_prefix:0")
434 public String topicPrefix;
435 @SerializedName("rpc_ntf")
436 public String rpcNtf;
437 @SerializedName("status_ntf")
438 public String statusNtf;
441 public Shelly2DevConfigBle ble;
442 public Shelly2DevConfigEth eth;
443 public Shelly2DevConfigCloud cloud;
444 public Shelly2DevConfigMqtt mqtt;
445 public Shelly2DeviceConfigSys sys;
446 public Shelly2DeviceConfigWiFi wifi;
447 @SerializedName("wd_ui")
448 public Shelly2DeviceConfigLed led;
450 @SerializedName("input:0")
451 public Shelly2DevConfigInput input0;
452 @SerializedName("input:1")
453 public Shelly2DevConfigInput input1;
454 @SerializedName("input:2")
455 public Shelly2DevConfigInput input2;
456 @SerializedName("input:3")
457 public Shelly2DevConfigInput input3;
459 @SerializedName("switch:0")
460 public Shelly2DevConfigSwitch switch0;
461 @SerializedName("switch:1")
462 public Shelly2DevConfigSwitch switch1;
463 @SerializedName("switch:2")
464 public Shelly2DevConfigSwitch switch2;
465 @SerializedName("switch:3")
466 public Shelly2DevConfigSwitch switch3;
467 @SerializedName("switch:100")
468 public Shelly2DevConfigSwitch switch100; // Pro 3EM Add-On
470 @SerializedName("em:0")
471 public Shelly2DevConfigEm em0;
472 @SerializedName("em1:0")
473 public Shelly2DevConfigEm em10;
474 @SerializedName("em1:1")
475 public Shelly2DevConfigEm em11;
476 @SerializedName("pm1:0")
477 public Shelly2DevConfigPm1 pm10;
479 @SerializedName("cover:0")
480 public Shelly2DevConfigCover cover0;
482 @SerializedName("light:0")
483 public Shelly2GetConfigLight light0;
485 @SerializedName("smoke:0")
486 public Shelly2ConfigSmoke smoke0;
489 public class Shelly2DeviceConfigSta {
491 public String password;
492 @SerializedName("is_open")
493 public Boolean isOpen;
494 public Boolean enable;
495 public String ipv4mode;
497 public String netmask;
499 public String nameserver;
502 public class Shelly2DeviceConfigRoam {
503 @SerializedName("rssi_thr")
504 public Integer rssiThr;
505 public Integer interval;
508 public class Shelly2DeviceConfigWiFi {
509 public Shelly2DeviceConfigAp ap;
510 public Shelly2DeviceConfigSta sta;
511 public Shelly2DeviceConfigSta sta1;
512 public Shelly2DeviceConfigRoam roam;
517 public Shelly2GetConfigResult result;
520 public static class Shelly2DeviceStatus {
521 public class Shelly2InputStatus {
523 public Boolean state;
524 public Double percent; // analog input only
525 public ArrayList<String> errors;// shown only if at least one error is present.
528 public static class Shelly2DeviceStatusLight {
530 public String source;
531 public Boolean output;
532 public Double brightness;
533 @SerializedName("timer_started_at")
534 public Double timerStartedAt;
535 @SerializedName("timer_duration")
536 public Integer timerDuration;
539 public static class Shelly2DeviceStatusResult {
540 public class Shelly2DeviceStatusBle {
544 public class Shelly2DeviceStatusCloud {
545 public Boolean connected;
548 public class Shelly2DeviceStatusMqqt {
549 public Boolean connected;
552 public class Shelly2CoverStatus {
554 public String source;
556 public Double apower;
557 public Double voltage;
558 public Double current;
560 public Shelly2Energy aenergy;
561 @SerializedName("current_pos")
562 public Integer currentPos;
563 @SerializedName("target_pos")
564 public Integer targetPos;
565 @SerializedName("move_timeout")
566 public Double moveTimeout;
567 @SerializedName("move_started_at")
568 public Double moveStartedAt;
569 @SerializedName("pos_control")
570 public Boolean posControl;
571 public Shelly2DeviceStatusTemp temperature;
572 public ArrayList<String> errors;
575 public class Shelly2DeviceStatusHumidity {
580 public class Shelly2DeviceStatusIlluminance {
583 public String illumination;
586 public class Shelly2DeviceStatusVoltage {
588 public Double voltage;
591 public class Shelly2DeviceStatusTempId extends Shelly2DeviceStatusTemp {
595 public static class Shelly2DeviceStatusPower {
596 public static class Shelly2DeviceStatusBattery {
599 public Double percent;
602 public static class Shelly2DeviceStatusCharger {
603 public Boolean present;
607 public Shelly2DeviceStatusBattery battery;
608 public Shelly2DeviceStatusCharger external;
611 public static class Shelly2DeviceStatusEm {
614 @SerializedName("a_current")
615 public Double aCurrent;
616 @SerializedName("a_voltage")
617 public Double aVoltage;
618 @SerializedName("a_act_power")
619 public Double aActPower;
620 @SerializedName("a_aprt_power")
621 public Double aAprtPower;
622 @SerializedName("a_pf")
625 @SerializedName("b_current")
626 public Double bCurrent;
627 @SerializedName("b_voltage")
628 public Double bVoltage;
629 @SerializedName("b_act_power")
630 public Double bActPower;
631 @SerializedName("b_aprt_power")
632 public Double bAprtPower;
633 @SerializedName("b_pf")
636 @SerializedName("c_current")
637 public Double cCurrent;
638 @SerializedName("c_voltage")
639 public Double cVoltage;
640 @SerializedName("c_act_power")
641 public Double cActPower;
642 @SerializedName("c_aprt_power")
643 public Double cAprtPower;
644 @SerializedName("c_pf")
647 @SerializedName("n_current")
648 public Double nCurrent;
650 @SerializedName("total_current")
651 public Double totalCurrent;
652 @SerializedName("total_act_power")
653 public Double totalActPower;
654 @SerializedName("total_aprt_power")
655 public Double totalAprtPower;
658 public static class Shelly2DeviceStatusEmData {
660 public String[] errors;
663 public class Shelly2DeviceStatusSmoke {
665 public Boolean alarm;
669 public Shelly2DeviceStatusBle ble;
670 public Shelly2DeviceStatusCloud cloud;
671 public Shelly2DeviceStatusMqqt mqtt;
672 public Shelly2DeviceStatusSys sys;
673 public Shelly2DeviceStatusSysWiFi wifi;
675 @SerializedName("input:0")
676 public Shelly2InputStatus input0;
677 @SerializedName("input:1")
678 public Shelly2InputStatus input1;
679 @SerializedName("input:2")
680 public Shelly2InputStatus input2;
681 @SerializedName("input:3")
682 public Shelly2InputStatus input3;
683 @SerializedName("input:100")
684 public Shelly2InputStatus input100; // Digital Input from Add-On
686 @SerializedName("switch:0")
687 public Shelly2RelayStatus switch0;
688 @SerializedName("switch:1")
689 public Shelly2RelayStatus switch1;
690 @SerializedName("switch:2")
691 public Shelly2RelayStatus switch2;
692 @SerializedName("switch:3")
693 public Shelly2RelayStatus switch3;
694 @SerializedName("switch:100")
695 public Shelly2RelayStatus switch100; // Pro 3EM Add-On
697 @SerializedName("pm1:0")
698 public Shelly2RelayStatus pm10;
700 @SerializedName("em:0")
701 public Shelly2DeviceStatusEm em0;
702 @SerializedName("emdata:0")
703 public Shelly2DeviceStatusEmData emdata0;
704 @SerializedName("em1:0")
705 public Shelly2StatusEm1 em10;
706 @SerializedName("em1:1")
707 public Shelly2StatusEm1 em11;
708 @SerializedName("em1data:0")
709 public Shelly2DeviceStatusEmData em1data0;
711 @SerializedName("cover:0")
712 public Shelly2CoverStatus cover0;
714 @SerializedName("light:0")
715 public Shelly2DeviceStatusLight light0;
717 @SerializedName("temperature:0")
718 public Shelly2DeviceStatusTempId temperature0;
719 @SerializedName("temperature:100")
720 public Shelly2DeviceStatusTempId temperature100;
721 @SerializedName("temperature:101")
722 public Shelly2DeviceStatusTempId temperature101;
723 @SerializedName("temperature:102")
724 public Shelly2DeviceStatusTempId temperature102;
725 @SerializedName("temperature:103")
726 public Shelly2DeviceStatusTempId temperature103;
727 @SerializedName("temperature:104")
728 public Shelly2DeviceStatusTempId temperature104;
730 @SerializedName("humidity:0")
731 public Shelly2DeviceStatusHumidity humidity0;
732 @SerializedName("humidity:100")
733 public Shelly2DeviceStatusHumidity humidity100;
735 @SerializedName("illuminance:0")
736 Shelly2DeviceStatusIlluminance illuminance0;
738 @SerializedName("smoke:0")
739 public Shelly2DeviceStatusSmoke smoke0;
741 @SerializedName("voltmeter:100")
742 public Shelly2DeviceStatusVoltage voltmeter100;
744 @SerializedName("devicepower:0")
745 public Shelly2DeviceStatusPower devicepower0;
748 public class Shelly2DeviceStatusSys {
749 public class Shelly2DeviceStatusSysAvlUpdate {
750 public class Shelly2DeviceStatusSysUpdate {
751 public String version;
754 public Shelly2DeviceStatusSysUpdate stable;
755 public Shelly2DeviceStatusSysUpdate beta;
758 public class Shelly2DeviceStatusWakeup {
764 @SerializedName("restart_required")
765 public Boolean restartRequired;
767 public Long unixtime;
769 @SerializedName("ram_size")
771 @SerializedName("ram_free")
773 @SerializedName("fs_size")
775 @SerializedName("fs_free")
777 @SerializedName("cfg_rev")
778 public Integer cfg_rev;
779 @SerializedName("available_updates")
780 public Shelly2DeviceStatusSysAvlUpdate availableUpdates;
781 @SerializedName("webhook_rev")
782 public Integer webHookRev;
783 @SerializedName("wakeup_reason")
784 public Shelly2DeviceStatusWakeup wakeUpReason;
785 @SerializedName("wakeup_period")
786 public Integer wakeupPeriod;
789 public class Shelly2DeviceStatusSysWiFi {
790 @SerializedName("sta_ip")
792 public String status;
795 @SerializedName("ap_client_count")
796 public Integer apClientCount;
801 public Shelly2DeviceStatusResult result;
804 public static class Shelly2RelayStatus {
806 public String source;
807 public Boolean output;
808 @SerializedName("timer_started_at")
809 public Double timerStartetAt;
810 @SerializedName("timer_duration")
811 public Integer timerDuration;
812 public Double apower;
813 public Double voltage;
814 public Double current;
816 public Shelly2Energy aenergy;
817 public Shelly2DeviceStatusTemp temperature;
818 public String[] errors;
821 public static class Shelly2Pm1Status {
823 public String source;
824 public Boolean output;
825 @SerializedName("timer_started_at")
826 public Double timerStartetAt;
827 @SerializedName("timer_duration")
828 public Integer timerDuration;
829 public Double apower;
830 public Double voltage;
831 public Double current;
833 public Shelly2Energy aenergy;
834 public Shelly2DeviceStatusTemp temperature;
835 public String[] errors;
838 public static class Shelly2StatusEm1 {
840 public Double current;
841 public Double voltage;
842 @SerializedName("act_power")
843 public Double actPower;
844 @SerializedName("aprt_power")
845 public Double aptrPower;
847 public String calibration;
848 public ArrayList<String> errors;
851 public static class Shelly2DeviceStatusTemp {
856 public static class Shelly2Energy {
857 // "switch:1":{"id":1,"aenergy":{"total":0.003,"by_minute":[0.000,0.000,0.000],"minute_ts":1619910239}}}}
859 @SerializedName("by_minute")
860 public Double[] byMinute;
861 @SerializedName("minute_ts")
862 public Long minuteTs;
865 public static class Shelly2ConfigParms {
867 public Boolean enable;
868 public String server;
869 @SerializedName("ssl_ca")
873 public Shelly2DeviceConfigAp ap;
876 @SerializedName("auto_on")
877 public Boolean autoOn;
878 @SerializedName("auto_on_delay")
879 public Double autoOnDelay;
880 @SerializedName("auto_off")
881 public Boolean autoOff;
882 @SerializedName("auto_off_delay")
883 public Double autoOffDelay;
886 @SerializedName("sys_led_enable")
887 public Boolean sysLedEnable;
888 @SerializedName("power_led")
889 public String powerLed;
892 public static class Shelly2RpcRequest {
893 public Integer id = 0;
894 public String method;
896 public static class Shelly2RpcRequestParams {
897 public Integer id = 1;
904 public Integer brightness;
905 @SerializedName("toggle_after")
906 public Integer toggleAfter;
918 public Shelly2ConfigParms config;
923 public Shelly2RpcRequestParams withConfig() {
924 config = new Shelly2ConfigParms();
929 public Shelly2RpcRequestParams params = new Shelly2RpcRequestParams();
931 public Shelly2RpcRequest() {
934 public Shelly2RpcRequest withMethod(String method) {
935 this.method = method;
939 public Shelly2RpcRequest withId(int id) {
944 public Shelly2RpcRequest withPos(int pos) {
949 public Shelly2RpcRequest withName(String name) {
955 public static class Shelly2WsConfigResponse {
959 public static class Shelly2WsConfigResult {
960 @SerializedName("restart_required")
961 public Boolean restartRequired;
964 public Shelly2WsConfigResult result;
967 public static class ShellyScriptListResponse {
968 public static class ShellyScriptListEntry {
971 public Boolean enable;
972 public Boolean running;
975 public ArrayList<ShellyScriptListEntry> scripts;
978 public static class ShellyScriptResponse {
980 public Boolean running;
985 public static class ShellyScriptPutCodeParams {
988 public Boolean append;
991 public static class Shelly2RpcBaseMessage {
992 // Basic message format, e.g.
993 // {"id":1,"src":"localweb528","method":"Shelly.GetConfig"}
994 public class Shelly2RpcMessageError {
996 public String message;
1002 public String component;
1003 public String method;
1004 public Object params;
1005 public String event;
1006 public Object result;
1007 public Shelly2AuthRequest auth;
1008 public Shelly2RpcMessageError error;
1011 public static class Shelly2RpcNotifyStatus {
1012 public static class Shelly2NotifyStatus extends Shelly2DeviceStatusResult {
1019 public String method;
1020 public Shelly2NotifyStatus params;
1021 public Shelly2NotifyStatus result;
1022 public Shelly2RpcMessageError error;
1025 public static String SHELLY2_AUTHTTYPE_DIGEST = "digest";
1026 public static String SHELLY2_AUTHTTYPE_STRING = "string";
1027 public static String SHELLY2_AUTHALG_SHA256 = "SHA-256";
1028 // = ':auth:'+HexHash("dummy_method:dummy_uri");
1029 public static String SHELLY2_AUTH_NOISE = "6370ec69915103833b5222b368555393393f098bfbfbb59f47e0590af135f062";
1031 public static class Shelly2AuthRequest {
1032 public String username;
1036 public String realm;
1037 public String algorithm;
1038 public String response;
1039 @SerializedName("auth_type")
1040 public String authType;
1043 public static class Shelly2AuthResponse { // on 401 message contains the auth info
1044 @SerializedName("auth_type")
1045 public String authType;
1048 public String realm;
1049 public String algorithm;
1054 // {"component":"script:2", "id":2, "event":"oh-blu.scan_result",
1055 // "data":{"addr":"bc:02:6e:c3:a6:c7","rssi":-62,"tx_power":-128}, "ts":1682877414.21}
1056 // {"component":"script:2", "id":2, "event":"oh-blu.data",
1057 // "data":{"encryption":false,"BTHome_version":2,"pid":205,"Battery":100,"Button":1,"addr":"b4:35:22:fd:b3:81","rssi":-68},
1058 // "ts":1682877399.22}
1061 // {"component":"script:2", "id":2, "event":"oh-blu.scan_result",
1062 // "data":{"addr":"bc:02:6e:c3:a6:c7","rssi":-62,"tx_power":-128}, "ts":1682877414.21}
1063 // {"component":"script:2", "id":2, "event":"oh-blu.data",
1064 // "data":{"encryption":false,"BTHome_version":2,"pid":38,"Battery":100,"Illuminance":0,"Window":1,"Rotation":0,"addr":"bc:02:6e:c3:a6:c7","rssi":-62},
1065 // "ts":1682877414.25}
1067 public class Shelly2NotifyEventMessage {
1070 public Boolean encryption;
1071 @SerializedName("BTHome_version")
1072 public Integer bthVersion;
1074 @SerializedName("Battery")
1075 public Integer battery;
1076 @SerializedName("Button")
1077 public Integer buttonEvent;
1078 @SerializedName("Illuminance")
1079 public Integer illuminance;
1080 @SerializedName("Window")
1081 public Integer windowState;
1082 @SerializedName("Rotation")
1083 public Double rotation;
1085 public Integer rssi;
1086 public Integer tx_power;
1089 public class Shelly2NotifyEvent {
1092 public String component;
1093 public String event;
1094 public Shelly2NotifyEventMessage data;
1096 public Integer reason;
1097 @SerializedName("cfg_rev")
1098 public Integer cfgRev;
1101 public class Shelly2NotifyEventData {
1103 public ArrayList<Shelly2NotifyEvent> events;
1106 public static class Shelly2RpcNotifyEvent {
1109 public Shelly2NotifyEventData params;