2 * Copyright (c) 2010-2020 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.volvooncall.internal.dto;
15 import static org.openhab.binding.volvooncall.internal.VolvoOnCallBindingConstants.UNDEFINED;
17 import java.util.List;
18 import java.util.Optional;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.core.library.types.OnOffType;
25 * The {@link Status} is responsible for storing
26 * Door Status informations returned by vehicule status rest answer
28 * @author Gaƫl L'hopital - Initial contribution
31 public class Status extends VocAnswer {
32 public double averageFuelConsumption = UNDEFINED;
33 public int averageSpeed = UNDEFINED;
34 public int fuelAmount = UNDEFINED;
35 public int fuelAmountLevel = UNDEFINED;
36 public int distanceToEmpty = UNDEFINED;
37 public int odometer = UNDEFINED;
38 public int tripMeter1 = UNDEFINED;
39 public int tripMeter2 = UNDEFINED;
41 private @Nullable OnOffType carLocked;
42 private @Nullable OnOffType engineRunning;
43 public String brakeFluid = "";
44 public String washerFluidLevel = "";
45 private @Nullable WindowsStatus windows;
46 private @Nullable DoorsStatus doors;
47 private @Nullable TyrePressure tyrePressure;
48 private @Nullable HvBattery hvBattery;
49 private @Nullable Heater heater;
50 public String serviceWarningStatus = "";
51 private @NonNullByDefault({}) List<Object> bulbFailures;
53 public Optional<WindowsStatus> getWindows() {
54 WindowsStatus windows = this.windows;
55 if (windows != null) {
56 return Optional.of(windows);
58 return Optional.empty();
61 public Optional<DoorsStatus> getDoors() {
62 DoorsStatus doors = this.doors;
64 return Optional.of(doors);
66 return Optional.empty();
69 public Optional<TyrePressure> getTyrePressure() {
70 TyrePressure tyrePressure = this.tyrePressure;
71 if (tyrePressure != null) {
72 return Optional.of(tyrePressure);
74 return Optional.empty();
77 public Optional<HvBattery> getHvBattery() {
78 HvBattery hvBattery = this.hvBattery;
79 if (hvBattery != null) {
80 return Optional.of(hvBattery);
82 return Optional.empty();
85 public Optional<Heater> getHeater() {
86 Heater heater = this.heater;
88 return Optional.of(heater);
90 return Optional.empty();
93 public Optional<OnOffType> getCarLocked() {
94 OnOffType carLocked = this.carLocked;
95 if (carLocked != null) {
96 return Optional.of(carLocked);
98 return Optional.empty();
101 public Optional<OnOffType> getEngineRunning() {
102 OnOffType engineRunning = this.engineRunning;
103 if (engineRunning != null) {
104 return Optional.of(engineRunning);
106 return Optional.empty();
109 public boolean aFailedBulb() {
110 return bulbFailures.size() > 0;
114 * Currently not used in the binding, maybe interesting for the future
116 * @SerializedName("ERS")
117 * private ERSStatus ers;
118 * private ZonedDateTime averageFuelConsumptionTimestamp;
119 * private ZonedDateTime averageSpeedTimestamp;
120 * private ZonedDateTime brakeFluidTimestamp;
121 * private ZonedDateTime bulbFailuresTimestamp;
122 * private ZonedDateTime carLockedTimestamp;
123 * private ZonedDateTime distanceToEmptyTimestamp;
124 * private ZonedDateTime engineRunningTimestamp;
125 * private ZonedDateTime fuelAmountLevelTimestamp;
126 * private ZonedDateTime fuelAmountTimestamp;
127 * private ZonedDateTime odometerTimestamp;
128 * private Boolean privacyPolicyEnabled;
129 * private ZonedDateTime privacyPolicyEnabledTimestamp;
130 * private String remoteClimatizationStatus;
131 * private ZonedDateTime remoteClimatizationStatusTimestamp;
132 * private ZonedDateTime serviceWarningStatusTimestamp;
133 * private Object theftAlarm;
134 * private String timeFullyAccessibleUntil;
135 * private String timePartiallyAccessibleUntil;
136 * private ZonedDateTime tripMeter1Timestamp;
137 * private ZonedDateTime tripMeter2Timestamp;
138 * private ZonedDateTime washerFluidLevelTimestamp;