]> git.basschouten.com Git - openhab-addons.git/blob
17f307e6224cedcab37443a4e9e21ef181a8869c
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 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.volvooncall.internal.dto;
14
15 import static org.openhab.binding.volvooncall.internal.VolvoOnCallBindingConstants.UNDEFINED;
16
17 import java.util.List;
18 import java.util.Optional;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.core.library.types.OnOffType;
23
24 /**
25  * The {@link Status} is responsible for storing
26  * Door Status informations returned by vehicule status rest answer
27  *
28  * @author GaĆ«l L'hopital - Initial contribution
29  */
30 @NonNullByDefault
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;
40
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;
52
53     public Optional<WindowsStatus> getWindows() {
54         WindowsStatus windows = this.windows;
55         if (windows != null) {
56             return Optional.of(windows);
57         }
58         return Optional.empty();
59     }
60
61     public Optional<DoorsStatus> getDoors() {
62         DoorsStatus doors = this.doors;
63         if (doors != null) {
64             return Optional.of(doors);
65         }
66         return Optional.empty();
67     }
68
69     public Optional<TyrePressure> getTyrePressure() {
70         TyrePressure tyrePressure = this.tyrePressure;
71         if (tyrePressure != null) {
72             return Optional.of(tyrePressure);
73         }
74         return Optional.empty();
75     }
76
77     public Optional<HvBattery> getHvBattery() {
78         HvBattery hvBattery = this.hvBattery;
79         if (hvBattery != null) {
80             return Optional.of(hvBattery);
81         }
82         return Optional.empty();
83     }
84
85     public Optional<Heater> getHeater() {
86         Heater heater = this.heater;
87         if (heater != null) {
88             return Optional.of(heater);
89         }
90         return Optional.empty();
91     }
92
93     public Optional<OnOffType> getCarLocked() {
94         OnOffType carLocked = this.carLocked;
95         if (carLocked != null) {
96             return Optional.of(carLocked);
97         }
98         return Optional.empty();
99     }
100
101     public Optional<OnOffType> getEngineRunning() {
102         OnOffType engineRunning = this.engineRunning;
103         if (engineRunning != null) {
104             return Optional.of(engineRunning);
105         }
106         return Optional.empty();
107     }
108
109     public boolean aFailedBulb() {
110         return bulbFailures.size() > 0;
111     }
112
113     /*
114      * Currently not used in the binding, maybe interesting for the future
115      *
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;
139      */
140 }