]> git.basschouten.com Git - openhab-addons.git/blob
3beae4585370cd435b839c6d91af26488f875cc4
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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.senechome.internal;
14
15 /**
16  * Enum with available Senec specific wallbox states.
17  *
18  * @author Erwin Guib - Initial Contribution
19  */
20 public enum SenecWallboxStatus {
21     WAIT_FOR_EV(0xA1, "Waiting for EV"),
22     EV_ASKING_CHARGE(0xB1, "EV asking for charge"),
23     EV_CHARGE_PERMISSION(0xB2, "EV has charge permission"),
24     EV_CHARGING(0xC2, "Charging"),
25     EV_CHARGING_REDUCED_CURRENT_ERROR(0xC3, "Charging reduced current (error F16, F17)"),
26     EV_CHARGING_REDUCED_CURRENT_IMBALANCE(0xC4, "Charging reduced current (imbalance F15)"),
27     DISABLED(0xE0, "Wallbox disabled"),
28     TEST_PRODUCTION(0xE1, "production test"),
29     EVCC_PROGRAM(0xE2, "EVCC program mode"),
30     BUS_IDLE(0xE3, "Bus idle"),
31     UNEXPECTED_CLOSED_CONTACT(0xF1, "unexpected closed contact (welded)"),
32     INTERNAL_ERROR(0xF2, "Internal error"),
33     DC_RESIDUAL_CURRENT(0xF3, "DC residual current detected"),
34     UPSTREAM_COM_TIMEOUT(0xF4, "Upstream communication timeout"),
35     LOCK_SOCKET_FAILED(0xF5, "Lock of socket failed"),
36     CS_OUT_OF_RANGE(0xF6, "CS out of range"),
37     EV_HIGH_TEMP(0xF7, "State D requested by EV"),
38     CP_OUT_OF_RANGE(0xF8, "CP out of range"),
39     OVERCURRENT(0xF9, "Overcurrent detected"),
40     TEMP_OUT_OF_LIMITS(0xFA, "Temperature outside limits"),
41     UNEXPECTED_OPEN_CONTACT(0xFB, "unexpected opened contact"),
42     RESERVED_1(0xFC, "Reserved State"),
43     RESERVED_2(0xFD, "Reserved State"),
44     UNKNOWN(-1, "UNKNOWN");
45
46     private final int code;
47     private final String description;
48
49     SenecWallboxStatus(int index, String description) {
50         this.code = index;
51         this.description = description;
52     }
53
54     public int getCode() {
55         return code;
56     }
57
58     public String getDescription() {
59         return description;
60     }
61
62     public static SenecWallboxStatus fromCode(int code) {
63         for (SenecWallboxStatus state : SenecWallboxStatus.values()) {
64             if (state.code == code) {
65                 return state;
66             }
67         }
68         return SenecWallboxStatus.UNKNOWN;
69     }
70
71     public static String descriptionFromCode(int code) {
72         for (SenecWallboxStatus state : SenecWallboxStatus.values()) {
73             if (state.code == code) {
74                 return state.description;
75             }
76         }
77         return SenecWallboxStatus.UNKNOWN.description;
78     }
79 }