]> git.basschouten.com Git - openhab-addons.git/blob
fe0f6412ed30189a63b12fecedae95928849e62c
[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.mybmw.internal.dto.vehicle;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.openhab.binding.mybmw.internal.dto.charge.ChargingProfile;
19
20 /**
21  * 
22  * derived from the API responses
23  * 
24  * @author Martin Grassl - initial contribution
25  */
26 public class VehicleState {
27
28     public static final String CHECK_CONTROL_OVERALL_MESSAGE_OK = "No Issues";
29
30     private boolean isLeftSteering = false;
31     private String lastFetched = ""; // 2022-12-21T17:31:26.560Z,
32     private String lastUpdatedAt = ""; // 2022-12-21T15:41:23Z,
33     private boolean isLscSupported = false; // true,
34     private int range = -1; // 435,
35     private VehicleDoorsState doorsState = new VehicleDoorsState();
36     private VehicleWindowsState windowsState = new VehicleWindowsState();
37     private VehicleRoofState roofState = new VehicleRoofState();
38     private VehicleTireStates tireState = new VehicleTireStates();
39
40     private VehicleLocation location = new VehicleLocation();
41     private int currentMileage = -1;
42     private ClimateControlState climateControlState = new ClimateControlState();
43     private List<RequiredService> requiredServices = new ArrayList<>();
44     private List<CheckControlMessage> checkControlMessages = new ArrayList<>();
45     private CombustionFuelLevel combustionFuelLevel = new CombustionFuelLevel();
46     private DriverPreferences driverPreferences = new DriverPreferences();
47     private ElectricChargingState electricChargingState = new ElectricChargingState();
48     private boolean isDeepSleepModeActive = false; // false
49     private List<ClimateTimer> climateTimers = new ArrayList<>();
50     private ChargingProfile chargingProfile = new ChargingProfile();
51
52     /*
53      * (non-Javadoc)
54      * 
55      * @see java.lang.Object#toString()
56      */
57
58     /**
59      * @return the isLeftSteering
60      */
61     public boolean isLeftSteering() {
62         return isLeftSteering;
63     }
64
65     /**
66      * @return the lastFetched
67      */
68     public String getLastFetched() {
69         return lastFetched;
70     }
71
72     /**
73      * @return the lastUpdatedAt
74      */
75     public String getLastUpdatedAt() {
76         return lastUpdatedAt;
77     }
78
79     /**
80      * @return the isLscSupported
81      */
82     public boolean isLscSupported() {
83         return isLscSupported;
84     }
85
86     /**
87      * @return the range
88      */
89     public int getRange() {
90         return range;
91     }
92
93     /**
94      * @return the doorsState
95      */
96     public VehicleDoorsState getDoorsState() {
97         return doorsState;
98     }
99
100     /**
101      * @return the windowsState
102      */
103     public VehicleWindowsState getWindowsState() {
104         return windowsState;
105     }
106
107     /**
108      * @return the roofState
109      */
110     public VehicleRoofState getRoofState() {
111         return roofState;
112     }
113
114     /**
115      * @return the tireState
116      */
117     public VehicleTireStates getTireState() {
118         return tireState;
119     }
120
121     /**
122      * @return the location
123      */
124     public VehicleLocation getLocation() {
125         return location;
126     }
127
128     /**
129      * @return the currentMileage
130      */
131     public int getCurrentMileage() {
132         return currentMileage;
133     }
134
135     /**
136      * @return the climateControlState
137      */
138     public ClimateControlState getClimateControlState() {
139         return climateControlState;
140     }
141
142     /**
143      * @return the requiredServices
144      */
145     public List<RequiredService> getRequiredServices() {
146         return requiredServices;
147     }
148
149     /**
150      * @return the checkControlMessages
151      */
152     public List<CheckControlMessage> getCheckControlMessages() {
153         return checkControlMessages;
154     }
155
156     /**
157      * @return the combustionFuelLevel
158      */
159     public CombustionFuelLevel getCombustionFuelLevel() {
160         return combustionFuelLevel;
161     }
162
163     /**
164      * @return the driverPreferences
165      */
166     public DriverPreferences getDriverPreferences() {
167         return driverPreferences;
168     }
169
170     /**
171      * @return the electricChargingState
172      */
173     public ElectricChargingState getElectricChargingState() {
174         return electricChargingState;
175     }
176
177     /**
178      * @return the isDeepSleepModeActive
179      */
180     public boolean isDeepSleepModeActive() {
181         return isDeepSleepModeActive;
182     }
183
184     /**
185      * @return the climateTimers
186      */
187     public List<ClimateTimer> getClimateTimers() {
188         return climateTimers;
189     }
190
191     /**
192      * @return the chargingProfile
193      */
194     public ChargingProfile getChargingProfile() {
195         return chargingProfile;
196     }
197
198     @Override
199     public String toString() {
200         return "VehicleState [isLeftSteering=" + isLeftSteering + ", lastFetched=" + lastFetched + ", lastUpdatedAt="
201                 + lastUpdatedAt + ", isLscSupported=" + isLscSupported + ", range=" + range + ", doorsState="
202                 + doorsState + ", windowsState=" + windowsState + ", roofState=" + roofState + ", tireState="
203                 + tireState + ", location=" + location + ", currentMileage=" + currentMileage + ", climateControlState="
204                 + climateControlState + ", requiredServices=" + requiredServices + ", checkControlMessages="
205                 + checkControlMessages + ", combustionFuelLevel=" + combustionFuelLevel + ", driverPreferences="
206                 + driverPreferences + ", electricChargingState=" + electricChargingState + ", isDeepSleepModeActive="
207                 + isDeepSleepModeActive + ", climateTimers=" + climateTimers + ", chargingProfile=" + chargingProfile
208                 + "]";
209     }
210
211     /**
212      * helper methods
213      */
214     public String getOverallCheckControlStatus() {
215         StringBuilder overallMessage = new StringBuilder();
216
217         for (CheckControlMessage checkControlMessage : checkControlMessages) {
218             if (checkControlMessage.getId() > 0) {
219                 overallMessage.append(checkControlMessage.getName() + "; ");
220             }
221         }
222
223         String overallMessageString = overallMessage.toString();
224
225         if (overallMessageString.isEmpty()) {
226             overallMessageString = CHECK_CONTROL_OVERALL_MESSAGE_OK;
227         }
228
229         return overallMessageString;
230     }
231 }