]> git.basschouten.com Git - openhab-addons.git/blob
7ddfae0e44f8c7d78719197785fead3f22cc4a7a
[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.daikin.internal.api.airbase;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 /**
20  * Container class for enums related to Daikin Airbase A/C systems
21  *
22  * @author Tim Waterhouse - Initial contribution
23  * @author Paul Smedley - Mods for Daikin Airbase Units
24  *
25  */
26 @NonNullByDefault
27 public class AirbaseEnums {
28     public enum AirbaseMode {
29         COLD(2, "Cooling"),
30         HEAT(1, "Heating"),
31         FAN(0, "Fan"),
32         DRY(7, "Dehumidifier"),
33         AUTO(3, "Auto");
34
35         private static final Logger LOGGER = LoggerFactory.getLogger(AirbaseMode.class);
36         private final int value;
37         private final String label;
38
39         AirbaseMode(int value, String label) {
40             this.value = value;
41             this.label = label;
42         }
43
44         public int getValue() {
45             return value;
46         }
47
48         public String getLabel() {
49             return label;
50         }
51
52         public static AirbaseMode fromValue(int value) {
53             for (AirbaseMode m : AirbaseMode.values()) {
54                 if (m.getValue() == value) {
55                     return m;
56                 }
57             }
58             LOGGER.debug("Unexpected Mode value of \"{}\"", value);
59             return AUTO;
60         }
61     }
62
63     public enum AirbaseFanSpeed {
64         // level,f_auto,f_airside
65         AUTO(0, false, false),
66         LEVEL_1(1, false, false),
67         LEVEL_2(2, false, false),
68         LEVEL_3(3, false, false),
69         LEVEL_4(4, false, false),
70         LEVEL_5(5, false, false),
71         AUTO_LEVEL_1(1, true, false),
72         AUTO_LEVEL_2(2, true, false),
73         AUTO_LEVEL_3(3, true, false),
74         AUTO_LEVEL_4(4, true, false),
75         AUTO_LEVEL_5(5, true, false),
76         AIRSIDE(1, false, true);
77
78         private static final Logger LOGGER = LoggerFactory.getLogger(AirbaseFanSpeed.class);
79         private final int level;
80         private final boolean auto;
81         private final boolean airside;
82
83         AirbaseFanSpeed(int level, boolean auto, boolean airside) {
84             this.level = level;
85             this.auto = auto;
86             this.airside = airside;
87         }
88
89         public int getLevel() {
90             return level;
91         }
92
93         public boolean getAuto() {
94             return auto;
95         }
96
97         public boolean getAirside() {
98             return airside;
99         }
100
101         public String getLabel() {
102             if (airside) {
103                 return "Airside";
104             }
105             if (level == 0) {
106                 return "Auto";
107             }
108             String label = "";
109             if (auto) {
110                 label = "Auto ";
111             }
112             return label + "Level " + Integer.toString(level);
113         }
114
115         public static AirbaseFanSpeed fromValue(int rate, boolean auto, boolean airside) { // convert from f_rate,
116                                                                                            // f_auto, f_airside
117             if (airside) {
118                 return AIRSIDE;
119             }
120             if (rate == 0) {
121                 return AirbaseFanSpeed.AUTO;
122             }
123             for (AirbaseFanSpeed m : AirbaseFanSpeed.values()) {
124                 if (m.getLevel() == rate && m.getAuto() == auto && m.getAirside() == airside) {
125                     return m;
126                 }
127             }
128             LOGGER.debug("Unexpected FanSpeed value from rate={}, auto={}, airside={}", rate, auto ? 1 : 0,
129                     airside ? 1 : 0);
130             return LEVEL_1;
131         }
132     }
133
134     public enum AirbaseFanMovement {
135         UNKNOWN(-1),
136         STOPPED(0),
137         VERTICAL(1),
138         HORIZONTAL(2),
139         VERTICAL_AND_HORIZONTAL(3);
140
141         private static final Logger LOGGER = LoggerFactory.getLogger(AirbaseFanMovement.class);
142         private final int value;
143
144         AirbaseFanMovement(int value) {
145             this.value = value;
146         }
147
148         public int getValue() {
149             return value;
150         }
151
152         public static AirbaseFanMovement fromValue(int value) {
153             for (AirbaseFanMovement m : AirbaseFanMovement.values()) {
154                 if (m.getValue() == value) {
155                     return m;
156                 }
157             }
158             LOGGER.debug("Unexpected FanMovement value of \"{}\"", value);
159             return STOPPED;
160         }
161     }
162
163     public enum AirbaseFeature {
164         ZONE("en_zone"),
165         FILTER_SIGN("en_filter_sign"),
166         TEMP_SETTING("en_temp_setting"),
167         FRATE("en_frate"),
168         DIR("en_dir"),
169         RTEMP_A("en_rtemp_a"),
170         SPMODE("en_spmode"),
171         MOMPOW("en_mompow"),
172         PATROL("en_patrol"),
173         AIRSIDE("en_airside"),
174         QUICK_TIMER("en_quick_timer"),
175         AUTO("en_auto"),
176         DRY("en_dry"),
177         FRATE_AUTO("en_frate_auto");
178
179         private static final Logger LOGGER = LoggerFactory.getLogger(AirbaseFeature.class);
180         private final String value;
181
182         AirbaseFeature(String value) {
183             this.value = value;
184         }
185
186         public String getValue() {
187             return value;
188         }
189     }
190 }