]> git.basschouten.com Git - openhab-addons.git/blob
3cc5754d74140d9b2ec7ea4adafb54c59b756cca
[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.verisure.internal.dto;
14
15 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.thing.ThingTypeUID;
20
21 import com.google.gson.annotations.SerializedName;
22
23 /**
24  * The climate devices of the Verisure System.
25  *
26  * @author Jan Gustafsson - Initial contribution
27  *
28  */
29 @NonNullByDefault
30 public class VerisureClimatesDTO extends VerisureBaseThingDTO {
31
32     private @Nullable VerisureBatteryStatusDTO batteryStatus;
33
34     public @Nullable VerisureBatteryStatusDTO getBatteryStatus() {
35         return batteryStatus;
36     }
37
38     public void setBatteryStatus(@Nullable VerisureBatteryStatusDTO batteryStatus) {
39         this.batteryStatus = batteryStatus;
40     }
41
42     @Override
43     public ThingTypeUID getThingTypeUID() {
44         String type = getData().getInstallation().getClimates().get(0).getDevice().getGui().getLabel();
45         if ("SMOKE".equals(type)) {
46             return THING_TYPE_SMOKEDETECTOR;
47         } else if ("WATER".equals(type)) {
48             return THING_TYPE_WATERDETECTOR;
49         } else if ("HOMEPAD".equals(type)) {
50             return THING_TYPE_NIGHT_CONTROL;
51         } else if ("SIREN".equals(type)) {
52             return THING_TYPE_SIREN;
53         } else {
54             return THING_TYPE_SMOKEDETECTOR;
55         }
56     }
57
58     @Override
59     public int hashCode() {
60         return super.hashCode();
61     }
62
63     @Override
64     public boolean equals(@Nullable Object obj) {
65         if (this == obj) {
66             return true;
67         }
68         if (!super.equals(obj)) {
69             return false;
70         }
71         if (obj == null) {
72             return false;
73         }
74         if (getClass() != obj.getClass()) {
75             return false;
76         }
77         VerisureClimatesDTO other = (VerisureClimatesDTO) obj;
78         VerisureBatteryStatusDTO localBatteryStatusJSON = batteryStatus;
79         if (localBatteryStatusJSON == null) {
80             if (other.batteryStatus != null) {
81                 return false;
82             }
83         } else if (!localBatteryStatusJSON.equals(other.batteryStatus)) {
84             return false;
85         }
86         return true;
87     }
88
89     public static class Climate {
90
91         private Device device = new Device();
92         private boolean humidityEnabled;
93         private @Nullable String humidityTimestamp;
94         private double humidityValue;
95         private @Nullable String temperatureTimestamp;
96         private double temperatureValue;
97         @SerializedName("__typename")
98         private @Nullable String typename;
99
100         public Device getDevice() {
101             return device;
102         }
103
104         public boolean isHumidityEnabled() {
105             return humidityEnabled;
106         }
107
108         public @Nullable String getHumidityTimestamp() {
109             return humidityTimestamp;
110         }
111
112         public double getHumidityValue() {
113             return humidityValue;
114         }
115
116         public @Nullable String getTemperatureTimestamp() {
117             return temperatureTimestamp;
118         }
119
120         public double getTemperatureValue() {
121             return temperatureValue;
122         }
123
124         public @Nullable String getTypename() {
125             return typename;
126         }
127
128         @Override
129         public int hashCode() {
130             final int prime = 31;
131             int result = 1;
132             result = prime * result + device.hashCode();
133             result = prime * result + (humidityEnabled ? 1231 : 1237);
134             String localHumidityTimestamp = humidityTimestamp;
135             result = prime * result + ((localHumidityTimestamp == null) ? 0 : localHumidityTimestamp.hashCode());
136             long temp;
137             temp = Double.doubleToLongBits(humidityValue);
138             result = prime * result + (int) (temp ^ (temp >>> 32));
139             String localTemperatureTimestamp = temperatureTimestamp;
140             result = prime * result + ((localTemperatureTimestamp == null) ? 0 : localTemperatureTimestamp.hashCode());
141             temp = Double.doubleToLongBits(temperatureValue);
142             result = prime * result + (int) (temp ^ (temp >>> 32));
143             String localTypeName = typename;
144             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
145             return result;
146         }
147
148         @Override
149         public boolean equals(@Nullable Object obj) {
150             if (this == obj) {
151                 return true;
152             }
153             if (obj == null) {
154                 return false;
155             }
156             if (getClass() != obj.getClass()) {
157                 return false;
158             }
159             Climate other = (Climate) obj;
160             if (!device.equals(other.device)) {
161                 return false;
162             }
163             if (humidityEnabled != other.humidityEnabled) {
164                 return false;
165             }
166             String localHumidityTimestamp = humidityTimestamp;
167             if (localHumidityTimestamp == null) {
168                 if (other.humidityTimestamp != null) {
169                     return false;
170                 }
171             } else if (!localHumidityTimestamp.equals(other.humidityTimestamp)) {
172                 return false;
173             }
174             if (Double.doubleToLongBits(humidityValue) != Double.doubleToLongBits(other.humidityValue)) {
175                 return false;
176             }
177             String localTemperatureTimestamp = temperatureTimestamp;
178             if (localTemperatureTimestamp == null) {
179                 if (other.temperatureTimestamp != null) {
180                     return false;
181                 }
182             } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
183                 return false;
184             }
185             if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
186                 return false;
187             }
188             String localTypeName = typename;
189             if (localTypeName == null) {
190                 if (other.typename != null) {
191                     return false;
192                 }
193             } else if (!localTypeName.equals(other.typename)) {
194                 return false;
195             }
196             return true;
197         }
198
199         @Override
200         public String toString() {
201             return "Climate [device=" + device + ", humidityEnabled=" + humidityEnabled + ", humidityTimestamp="
202                     + humidityTimestamp + ", humidityValue=" + humidityValue + ", temperatureTimestamp="
203                     + temperatureTimestamp + ", temperatureValue=" + temperatureValue + ", typename=" + typename + "]";
204         }
205     }
206 }