]> git.basschouten.com Git - openhab-addons.git/blob
b21b1d5610729703805f493b875b34683ba3fe49
[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.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     @Override
33     public ThingTypeUID getThingTypeUID() {
34         String type = getData().getInstallation().getClimates().get(0).getDevice().getGui().getLabel();
35         if ("SMOKE".equals(type)) {
36             return THING_TYPE_SMOKEDETECTOR;
37         } else if ("WATER".equals(type)) {
38             return THING_TYPE_WATERDETECTOR;
39         } else if ("HOMEPAD".equals(type)) {
40             return THING_TYPE_NIGHT_CONTROL;
41         } else if ("SIREN".equals(type)) {
42             return THING_TYPE_SIREN;
43         } else {
44             return THING_TYPE_SMOKEDETECTOR;
45         }
46     }
47
48     @Override
49     public int hashCode() {
50         return super.hashCode();
51     }
52
53     @Override
54     public boolean equals(@Nullable Object obj) {
55         if (this == obj) {
56             return true;
57         }
58         if (!super.equals(obj)) {
59             return false;
60         }
61         if (obj == null) {
62             return false;
63         }
64         if (getClass() != obj.getClass()) {
65             return false;
66         }
67         return true;
68     }
69
70     public static class Climate {
71
72         private Device device = new Device();
73         private boolean humidityEnabled;
74         private @Nullable String humidityTimestamp;
75         private double humidityValue;
76         private @Nullable String temperatureTimestamp;
77         private double temperatureValue;
78         @SerializedName("__typename")
79         private @Nullable String typename;
80
81         public Device getDevice() {
82             return device;
83         }
84
85         public boolean isHumidityEnabled() {
86             return humidityEnabled;
87         }
88
89         public @Nullable String getHumidityTimestamp() {
90             return humidityTimestamp;
91         }
92
93         public double getHumidityValue() {
94             return humidityValue;
95         }
96
97         public @Nullable String getTemperatureTimestamp() {
98             return temperatureTimestamp;
99         }
100
101         public double getTemperatureValue() {
102             return temperatureValue;
103         }
104
105         public @Nullable String getTypename() {
106             return typename;
107         }
108
109         @Override
110         public int hashCode() {
111             final int prime = 31;
112             int result = 1;
113             result = prime * result + device.hashCode();
114             result = prime * result + (humidityEnabled ? 1231 : 1237);
115             String localHumidityTimestamp = humidityTimestamp;
116             result = prime * result + ((localHumidityTimestamp == null) ? 0 : localHumidityTimestamp.hashCode());
117             long temp;
118             temp = Double.doubleToLongBits(humidityValue);
119             result = prime * result + (int) (temp ^ (temp >>> 32));
120             String localTemperatureTimestamp = temperatureTimestamp;
121             result = prime * result + ((localTemperatureTimestamp == null) ? 0 : localTemperatureTimestamp.hashCode());
122             temp = Double.doubleToLongBits(temperatureValue);
123             result = prime * result + (int) (temp ^ (temp >>> 32));
124             String localTypeName = typename;
125             result = prime * result + ((localTypeName == null) ? 0 : localTypeName.hashCode());
126             return result;
127         }
128
129         @Override
130         public boolean equals(@Nullable Object obj) {
131             if (this == obj) {
132                 return true;
133             }
134             if (obj == null) {
135                 return false;
136             }
137             if (getClass() != obj.getClass()) {
138                 return false;
139             }
140             Climate other = (Climate) obj;
141             if (!device.equals(other.device)) {
142                 return false;
143             }
144             if (humidityEnabled != other.humidityEnabled) {
145                 return false;
146             }
147             String localHumidityTimestamp = humidityTimestamp;
148             if (localHumidityTimestamp == null) {
149                 if (other.humidityTimestamp != null) {
150                     return false;
151                 }
152             } else if (!localHumidityTimestamp.equals(other.humidityTimestamp)) {
153                 return false;
154             }
155             if (Double.doubleToLongBits(humidityValue) != Double.doubleToLongBits(other.humidityValue)) {
156                 return false;
157             }
158             String localTemperatureTimestamp = temperatureTimestamp;
159             if (localTemperatureTimestamp == null) {
160                 if (other.temperatureTimestamp != null) {
161                     return false;
162                 }
163             } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
164                 return false;
165             }
166             if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
167                 return false;
168             }
169             String localTypeName = typename;
170             if (localTypeName == null) {
171                 if (other.typename != null) {
172                     return false;
173                 }
174             } else if (!localTypeName.equals(other.typename)) {
175                 return false;
176             }
177             return true;
178         }
179
180         @Override
181         public String toString() {
182             return "Climate [device=" + device + ", humidityEnabled=" + humidityEnabled + ", humidityTimestamp="
183                     + humidityTimestamp + ", humidityValue=" + humidityValue + ", temperatureTimestamp="
184                     + temperatureTimestamp + ", temperatureValue=" + temperatureValue + ", typename=" + typename + "]";
185         }
186     }
187 }