2 * Copyright (c) 2010-2021 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.verisure.internal.dto;
15 import static org.openhab.binding.verisure.internal.VerisureBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.thing.ThingTypeUID;
21 import com.google.gson.annotations.SerializedName;
24 * The climate devices of the Verisure System.
26 * @author Jan Gustafsson - Initial contribution
30 public class VerisureClimatesDTO extends VerisureBaseThingDTO {
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;
44 return THING_TYPE_SMOKEDETECTOR;
49 public int hashCode() {
50 return super.hashCode();
54 public boolean equals(@Nullable Object obj) {
58 if (!super.equals(obj)) {
64 if (getClass() != obj.getClass()) {
70 public static class Climate {
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;
81 public Device getDevice() {
85 public boolean isHumidityEnabled() {
86 return humidityEnabled;
89 public @Nullable String getHumidityTimestamp() {
90 return humidityTimestamp;
93 public double getHumidityValue() {
97 public @Nullable String getTemperatureTimestamp() {
98 return temperatureTimestamp;
101 public double getTemperatureValue() {
102 return temperatureValue;
105 public @Nullable String getTypename() {
110 public int hashCode() {
111 final int prime = 31;
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());
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());
130 public boolean equals(@Nullable Object obj) {
137 if (getClass() != obj.getClass()) {
140 Climate other = (Climate) obj;
141 if (!device.equals(other.device)) {
144 if (humidityEnabled != other.humidityEnabled) {
147 String localHumidityTimestamp = humidityTimestamp;
148 if (localHumidityTimestamp == null) {
149 if (other.humidityTimestamp != null) {
152 } else if (!localHumidityTimestamp.equals(other.humidityTimestamp)) {
155 if (Double.doubleToLongBits(humidityValue) != Double.doubleToLongBits(other.humidityValue)) {
158 String localTemperatureTimestamp = temperatureTimestamp;
159 if (localTemperatureTimestamp == null) {
160 if (other.temperatureTimestamp != null) {
163 } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
166 if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
169 String localTypeName = typename;
170 if (localTypeName == null) {
171 if (other.typename != null) {
174 } else if (!localTypeName.equals(other.typename)) {
181 public String toString() {
182 return "Climate [device=" + device + ", humidityEnabled=" + humidityEnabled + ", humidityTimestamp="
183 + humidityTimestamp + ", humidityValue=" + humidityValue + ", temperatureTimestamp="
184 + temperatureTimestamp + ", temperatureValue=" + temperatureValue + ", typename=" + typename + "]";