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.tapocontrol.internal.constants;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * The {@link TapoErrorCode} enum lists known errorcodes can be received or thrown by binding
20 * @author Christian Wild - Initial contribution
23 public enum TapoErrorCode {
25 ERR_UNKNOWN(-1, TapoErrorType.UNKNOWN),
26 ERR_API_SESSION_TIMEOUT(9999, TapoErrorType.COMMUNICATION_RETRY),
27 ERR_API_NULL_TRANSPORT(1000),
28 ERR_API_REQUEST(1002),
29 ERR_API_HAND_SHAKE_FAILED(1100, TapoErrorType.COMMUNICATION_RETRY),
30 ERR_API_LOGIN_FAILED(1111),
31 ERR_API_HTTP_TRANSPORT_FAILED(1112),
32 ERR_API_MULTI_REQUEST_FAILED(1200),
33 ERR_API_JSON_DECODE_FAIL(-1003),
34 ERR_API_JSON_ENCODE_FAIL(-1004),
35 ERR_API_AES_DECODE_FAIL(-1005),
36 ERR_API_REQUEST_LEN_ERROR(-1006),
37 ERR_API_CLOUD_FAILED(-1007),
38 ERR_API_PARAMS(-1008),
39 ERR_API_RSA_KEY_LENGTH(-1010),
40 ERR_API_SESSION_PARAM(-1101),
41 ERR_API_QUICK_SETUP(-1201),
42 ERR_API_DEVICE(-1301),
43 ERR_API_DEVICE_NEXT_EVENT(-1302),
44 ERR_API_FIRMWARE(-1401),
45 ERR_API_FIRMWARE_VER_ERROR(-1402),
48 ERR_API_TIME_SYS(-1602),
49 ERR_API_TIME_SAVE(-1603),
50 ERR_API_WIRELESS(-1701),
51 ERR_API_WIRELESS_UNSUPPORTED(-1702),
52 ERR_API_SCHEDULE(-1801),
53 ERR_API_SCHEDULE_FULL(-1802),
54 ERR_API_SCHEDULE_CONFLICT(-1803),
55 ERR_API_SCHEDULE_SAVE(-1804),
56 ERR_API_SCHEDULE_INDEX(-1805),
57 ERR_API_COUNTDOWN(-1901),
58 ERR_API_COUNTDOWN_CONFLICT(-1902),
59 ERR_API_COUNTDOWN_SAVE(-1903),
60 ERR_API_ANTITHEFT(-2001),
61 ERR_API_ANTITHEFT_CONFLICT(-2002),
62 ERR_API_ANTITHEFT_SAVE(-2003),
63 ERR_API_ACCOUNT(-2101),
65 ERR_API_STAT_SAVE(-2202),
67 ERR_API_DST_SAVE(-2302),
69 // List of Cloud-ErrorCodes
70 ERR_CLOUD_API_RATE(-20004),
71 ERR_CLOUD_CREDENTIALS(-20601),
72 ERR_CLOUD_JSON_FORMAT(-10100),
73 ERR_CLOUD_METHOD_MISSING(-20103),
74 ERR_CLOUD_PARAMETER_MISSING(-20104),
75 ERR_CLOUD_TOKEN_EXPIRED(-20651),
77 // List of Binding-ErrorCodes
78 ERR_BINDING_HTTP_RESPONSE(9001, TapoErrorType.COMMUNICATION_ERROR),
79 ERR_BINDING_COOKIE(9002, TapoErrorType.COMMUNICATION_ERROR),
80 ERR_BINDING_CREDENTIALS(9003, TapoErrorType.CONFIGURATION_ERROR),
81 ERR_BINDING_DEVICE_OFFLINE(9009, TapoErrorType.COMMUNICATION_ERROR),
82 ERR_BINDING_CONNECT_TIMEOUT(9010, TapoErrorType.COMMUNICATION_ERROR),
84 // List of Binding-Config-ErrorCodes
85 ERR_CONFIG_IP(10001, TapoErrorType.CONFIGURATION_ERROR), // ip not set
86 ERR_CONFIG_CREDENTIALS(10002, TapoErrorType.CONFIGURATION_ERROR), // credentials not set
87 ERR_CONFIG_NO_BRIDGE(10003, TapoErrorType.CONFIGURATION_ERROR); // no bridge configured
90 private TapoErrorType errorType;
93 private TapoErrorCode(Integer code) {
95 this.errorType = TapoErrorType.GENERAL;
98 private TapoErrorCode(Integer code, TapoErrorType errorType) {
100 this.errorType = errorType;
104 public Integer getCode() {
108 public TapoErrorType getType() {
109 return this.errorType;
112 public static TapoErrorCode fromCode(int errorCode) {
113 for (TapoErrorCode e : TapoErrorCode.values()) {
114 if (e.code.equals(errorCode))