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.mybmw.internal.dto.vehicle;
15 import java.util.ArrayList;
16 import java.util.List;
18 import org.openhab.binding.mybmw.internal.dto.charge.ChargingProfile;
22 * derived from the API responses
24 * @author Martin Grassl - initial contribution
26 public class VehicleState {
28 public static final String CHECK_CONTROL_OVERALL_MESSAGE_OK = "No Issues";
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();
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();
55 * @see java.lang.Object#toString()
59 * @return the isLeftSteering
61 public boolean isLeftSteering() {
62 return isLeftSteering;
66 * @return the lastFetched
68 public String getLastFetched() {
73 * @return the lastUpdatedAt
75 public String getLastUpdatedAt() {
80 * @return the isLscSupported
82 public boolean isLscSupported() {
83 return isLscSupported;
89 public int getRange() {
94 * @return the doorsState
96 public VehicleDoorsState getDoorsState() {
101 * @return the windowsState
103 public VehicleWindowsState getWindowsState() {
108 * @return the roofState
110 public VehicleRoofState getRoofState() {
115 * @return the tireState
117 public VehicleTireStates getTireState() {
122 * @return the location
124 public VehicleLocation getLocation() {
129 * @return the currentMileage
131 public int getCurrentMileage() {
132 return currentMileage;
136 * @return the climateControlState
138 public ClimateControlState getClimateControlState() {
139 return climateControlState;
143 * @return the requiredServices
145 public List<RequiredService> getRequiredServices() {
146 return requiredServices;
150 * @return the checkControlMessages
152 public List<CheckControlMessage> getCheckControlMessages() {
153 return checkControlMessages;
157 * @return the combustionFuelLevel
159 public CombustionFuelLevel getCombustionFuelLevel() {
160 return combustionFuelLevel;
164 * @return the driverPreferences
166 public DriverPreferences getDriverPreferences() {
167 return driverPreferences;
171 * @return the electricChargingState
173 public ElectricChargingState getElectricChargingState() {
174 return electricChargingState;
178 * @return the isDeepSleepModeActive
180 public boolean isDeepSleepModeActive() {
181 return isDeepSleepModeActive;
185 * @return the climateTimers
187 public List<ClimateTimer> getClimateTimers() {
188 return climateTimers;
192 * @return the chargingProfile
194 public ChargingProfile getChargingProfile() {
195 return chargingProfile;
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
214 public String getOverallCheckControlStatus() {
215 StringBuilder overallMessage = new StringBuilder();
217 for (CheckControlMessage checkControlMessage : checkControlMessages) {
218 if (checkControlMessage.getId() > 0) {
219 overallMessage.append(checkControlMessage.getName() + "; ");
223 String overallMessageString = overallMessage.toString();
225 if (overallMessageString.isEmpty()) {
226 overallMessageString = CHECK_CONTROL_OVERALL_MESSAGE_OK;
229 return overallMessageString;