2 * Copyright (c) 2010-2023 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 {
32 private @Nullable VerisureBatteryStatusDTO batteryStatus;
34 public @Nullable VerisureBatteryStatusDTO getBatteryStatus() {
38 public void setBatteryStatus(@Nullable VerisureBatteryStatusDTO batteryStatus) {
39 this.batteryStatus = batteryStatus;
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;
54 return THING_TYPE_SMOKEDETECTOR;
59 public int hashCode() {
60 return super.hashCode();
64 public boolean equals(@Nullable Object obj) {
68 if (!super.equals(obj)) {
74 if (getClass() != obj.getClass()) {
77 VerisureClimatesDTO other = (VerisureClimatesDTO) obj;
78 VerisureBatteryStatusDTO localBatteryStatusJSON = batteryStatus;
79 if (localBatteryStatusJSON == null) {
80 if (other.batteryStatus != null) {
83 } else if (!localBatteryStatusJSON.equals(other.batteryStatus)) {
89 public static class Climate {
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;
100 public Device getDevice() {
104 public boolean isHumidityEnabled() {
105 return humidityEnabled;
108 public @Nullable String getHumidityTimestamp() {
109 return humidityTimestamp;
112 public double getHumidityValue() {
113 return humidityValue;
116 public @Nullable String getTemperatureTimestamp() {
117 return temperatureTimestamp;
120 public double getTemperatureValue() {
121 return temperatureValue;
124 public @Nullable String getTypename() {
129 public int hashCode() {
130 final int prime = 31;
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());
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());
149 public boolean equals(@Nullable Object obj) {
156 if (getClass() != obj.getClass()) {
159 Climate other = (Climate) obj;
160 if (!device.equals(other.device)) {
163 if (humidityEnabled != other.humidityEnabled) {
166 String localHumidityTimestamp = humidityTimestamp;
167 if (localHumidityTimestamp == null) {
168 if (other.humidityTimestamp != null) {
171 } else if (!localHumidityTimestamp.equals(other.humidityTimestamp)) {
174 if (Double.doubleToLongBits(humidityValue) != Double.doubleToLongBits(other.humidityValue)) {
177 String localTemperatureTimestamp = temperatureTimestamp;
178 if (localTemperatureTimestamp == null) {
179 if (other.temperatureTimestamp != null) {
182 } else if (!localTemperatureTimestamp.equals(other.temperatureTimestamp)) {
185 if (Double.doubleToLongBits(temperatureValue) != Double.doubleToLongBits(other.temperatureValue)) {
188 String localTypeName = typename;
189 if (localTypeName == null) {
190 if (other.typename != null) {
193 } else if (!localTypeName.equals(other.typename)) {
200 public String toString() {
201 return "Climate [device=" + device + ", humidityEnabled=" + humidityEnabled + ", humidityTimestamp="
202 + humidityTimestamp + ", humidityValue=" + humidityValue + ", temperatureTimestamp="
203 + temperatureTimestamp + ", temperatureValue=" + temperatureValue + ", typename=" + typename + "]";