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_SMOKE_SETCONFIG = "Smoke.SetConfig";
65 public static final String SHELLYRPC_METHOD_SMOKE_MUTE = "Smoke.Mute";
66 public static final String SHELLYRPC_METHOD_SCRIPT_LIST = "Script.List";
67 public static final String SHELLYRPC_METHOD_SCRIPT_SETCONFIG = "Script.SetConfig";
68 public static final String SHELLYRPC_METHOD_SCRIPT_GETSTATUS = "Script.GetStatus";
69 public static final String SHELLYRPC_METHOD_SCRIPT_DELETE = "Script.Delete";
70 public static final String SHELLYRPC_METHOD_SCRIPT_CREATE = "Script.Create";
71 public static final String SHELLYRPC_METHOD_SCRIPT_GETCODE = "Script.GetCode";
72 public static final String SHELLYRPC_METHOD_SCRIPT_PUTCODE = "Script.PutCode";
73 public static final String SHELLYRPC_METHOD_SCRIPT_START = "Script.Start";
74 public static final String SHELLYRPC_METHOD_SCRIPT_STOP = "Script.Stop";
76 public static final String SHELLYRPC_METHOD_NOTIFYSTATUS = "NotifyStatus"; // inbound status
77 public static final String SHELLYRPC_METHOD_NOTIFYFULLSTATUS = "NotifyFullStatus"; // inbound status from bat device
78 public static final String SHELLYRPC_METHOD_NOTIFYEVENT = "NotifyEvent"; // inbound event
81 public static final String SHELLY2_PROFILE_RELAY = "switch";
82 public static final String SHELLY2_PROFILE_ROLLER = "cover";
85 public static final String SHELLY2_BTNT_MOMENTARY = "momentary";
86 public static final String SHELLY2_BTNT_FLIP = "flip";
87 public static final String SHELLY2_BTNT_FOLLOW = "follow";
88 public static final String SHELLY2_BTNT_DETACHED = "detached";
91 public static final String SHELLY2_INPUTT_SWITCH = "switch";
92 public static final String SHELLY2_INPUTT_BUTTON = "button";
93 public static final String SHELLY2_INPUTT_ANALOG = "analog"; // Shelly Addon: analogous input
96 public static final String SHELLY2_API_MODE_DETACHED = "detached";
97 public static final String SHELLY2_API_MODE_FOLLOW = "follow";
99 // Initial switch states
100 public static final String SHELLY2_API_ISTATE_ON = "on";
101 public static final String SHELLY2_API_ISTATE_OFF = "off";
102 public static final String SHELLY2_API_ISTATE_FOLLOWLAST = "restore_last";
103 public static final String SHELLY2_API_ISTATE_MATCHINPUT = "match_input";
105 // Cover/Roller modes
106 public static final String SHELLY2_RMODE_SINGLE = "single";
107 public static final String SHELLY2_RMODE_DUAL = "dual";
108 public static final String SHELLY2_RMODE_DETACHED = "detached";
110 public static final String SHELLY2_RSTATE_OPENING = "opening";
111 public static final String SHELLY2_RSTATE_OPEN = "open";
112 public static final String SHELLY2_RSTATE_CLOSING = "closing";
113 public static final String SHELLY2_RSTATE_CLOSED = "closed";
114 public static final String SHELLY2_RSTATE_STOPPED = "stopped";
115 public static final String SHELLY2_RSTATE_CALIB = "calibrating";
117 // Event notifications
118 public static final String SHELLY2_EVENT_BTNUP = "btn_up";
119 public static final String SHELLY2_EVENT_BTNDOWN = "btn_down";
120 public static final String SHELLY2_EVENT_1PUSH = "single_push";
121 public static final String SHELLY2_EVENT_2PUSH = "double_push";
122 public static final String SHELLY2_EVENT_3PUSH = "triple_push";
123 public static final String SHELLY2_EVENT_LPUSH = "long_push";
124 public static final String SHELLY2_EVENT_SLPUSH = "short_long_push";
125 public static final String SHELLY2_EVENT_LSPUSH = "long_short_push";
127 public static final String SHELLY2_EVENT_SLEEP = "sleep";
128 public static final String SHELLY2_EVENT_CFGCHANGED = "config_changed";
129 public static final String SHELLY2_EVENT_OTASTART = "ota_begin";
130 public static final String SHELLY2_EVENT_OTAPROGRESS = "ota_progress";
131 public static final String SHELLY2_EVENT_OTADONE = "ota_success";
132 public static final String SHELLY2_EVENT_WIFICONNFAILED = "sta_connect_fail";
133 public static final String SHELLY2_EVENT_WIFIDISCONNECTED = "sta_disconnected";
136 public static final String SHELLY2_BLU_GWSCRIPT = "oh-blu-scanner.js";
137 public static final String SHELLY2_EVENT_BLUPREFIX = "oh-blu.";
138 public static final String SHELLY2_EVENT_BLUSCAN = SHELLY2_EVENT_BLUPREFIX + "scan_result";
139 public static final String SHELLY2_EVENT_BLUDATA = SHELLY2_EVENT_BLUPREFIX + "data";
142 public static final String SHELLY2_ERROR_OVERPOWER = "overpower";
143 public static final String SHELLY2_ERROR_OVERTEMP = "overtemp";
144 public static final String SHELLY2_ERROR_OVERVOLTAGE = "overvoltage";
146 // Wakeup reasons (e.g. Plus HT)
147 public static final String SHELLY2_WAKEUPO_BOOT_POWERON = "poweron";
148 public static final String SHELLY2_WAKEUPO_BOOT_RESTART = "software_restart";
149 public static final String SHELLY2_WAKEUPO_BOOT_WAKEUP = "deepsleep_wake";
150 public static final String SHELLY2_WAKEUPO_BOOT_INTERNAL = "internal";
151 public static final String SHELLY2_WAKEUPO_BOOT_UNKNOWN = "unknown";
153 public static final String SHELLY2_WAKEUPOCAUSE_BUTTON = "button";
154 public static final String SHELLY2_WAKEUPOCAUSE_USB = "usb";
155 public static final String SHELLY2_WAKEUPOCAUSE_PERIODIC = "periodic";
156 public static final String SHELLY2_WAKEUPOCAUSE_UPDATE = "status_update";
157 public static final String SHELLY2_WAKEUPOCAUSE_UNDEFINED = "undefined";
159 // Dimmer US: LED power modes
160 public static final String SHELLY2_POWERLED_ON = "on";
161 public static final String SHELLY2_POWERLED_OFF = "off";
162 public static final String SHELLY2_POWERLED_MATCH = "match_output";
163 public static final String SHELLY2_POWERLED_INVERT = "inverted_output";
165 public class Shelly2DevConfigBle {
166 public Boolean enable;
169 public class Shelly2DevConfigEth {
170 public Boolean enable;
171 public String ipv4mode;
173 public String netmask;
175 public String nameserver;
178 public static class Shelly2DeviceSettings {
184 @SerializedName("fw_id")
185 public String firmware;
188 @SerializedName("auth_en")
189 public Boolean authEnable;
190 @SerializedName("auth_domain")
191 public String authDomain;
194 public static class Shelly2DeviceConfigAp {
195 public static class Shelly2DeviceConfigApRE {
196 public Boolean enable;
199 public Boolean enable;
201 public String password;
202 @SerializedName("is_open")
203 public Boolean isOpen;
204 @SerializedName("range_extender")
205 Shelly2DeviceConfigApRE rangeExtender;
208 public static class Shelly2DeviceConfig {
209 public class Shelly2DeviceConfigSys {
210 public class Shelly2DeviceConfigDevice {
213 @SerializedName("fw_id")
215 public String profile;
216 @SerializedName("eco_mode")
217 public Boolean ecoMode;
218 public Boolean discoverable;
221 public class Shelly2DeviceConfigLocation {
227 public class Shelly2DeviceConfigSntp {
228 public String server;
231 public class Shelly2DeviceConfigSleep {
232 @SerializedName("wakeup_period")
233 public Integer wakeupPeriod;
236 public class Shelly2DeviceConfigDebug {
237 public class Shelly2DeviceConfigDebugMqtt {
238 public Boolean enable;
241 public class Shelly2DeviceConfigDebugWebSocket {
242 public Boolean enable;
245 public class Shelly2DeviceConfigDebugUdp {
249 public Shelly2DeviceConfigDebugMqtt mqtt;
250 public Shelly2DeviceConfigDebugWebSocket websocket;
251 public Shelly2DeviceConfigDebugUdp udp;
254 public class Shelly2DeviceConfigUiData {
255 public String cover; // hold comma seperated list of roller favorites
258 public class Shelly2DeviceConfigRpcUdp {
259 @SerializedName("dst_addr")
260 public String dstAddr;
261 @SerializedName("listenPort")
262 public String listenPort;
265 @SerializedName("cfg_rev")
266 public Integer cfgRevision;
267 public Shelly2DeviceConfigDevice device;
268 public Shelly2DeviceConfigLocation location;
269 public Shelly2DeviceConfigSntp sntp;
270 public Shelly2DeviceConfigSleep sleep;
271 public Shelly2DeviceConfigDebug debug;
272 @SerializedName("ui_data")
273 public Shelly2DeviceConfigUiData uiData;
274 @SerializedName("rpc_udp")
275 public Shelly2DeviceConfigRpcUdp rpcUdp;
278 public class Shelly2DevConfigInput {
282 public Boolean invert;
283 @SerializedName("factory_reset")
284 public Boolean factoryReset;
285 @SerializedName("report_thr")
286 public Double reportTreshold; // only for type analog
289 public class Shelly2DevConfigSwitch {
293 @SerializedName("in_mode")
296 @SerializedName("initial_state")
297 public String initialState;
298 @SerializedName("auto_on")
299 public Boolean autoOn;
300 @SerializedName("auto_on_delay")
301 public Double autoOnDelay;
302 @SerializedName("auto_off")
303 public Boolean autoOff;
304 @SerializedName("auto_off_delay")
305 public Double autoOffDelay;
306 @SerializedName("power_limit")
307 public Integer powerLimit;
308 @SerializedName("voltage_limit")
309 public Integer voltageLimit;
310 @SerializedName("current_limit")
311 public Double currentLimit;
314 public static class Shelly2DevConfigEm {
317 @SerializedName("blink_mode_selector")
318 public String blinkModeSelector;
319 @SerializedName("phase_selector")
320 public String phase_selector;
321 @SerializedName("monitor_phase_sequence")
322 public Boolean monitorPhaseSequence;
325 public class Shelly2DevConfigCover {
326 public class Shelly2DeviceConfigCoverMotor {
327 @SerializedName("idle_power_thr")
328 public Double idle_powerThr;
331 public class Shelly2DeviceConfigCoverSafetySwitch {
332 public Boolean enable;
333 public String direction;
334 public String action;
335 @SerializedName("allowed_move")
336 public String allowedMove;
339 public class Shelly2DeviceConfigCoverObstructionDetection {
340 public Boolean enable;
341 public String direction;
342 public String action;
343 @SerializedName("power_thr")
344 public Integer powerThr;
345 public Double holdoff;
350 public Shelly2DeviceConfigCoverMotor motor;
351 @SerializedName("maxtime_open")
352 public Double maxtimeOpen;
353 @SerializedName("maxtime_close")
354 public Double maxtimeClose;
355 @SerializedName("initial_state")
356 public String initialState;
357 @SerializedName("invert_directions")
358 public Boolean invertDirections;
359 @SerializedName("in_mode")
360 public String inMode;
361 @SerializedName("swap_inputs")
362 public Boolean swapInputs;
363 @SerializedName("safety_switch")
364 public Shelly2DeviceConfigCoverSafetySwitch safetySwitch;
365 @SerializedName("power_limit")
366 public Integer powerLimit;
367 @SerializedName("voltage_limit")
368 public Integer voltageLimit;
369 @SerializedName("current_limit")
370 public Double currentLimit;
371 @SerializedName("obstruction_detection")
372 public Shelly2DeviceConfigCoverObstructionDetection obstructionDetection;
375 public static class Shelly2ConfigSmoke {
377 public Boolean alarm;
381 public static class Shelly2GetConfigLight {
382 public static class Shelly2GetConfigLightDefault {
383 public Integer brightness;
386 public static class Shelly2GetConfigLightNightMode {
387 public boolean enable;
388 public Integer brightness;
393 @SerializedName("initial_state")
394 public String initialState;
395 @SerializedName("auto_on")
396 public Boolean autoOn;
397 @SerializedName("auto_off")
398 public Boolean autoOff;
399 @SerializedName("auto_on_delay")
400 public Double autoOnDelay;
401 @SerializedName("auto_off_delay")
402 public Double autoOffDelay;
403 @SerializedName("default")
404 public Shelly2GetConfigLightDefault defaultCfg;
405 @SerializedName("night_mode")
406 public Shelly2GetConfigLightNightMode nightMode;
409 public class Shelly2DeviceConfigLed {
410 @SerializedName("sys_led_enable")
411 public Boolean sysLedEnable;
412 @SerializedName("power_led")
413 public String powerLed;
416 public static class Shelly2GetConfigResult {
418 public class Shelly2DevConfigCloud {
419 public Boolean enable;
420 public String server;
423 public class Shelly2DevConfigMqtt {
424 public Boolean enable;
425 public String server;
427 @SerializedName("topic_prefix:0")
428 public String topicPrefix;
429 @SerializedName("rpc_ntf")
430 public String rpcNtf;
431 @SerializedName("status_ntf")
432 public String statusNtf;
435 public Shelly2DevConfigBle ble;
436 public Shelly2DevConfigEth eth;
437 public Shelly2DevConfigCloud cloud;
438 public Shelly2DevConfigMqtt mqtt;
439 public Shelly2DeviceConfigSys sys;
440 public Shelly2DeviceConfigWiFi wifi;
441 @SerializedName("wd_ui")
442 public Shelly2DeviceConfigLed led;
444 @SerializedName("input:0")
445 public Shelly2DevConfigInput input0;
446 @SerializedName("input:1")
447 public Shelly2DevConfigInput input1;
448 @SerializedName("input:2")
449 public Shelly2DevConfigInput input2;
450 @SerializedName("input:3")
451 public Shelly2DevConfigInput input3;
453 @SerializedName("switch:0")
454 public Shelly2DevConfigSwitch switch0;
455 @SerializedName("switch:1")
456 public Shelly2DevConfigSwitch switch1;
457 @SerializedName("switch:2")
458 public Shelly2DevConfigSwitch switch2;
459 @SerializedName("switch:3")
460 public Shelly2DevConfigSwitch switch3;
462 @SerializedName("em:0")
463 public Shelly2DevConfigEm em0;
465 @SerializedName("cover:0")
466 public Shelly2DevConfigCover cover0;
468 @SerializedName("light:0")
469 public Shelly2GetConfigLight light0;
471 @SerializedName("smoke:0")
472 public Shelly2ConfigSmoke smoke0;
475 public class Shelly2DeviceConfigSta {
477 public String password;
478 @SerializedName("is_open")
479 public Boolean isOpen;
480 public Boolean enable;
481 public String ipv4mode;
483 public String netmask;
485 public String nameserver;
488 public class Shelly2DeviceConfigRoam {
489 @SerializedName("rssi_thr")
490 public Integer rssiThr;
491 public Integer interval;
494 public class Shelly2DeviceConfigWiFi {
495 public Shelly2DeviceConfigAp ap;
496 public Shelly2DeviceConfigSta sta;
497 public Shelly2DeviceConfigSta sta1;
498 public Shelly2DeviceConfigRoam roam;
503 public Shelly2GetConfigResult result;
506 public static class Shelly2DeviceStatus {
507 public class Shelly2InputStatus {
509 public Boolean state;
510 public Double percent; // analog input only
511 public ArrayList<String> errors;// shown only if at least one error is present.
514 public static class Shelly2DeviceStatusLight {
516 public String source;
517 public Boolean output;
518 public Double brightness;
519 @SerializedName("timer_started_at")
520 public Double timerStartedAt;
521 @SerializedName("timer_duration")
522 public Integer timerDuration;
525 public static class Shelly2DeviceStatusResult {
526 public class Shelly2DeviceStatusBle {
530 public class Shelly2DeviceStatusCloud {
531 public Boolean connected;
534 public class Shelly2DeviceStatusMqqt {
535 public Boolean connected;
538 public class Shelly2CoverStatus {
540 public String source;
542 public Double apower;
543 public Double voltage;
544 public Double current;
546 public Shelly2Energy aenergy;
547 @SerializedName("current_pos")
548 public Integer currentPos;
549 @SerializedName("target_pos")
550 public Integer targetPos;
551 @SerializedName("move_timeout")
552 public Double moveTimeout;
553 @SerializedName("move_started_at")
554 public Double moveStartedAt;
555 @SerializedName("pos_control")
556 public Boolean posControl;
557 public Shelly2DeviceStatusTemp temperature;
558 public ArrayList<String> errors;
561 public class Shelly2DeviceStatusHumidity {
566 public class Shelly2DeviceStatusIlluminance {
569 public String illumination;
572 public class Shelly2DeviceStatusVoltage {
574 public Double voltage;
577 public class Shelly2DeviceStatusTempId extends Shelly2DeviceStatusTemp {
581 public static class Shelly2DeviceStatusPower {
582 public static class Shelly2DeviceStatusBattery {
585 public Double percent;
588 public static class Shelly2DeviceStatusCharger {
589 public Boolean present;
593 public Shelly2DeviceStatusBattery battery;
594 public Shelly2DeviceStatusCharger external;
597 public static class Shelly2DeviceStatusEm {
600 @SerializedName("a_current")
601 public Double aCurrent;
602 @SerializedName("a_voltage")
603 public Double aVoltage;
604 @SerializedName("a_act_power")
605 public Double aActPower;
606 @SerializedName("a_aprt_power")
607 public Double aAprtPower;
608 @SerializedName("a_pf")
611 @SerializedName("b_current")
612 public Double bCurrent;
613 @SerializedName("b_voltage")
614 public Double bVoltage;
615 @SerializedName("b_act_power")
616 public Double bActPower;
617 @SerializedName("b_aprt_power")
618 public Double bAprtPower;
619 @SerializedName("b_pf")
622 @SerializedName("c_current")
623 public Double cCurrent;
624 @SerializedName("c_voltage")
625 public Double cVoltage;
626 @SerializedName("c_act_power")
627 public Double cActPower;
628 @SerializedName("c_aprt_power")
629 public Double cAprtPower;
630 @SerializedName("c_pf")
633 @SerializedName("n_current")
634 public Double nCurrent;
636 @SerializedName("total_current")
637 public Double totalCurrent;
638 @SerializedName("total_act_power")
639 public Double totalActPower;
640 @SerializedName("total_aprt_power")
641 public Double totalAprtPower;
644 public static class Shelly2DeviceStatusEmData {
646 public String[] errors;
649 public class Shelly2DeviceStatusSmoke {
651 public Boolean alarm;
655 public Shelly2DeviceStatusBle ble;
656 public Shelly2DeviceStatusCloud cloud;
657 public Shelly2DeviceStatusMqqt mqtt;
658 public Shelly2DeviceStatusSys sys;
659 public Shelly2DeviceStatusSysWiFi wifi;
661 @SerializedName("input:0")
662 public Shelly2InputStatus input0;
663 @SerializedName("input:1")
664 public Shelly2InputStatus input1;
665 @SerializedName("input:2")
666 public Shelly2InputStatus input2;
667 @SerializedName("input:3")
668 public Shelly2InputStatus input3;
669 @SerializedName("input:100")
670 public Shelly2InputStatus input100; // Digital Input from Add-On
672 @SerializedName("switch:0")
673 public Shelly2RelayStatus switch0;
674 @SerializedName("switch:1")
675 public Shelly2RelayStatus switch1;
676 @SerializedName("switch:2")
677 public Shelly2RelayStatus switch2;
678 @SerializedName("switch:3")
679 public Shelly2RelayStatus switch3;
681 @SerializedName("em:0")
682 Shelly2DeviceStatusEm em0;
683 @SerializedName("emdata:0")
684 Shelly2DeviceStatusEmData emdata0;
686 @SerializedName("cover:0")
687 public Shelly2CoverStatus cover0;
689 @SerializedName("light:0")
690 public Shelly2DeviceStatusLight light0;
692 @SerializedName("temperature:0")
693 public Shelly2DeviceStatusTempId temperature0;
694 @SerializedName("temperature:100")
695 public Shelly2DeviceStatusTempId temperature100;
696 @SerializedName("temperature:101")
697 public Shelly2DeviceStatusTempId temperature101;
698 @SerializedName("temperature:102")
699 public Shelly2DeviceStatusTempId temperature102;
700 @SerializedName("temperature:103")
701 public Shelly2DeviceStatusTempId temperature103;
702 @SerializedName("temperature:104")
703 public Shelly2DeviceStatusTempId temperature104;
705 @SerializedName("humidity:0")
706 public Shelly2DeviceStatusHumidity humidity0;
707 @SerializedName("humidity:100")
708 public Shelly2DeviceStatusHumidity humidity100;
710 @SerializedName("illuminance:0")
711 Shelly2DeviceStatusIlluminance illuminance0;
713 @SerializedName("smoke:0")
714 public Shelly2DeviceStatusSmoke smoke0;
716 @SerializedName("voltmeter:100")
717 public Shelly2DeviceStatusVoltage voltmeter100;
719 @SerializedName("devicepower:0")
720 public Shelly2DeviceStatusPower devicepower0;
723 public class Shelly2DeviceStatusSys {
724 public class Shelly2DeviceStatusSysAvlUpdate {
725 public class Shelly2DeviceStatusSysUpdate {
726 public String version;
729 public Shelly2DeviceStatusSysUpdate stable;
730 public Shelly2DeviceStatusSysUpdate beta;
733 public class Shelly2DeviceStatusWakeup {
739 @SerializedName("restart_required")
740 public Boolean restartRequired;
742 public Long unixtime;
744 @SerializedName("ram_size")
746 @SerializedName("ram_free")
748 @SerializedName("fs_size")
750 @SerializedName("fs_free")
752 @SerializedName("cfg_rev")
753 public Integer cfg_rev;
754 @SerializedName("available_updates")
755 public Shelly2DeviceStatusSysAvlUpdate availableUpdates;
756 @SerializedName("webhook_rev")
757 public Integer webHookRev;
758 @SerializedName("wakeup_reason")
759 public Shelly2DeviceStatusWakeup wakeUpReason;
760 @SerializedName("wakeup_period")
761 public Integer wakeupPeriod;
764 public class Shelly2DeviceStatusSysWiFi {
765 @SerializedName("sta_ip")
767 public String status;
770 @SerializedName("ap_client_count")
771 public Integer apClientCount;
776 public Shelly2DeviceStatusResult result;
779 public static class Shelly2RelayStatus {
781 public String source;
782 public Boolean output;
783 @SerializedName("timer_started_at")
784 public Double timerStartetAt;
785 @SerializedName("timer_duration")
786 public Integer timerDuration;
787 public Double apower;
788 public Double voltage;
789 public Double current;
791 public Shelly2Energy aenergy;
792 public Shelly2DeviceStatusTemp temperature;
793 public String[] errors;
796 public static class Shelly2DeviceStatusTemp {
801 public static class Shelly2Energy {
802 // "switch:1":{"id":1,"aenergy":{"total":0.003,"by_minute":[0.000,0.000,0.000],"minute_ts":1619910239}}}}
804 @SerializedName("by_minute")
805 public Double[] byMinute;
806 @SerializedName("minute_ts")
807 public Long minuteTs;
810 public static class Shelly2ConfigParms {
812 public Boolean enable;
813 public String server;
814 @SerializedName("ssl_ca")
818 public Shelly2DeviceConfigAp ap;
821 @SerializedName("auto_on")
822 public Boolean autoOn;
823 @SerializedName("auto_on_delay")
824 public Double autoOnDelay;
825 @SerializedName("auto_off")
826 public Boolean autoOff;
827 @SerializedName("auto_off_delay")
828 public Double autoOffDelay;
831 @SerializedName("sys_led_enable")
832 public Boolean sysLedEnable;
833 @SerializedName("power_led")
834 public String powerLed;
837 public static class Shelly2RpcRequest {
838 public Integer id = 0;
839 public String method;
841 public static class Shelly2RpcRequestParams {
842 public Integer id = 1;
849 public Integer brightness;
850 @SerializedName("toggle_after")
851 public Integer toggleAfter;
863 public Shelly2ConfigParms config;
868 public Shelly2RpcRequestParams withConfig() {
869 config = new Shelly2ConfigParms();
874 public Shelly2RpcRequestParams params = new Shelly2RpcRequestParams();
876 public Shelly2RpcRequest() {
879 public Shelly2RpcRequest withMethod(String method) {
880 this.method = method;
884 public Shelly2RpcRequest withId(int id) {
889 public Shelly2RpcRequest withPos(int pos) {
894 public Shelly2RpcRequest withName(String name) {
900 public static class Shelly2WsConfigResponse {
904 public static class Shelly2WsConfigResult {
905 @SerializedName("restart_required")
906 public Boolean restartRequired;
909 public Shelly2WsConfigResult result;
912 public static class ShellyScriptListResponse {
913 public static class ShellyScriptListEntry {
916 public Boolean enable;
917 public Boolean running;
920 public ArrayList<ShellyScriptListEntry> scripts;
923 public static class ShellyScriptResponse {
925 public Boolean running;
930 public static class ShellyScriptPutCodeParams {
933 public Boolean append;
936 public static class Shelly2RpcBaseMessage {
937 // Basic message format, e.g.
938 // {"id":1,"src":"localweb528","method":"Shelly.GetConfig"}
939 public class Shelly2RpcMessageError {
941 public String message;
947 public String component;
948 public String method;
949 public Object params;
951 public Object result;
952 public Shelly2AuthRequest auth;
953 public Shelly2RpcMessageError error;
956 public static class Shelly2RpcNotifyStatus {
957 public static class Shelly2NotifyStatus extends Shelly2DeviceStatusResult {
964 public String method;
965 public Shelly2NotifyStatus params;
966 public Shelly2NotifyStatus result;
967 public Shelly2RpcMessageError error;
970 public static String SHELLY2_AUTHTTYPE_DIGEST = "digest";
971 public static String SHELLY2_AUTHTTYPE_STRING = "string";
972 public static String SHELLY2_AUTHALG_SHA256 = "SHA-256";
973 // = ':auth:'+HexHash("dummy_method:dummy_uri");
974 public static String SHELLY2_AUTH_NOISE = "6370ec69915103833b5222b368555393393f098bfbfbb59f47e0590af135f062";
976 public static class Shelly2AuthRequest {
977 public String username;
982 public String algorithm;
983 public String response;
984 @SerializedName("auth_type")
985 public String authType;
988 public static class Shelly2AuthResponse { // on 401 message contains the auth info
989 @SerializedName("auth_type")
990 public String authType;
994 public String algorithm;
999 // {"component":"script:2", "id":2, "event":"oh-blu.scan_result",
1000 // "data":{"addr":"bc:02:6e:c3:a6:c7","rssi":-62,"tx_power":-128}, "ts":1682877414.21}
1001 // {"component":"script:2", "id":2, "event":"oh-blu.data",
1002 // "data":{"encryption":false,"BTHome_version":2,"pid":205,"Battery":100,"Button":1,"addr":"b4:35:22:fd:b3:81","rssi":-68},
1003 // "ts":1682877399.22}
1006 // {"component":"script:2", "id":2, "event":"oh-blu.scan_result",
1007 // "data":{"addr":"bc:02:6e:c3:a6:c7","rssi":-62,"tx_power":-128}, "ts":1682877414.21}
1008 // {"component":"script:2", "id":2, "event":"oh-blu.data",
1009 // "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},
1010 // "ts":1682877414.25}
1012 public class Shelly2NotifyEventMessage {
1015 public Boolean encryption;
1016 @SerializedName("BTHome_version")
1017 public Integer bthVersion;
1019 @SerializedName("Battery")
1020 public Integer battery;
1021 @SerializedName("Button")
1022 public Integer buttonEvent;
1023 @SerializedName("Illuminance")
1024 public Integer illuminance;
1025 @SerializedName("Window")
1026 public Integer windowState;
1027 @SerializedName("Rotation")
1028 public Double rotation;
1030 public Integer rssi;
1031 public Integer tx_power;
1034 public class Shelly2NotifyEvent {
1037 public String component;
1038 public String event;
1039 public Shelly2NotifyEventMessage data;
1041 public Integer reason;
1042 @SerializedName("cfg_rev")
1043 public Integer cfgRev;
1046 public class Shelly2NotifyEventData {
1048 public ArrayList<Shelly2NotifyEvent> events;
1051 public static class Shelly2RpcNotifyEvent {
1054 public Shelly2NotifyEventData params;