]> git.basschouten.com Git - openhab-addons.git/blob
b8131fb16baf0180d32913845327552d4a504013
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.solax.internal.model;
14
15 import java.util.stream.Stream;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * The {@link InverterType} class is enum representing the different inverter types with a simple logic to convert from
21  * int(coming from the JSON) to a more meaningful enum value.
22  *
23  * @author Konstantin Polihronov - Initial contribution
24  */
25 @NonNullByDefault
26 public enum InverterType {
27
28     X1_LX(1),
29     X_HYBRID(2),
30     X1_HYBRID_FIT(3),
31     X1_BOOST_AIR_MINI(4),
32     X3_HYBRID_FIT(5),
33     X3_20K_30K(6),
34     X3_MIC_PRO(7),
35     X1_SMART(8),
36     X1_AC(9),
37     A1_HYBRID(10),
38     A1_FIT(11),
39     A1_GRID(12),
40     J1_ESS(13),
41     X3_HYBRID_G4(14),
42     X1_HYBRID_G4(15),
43     UNKNOWN(-1);
44
45     private int typeIndex;
46
47     InverterType(int typeIndex) {
48         this.typeIndex = typeIndex;
49     }
50
51     public static InverterType fromIndex(int index) {
52         InverterType[] values = InverterType.values();
53         return Stream.of(values).filter(value -> value.typeIndex == index).findFirst().orElse(UNKNOWN);
54     }
55 }