From: lsiepel Date: Fri, 24 Feb 2023 15:08:53 +0000 (+0100) Subject: [evohome] Add null annotation and minor refactoring (#13885) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=dd21d92a80345014e43028decbdbca68b7f2fb07;p=openhab-addons.git [evohome] Add null annotation and minor refactoring (#13885) Signed-off-by: Leo Siepel --- diff --git a/bundles/org.openhab.binding.evohome/README.md b/bundles/org.openhab.binding.evohome/README.md index 4df9171563..65744fd222 100644 --- a/bundles/org.openhab.binding.evohome/README.md +++ b/bundles/org.openhab.binding.evohome/README.md @@ -64,11 +64,12 @@ None ### Zone -| Channel Type ID | Item Type | Description | -|-------------------|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| -| Temperature | Number | Allows for viewing the current actual temperature of the zone. | -| SetPointStatus | String | Allows for viewing the current set point mode of the zone. | -| SetPoint | Number | Allows for viewing and permanently overriding the temperature set point of the zone. Sending 0 cancels any active set point overrides. | +| Channel Type ID | Item Type | Description | +|-----------------|--------------------|----------------------------------------------------------------------------------------------------------------------------------------| +| Temperature | Number:Temperature | Allows for viewing the current actual temperature of the zone. | +| SetPointStatus | String | Allows for viewing the current set point mode of the zone. | +| SetPoint | Number:Temperature | Allows for viewing and permanently overriding the temperature set point of the zone. Sending 0 cancels any active set point overrides. | + | ## Full Example @@ -89,9 +90,9 @@ Bridge evohome:account:your_account_alias [ username="your_user_name", password= String DemoMode { channel="evohome:display:your_account_alias:your_display_alias:SystemMode" } // evohome Heatingzone -Number DemoZoneTemperature { channel="evohome:heatingzone:your_account_alias:your_zone_alias:Temperature" } -String DemoZoneSetPointStatus { channel="evohome:heatingzone:your_account_alias:your_zone_alias:SetPointStatus" } -Number DemoZoneSetPoint { channel="evohome:heatingzone:your_account_alias:your_zone_alias:SetPoint" } +Number:Temperature DemoZoneTemperature { channel="evohome:heatingzone:your_account_alias:your_zone_alias:Temperature" } +String DemoZoneSetPointStatus { channel="evohome:heatingzone:your_account_alias:your_zone_alias:SetPointStatus" } +Number:Temperature DemoZoneSetPoint { channel="evohome:heatingzone:your_account_alias:your_zone_alias:SetPoint" } ``` ### demo.sitemap diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/EvohomeBindingConstants.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/EvohomeBindingConstants.java index 2c07a77737..d416730cd5 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/EvohomeBindingConstants.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/EvohomeBindingConstants.java @@ -17,6 +17,7 @@ import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.ThingTypeUID; /** @@ -26,6 +27,7 @@ import org.openhab.core.thing.ThingTypeUID; * @author Jasper van Zuijlen - Initial contribution * @author Neil Renaud - Heating Zones */ +@NonNullByDefault public class EvohomeBindingConstants { private static final String BINDING_ID = "evohome"; diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/RunnableWithTimeout.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/RunnableWithTimeout.java index 0cb741839f..ea7b90a158 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/RunnableWithTimeout.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/RunnableWithTimeout.java @@ -14,12 +14,15 @@ package org.openhab.binding.evohome.internal; import java.util.concurrent.TimeoutException; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Provides an interface for a delegate that can throw a timeout * * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public interface RunnableWithTimeout { public abstract void run() throws TimeoutException; diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/ApiAccess.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/ApiAccess.java index cb2335e747..60c8cbac3e 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/ApiAccess.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/ApiAccess.java @@ -18,13 +18,15 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.client.api.ContentResponse; import org.eclipse.jetty.client.api.Request; import org.eclipse.jetty.client.util.StringContentProvider; import org.eclipse.jetty.http.HttpMethod; import org.eclipse.jetty.http.HttpStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.Authentication; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Authentication; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -37,17 +39,17 @@ import com.google.gson.GsonBuilder; * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class ApiAccess { private static final int REQUEST_TIMEOUT_SECONDS = 5; private final Logger logger = LoggerFactory.getLogger(ApiAccess.class); private final HttpClient httpClient; - private final Gson gson; + private final Gson gson = new GsonBuilder().create(); - private Authentication authenticationData; - private String applicationId; + private @Nullable Authentication authenticationData; + private @Nullable String applicationId; public ApiAccess(HttpClient httpClient) { - this.gson = new GsonBuilder().create(); this.httpClient = httpClient; } @@ -56,7 +58,7 @@ public class ApiAccess { * * @param authentication The authentication details to apply */ - public void setAuthentication(Authentication authentication) { + public void setAuthentication(@Nullable Authentication authentication) { authenticationData = authentication; } @@ -65,7 +67,7 @@ public class ApiAccess { * * @return The current authentication details */ - public Authentication getAuthentication() { + public @Nullable Authentication getAuthentication() { return authenticationData; } @@ -74,7 +76,7 @@ public class ApiAccess { * * @param applicationId The application id to apply */ - public void setApplicationId(String applicationId) { + public void setApplicationId(@Nullable String applicationId) { this.applicationId = applicationId; } @@ -89,18 +91,16 @@ public class ApiAccess { * @return The result of the request or null * @throws TimeoutException Thrown when a request times out */ - public TOut doRequest(HttpMethod method, String url, Map headers, String requestData, - String contentType, Class outClass) throws TimeoutException { - TOut retVal = null; + public @Nullable TOut doRequest(HttpMethod method, String url, Map headers, + @Nullable String requestData, String contentType, @Nullable Class outClass) throws TimeoutException { logger.debug("Requesting: [{}]", url); - + @Nullable + TOut retVal = null; try { Request request = httpClient.newRequest(url).method(method); - if (headers != null) { - for (Map.Entry header : headers.entrySet()) { - request.header(header.getKey(), header.getValue()); - } + for (Map.Entry header : headers.entrySet()) { + request.header(header.getKey(), header.getValue()); } if (requestData != null) { @@ -109,8 +109,8 @@ public class ApiAccess { ContentResponse response = request.timeout(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS).send(); - logger.debug("Response: {}", response); - logger.debug("\n{}\n{}", response.getHeaders(), response.getContentAsString()); + logger.trace("Response: {}", response); + logger.trace("\n{}\n{}", response.getHeaders(), response.getContentAsString()); if ((response.getStatus() == HttpStatus.OK_200) || (response.getStatus() == HttpStatus.ACCEPTED_202)) { String reply = response.getContentAsString(); @@ -118,6 +118,10 @@ public class ApiAccess { if (outClass != null) { retVal = new Gson().fromJson(reply, outClass); } + } else if ((response.getStatus() == HttpStatus.CREATED_201)) { + // success nothing to return ignore + } else { + logger.debug("Request failed with unexpected response code {}", response.getStatus()); } } catch (ExecutionException e) { logger.debug("Error in handling request: ", e); @@ -125,7 +129,6 @@ public class ApiAccess { logger.debug("Handling request interrupted: ", e); Thread.currentThread().interrupt(); } - return retVal; } @@ -138,7 +141,7 @@ public class ApiAccess { * @return The result of the request or null * @throws TimeoutException Thrown when a request times out */ - public TOut doAuthenticatedGet(String url, Class outClass) throws TimeoutException { + public @Nullable TOut doAuthenticatedGet(String url, Class outClass) throws TimeoutException { return doAuthenticatedRequest(HttpMethod.GET, url, null, outClass); } @@ -161,16 +164,16 @@ public class ApiAccess { * @param method The HTTP method to use (POST, GET, ...) * @param url The URL to query * @param headers The optional additional headers to apply, can be null - * @param requestContainer The object to use as JSON data for the request - * @param outClass The type of the requested result + * @param requestContainer The object to use as JSON data for the request, can be null + * @param outClass The type of the requested result, can be null * @return The result of the request or null * @throws TimeoutException Thrown when a request times out */ - private TOut doRequest(HttpMethod method, String url, Map headers, Object requestContainer, - Class outClass) throws TimeoutException { + private @Nullable TOut doRequest(HttpMethod method, String url, Map headers, + @Nullable Object requestContainer, @Nullable Class outClass) throws TimeoutException { String json = null; if (requestContainer != null) { - json = this.gson.toJson(requestContainer); + json = gson.toJson(requestContainer); } return doRequest(method, url, headers, json, "application/json", outClass); @@ -188,17 +191,19 @@ public class ApiAccess { * @return The result of the request or null * @throws TimeoutException Thrown when a request times out */ - private TOut doAuthenticatedRequest(HttpMethod method, String url, Object requestContainer, - Class outClass) throws TimeoutException { - Map headers = null; - if (authenticationData != null) { - headers = new HashMap<>(); - - headers.put("Authorization", "Bearer " + authenticationData.getAccessToken()); - headers.put("applicationId", applicationId); - headers.put("Accept", - "application/json, application/xml, text/json, text/x-json, text/javascript, text/xml"); + private @Nullable TOut doAuthenticatedRequest(HttpMethod method, String url, + @Nullable Object requestContainer, @Nullable Class outClass) throws TimeoutException { + Map headers = new HashMap<>(); + Authentication localAuthenticationData = authenticationData; + String localApplicationId = applicationId; + + if (localAuthenticationData != null) { + headers.put("Authorization", "Bearer " + localAuthenticationData.getAccessToken()); + } + if (localApplicationId != null) { + headers.put("applicationId", localApplicationId); } + headers.put("Accept", "application/json, application/xml, text/json, text/x-json, text/javascript, text/xml"); return doRequest(method, url, headers, requestContainer, outClass); } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClient.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClient.java index 477d68a794..eaceccf87a 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClient.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClient.java @@ -19,18 +19,20 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeoutException; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jetty.client.HttpClient; import org.eclipse.jetty.http.HttpMethod; -import org.openhab.binding.evohome.internal.api.models.v2.request.HeatSetPoint; -import org.openhab.binding.evohome.internal.api.models.v2.request.HeatSetPointBuilder; -import org.openhab.binding.evohome.internal.api.models.v2.request.Mode; -import org.openhab.binding.evohome.internal.api.models.v2.request.ModeBuilder; -import org.openhab.binding.evohome.internal.api.models.v2.response.Authentication; -import org.openhab.binding.evohome.internal.api.models.v2.response.Location; -import org.openhab.binding.evohome.internal.api.models.v2.response.LocationStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.Locations; -import org.openhab.binding.evohome.internal.api.models.v2.response.LocationsStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.UserAccount; +import org.openhab.binding.evohome.internal.api.models.v2.dto.request.HeatSetPoint; +import org.openhab.binding.evohome.internal.api.models.v2.dto.request.HeatSetPointBuilder; +import org.openhab.binding.evohome.internal.api.models.v2.dto.request.Mode; +import org.openhab.binding.evohome.internal.api.models.v2.dto.request.ModeBuilder; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Authentication; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Location; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.LocationStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Locations; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.LocationsStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.UserAccount; import org.openhab.binding.evohome.internal.configuration.EvohomeAccountConfiguration; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -41,6 +43,7 @@ import org.slf4j.LoggerFactory; * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeApiClient { private static final String APPLICATION_ID = "b013aa26-9724-4dbd-8897-048b9aada249"; @@ -52,8 +55,8 @@ public class EvohomeApiClient { private final ApiAccess apiAccess; private Locations locations = new Locations(); - private UserAccount useraccount; - private LocationsStatus locationsStatus; + private @Nullable UserAccount useraccount; + private @Nullable LocationsStatus locationsStatus; /** * Creates a new API client based on the V2 API interface @@ -72,7 +75,7 @@ public class EvohomeApiClient { public void close() { apiAccess.setAuthentication(null); useraccount = null; - locations = null; + locations = new Locations(); locationsStatus = null; } @@ -113,7 +116,7 @@ public class EvohomeApiClient { return locations; } - public LocationsStatus getInstallationStatus() { + public @Nullable LocationsStatus getInstallationStatus() { return locationsStatus; } @@ -139,33 +142,33 @@ public class EvohomeApiClient { apiAccess.doAuthenticatedPut(url, heatSetPoint); } - private UserAccount requestUserAccount() throws TimeoutException { + private @Nullable UserAccount requestUserAccount() throws TimeoutException { String url = EvohomeApiConstants.URL_V2_BASE + EvohomeApiConstants.URL_V2_ACCOUNT; return apiAccess.doAuthenticatedGet(url, UserAccount.class); } private Locations requestLocations() throws TimeoutException { - Locations locations = new Locations(); - if (useraccount != null) { + Locations locations = null; + UserAccount localAccount = useraccount; + if (localAccount != null) { String url = EvohomeApiConstants.URL_V2_BASE + EvohomeApiConstants.URL_V2_INSTALLATION_INFO; - url = String.format(url, useraccount.getUserId()); + url = String.format(url, localAccount.getUserId()); locations = apiAccess.doAuthenticatedGet(url, Locations.class); } - return locations; + return locations != null ? locations : new Locations(); } private LocationsStatus requestLocationsStatus() throws TimeoutException { LocationsStatus locationsStatus = new LocationsStatus(); - if (locations != null) { - for (Location location : locations) { - String url = EvohomeApiConstants.URL_V2_BASE + EvohomeApiConstants.URL_V2_LOCATION_STATUS; - url = String.format(url, location.getLocationInfo().getLocationId()); - LocationStatus status = apiAccess.doAuthenticatedGet(url, LocationStatus.class); - locationsStatus.add(status); - } + for (Location location : locations) { + String url = EvohomeApiConstants.URL_V2_BASE + EvohomeApiConstants.URL_V2_LOCATION_STATUS; + url = String.format(url, location.getLocationInfo().getLocationId()); + LocationStatus status = apiAccess.doAuthenticatedGet(url, LocationStatus.class); + locationsStatus.add(status); } + return locationsStatus; } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClientException.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClientException.java index a622e00c16..850879f8aa 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClientException.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiClientException.java @@ -12,13 +12,17 @@ */ package org.openhab.binding.evohome.internal.api; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Exception for errors from the API Client. * * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeApiClientException extends Exception { + private static final long serialVersionUID = 1L; public EvohomeApiClientException() { } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiConstants.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiConstants.java index c0237c7e71..d35e3cd82a 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiConstants.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/EvohomeApiConstants.java @@ -12,12 +12,15 @@ */ package org.openhab.binding.evohome.internal.api; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * List of evohome API constants * * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeApiConstants { public static final String URL_V2_AUTH = "https://tccna.honeywell.com/Auth/OAuth/Token"; diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/HeatSetPoint.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/HeatSetPoint.java new file mode 100644 index 0000000000..7a4168c08f --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/HeatSetPoint.java @@ -0,0 +1,57 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.request; + +import com.google.gson.annotations.SerializedName; + +/** + * Request model for the mode + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class HeatSetPoint { + + /** + * Constructs an override reset + */ + HeatSetPoint() { + heatSetpointValue = 0.0; + setpointMode = "FollowSchedule"; + timeUntil = null; + } + + /** + * Constructs a permanent override with the given temperature + * + * @param setPoint The target temperature to set the set point to + */ + HeatSetPoint(double setPoint) { + // Make sure that the value is rounded toward the nearest 0.5 + heatSetpointValue = Math.round(setPoint * 2) / 2.0; + setpointMode = "PermanentOverride"; + timeUntil = null; + } + + @SuppressWarnings("unused") + @SerializedName("heatSetpointValue") + private double heatSetpointValue; + + @SuppressWarnings("unused") + @SerializedName("setpointMode") + private String setpointMode; + + @SuppressWarnings("unused") + @SerializedName("timeUntil") + private String timeUntil; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/HeatSetPointBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/HeatSetPointBuilder.java new file mode 100644 index 0000000000..5eb458f2d7 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/HeatSetPointBuilder.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.request; + +/** + * Builder for heat set point API requests + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class HeatSetPointBuilder implements RequestBuilder { + + private double setPoint; + private boolean hasSetPoint; + private boolean cancelSetPoint; + + /** + * Creates a new heat set point command + * + * @return A heat set point command or null when the configuration is invalid + * + */ + @Override + public HeatSetPoint build() { + if (cancelSetPoint) { + return new HeatSetPoint(); + } + if (hasSetPoint) { + return new HeatSetPoint(setPoint); + } + return null; + } + + public HeatSetPointBuilder setSetPoint(double setPoint) { + this.hasSetPoint = true; + this.setPoint = setPoint; + return this; + } + + public HeatSetPointBuilder setCancelSetPoint() { + cancelSetPoint = true; + return this; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/Mode.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/Mode.java new file mode 100644 index 0000000000..125147f989 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/Mode.java @@ -0,0 +1,48 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.request; + +import com.google.gson.annotations.SerializedName; + +/** + * Request model for the mode + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class Mode { + + Mode(String mode) { + systemMode = mode; + timeUntil = null; + permanent = true; + } + + Mode(String mode, int day, int month, int year) { + systemMode = mode; + timeUntil = String.format("%s-%s-%sT00:00:00Z", year, month, day); + permanent = false; + } + + @SuppressWarnings("unused") + @SerializedName("systemMode") + private String systemMode; + + @SuppressWarnings("unused") + @SerializedName("timeUntil") + private String timeUntil; + + @SuppressWarnings("unused") + @SerializedName("permanent") + private boolean permanent; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/ModeBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/ModeBuilder.java new file mode 100644 index 0000000000..92bee418c7 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/ModeBuilder.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.request; + +/** + * Builder for mode API requests + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class ModeBuilder extends TimedRequestBuilder { + + private String mode; + private boolean hasSetMode; + + /** + * Creates a new mode command + * + * @return A mode command or null when the configuration is invalid + * + */ + @Override + public Mode build() { + if (hasSetMode) { + if (useEndTime()) { + return new Mode(mode, getYear(), getMonth(), getDay()); + } else { + return new Mode(mode); + } + } + return null; + } + + public ModeBuilder setMode(String mode) { + this.hasSetMode = true; + this.mode = mode; + return this; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/RequestBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/RequestBuilder.java new file mode 100644 index 0000000000..048b3ae9e7 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/RequestBuilder.java @@ -0,0 +1,24 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.request; + +/** + * Builder for API requests + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public interface RequestBuilder { + + public T build(); +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/TimedRequestBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/TimedRequestBuilder.java new file mode 100644 index 0000000000..829ea946e3 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/request/TimedRequestBuilder.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.request; + +/** + * Builder for timed API requests + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public abstract class TimedRequestBuilder implements RequestBuilder { + private boolean useEndTime; + private int year; + private int month; + private int day; + + public RequestBuilder withEndTime(int year, int month, int day) { + this.useEndTime = true; + this.year = year; + this.month = month; + this.day = day; + return this; + } + + protected boolean useEndTime() { + return useEndTime; + } + + protected int getYear() { + return year; + } + + protected int getMonth() { + return month; + } + + protected int getDay() { + return day; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ActiveFault.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ActiveFault.java new file mode 100644 index 0000000000..790054d75f --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ActiveFault.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the active fault + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class ActiveFault { + + @SerializedName("faultType") + private String faultType; + + @SerializedName("since") + private String since; + + public String getFaultType() { + return faultType; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Authentication.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Authentication.java new file mode 100644 index 0000000000..ac90b23b62 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Authentication.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the authentication + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class Authentication { + + @SerializedName("access_token") + private String accessToken; + + @SerializedName("token_type") + private String tokenType; + + @SerializedName("expires_in") + private int expiresIn; + + @SerializedName("refresh_token") + private String refreshToken; + + @SerializedName("scope") + private String scope; + + /** Convenience variable for current system time in seconds */ + private long systemTime; + + public String getAccessToken() { + return accessToken; + } + + public int getExpiresIn() { + return expiresIn; + } + + public String getRefreshToken() { + return refreshToken; + } + + public void setSystemTime(long systemTime) { + this.systemTime = systemTime; + } + + public long getSystemTime() { + return systemTime; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Gateway.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Gateway.java new file mode 100644 index 0000000000..154d85562f --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Gateway.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the gateway + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class Gateway { + + @SerializedName("gatewayInfo") + private GatewayInfo gatewayInfo; + + @SerializedName("temperatureControlSystems") + private List temperatureControlSystems; + + public GatewayInfo getGatewayInfo() { + return gatewayInfo; + } + + public List getTemperatureControlSystems() { + return temperatureControlSystems; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/GatewayInfo.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/GatewayInfo.java new file mode 100644 index 0000000000..c6a572a910 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/GatewayInfo.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the gateway info + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class GatewayInfo { + + @SerializedName("gatewayId") + private String gatewayId; + + @SerializedName("mac") + private String macAddress; + + @SerializedName("crc") + private String crc; + + @SerializedName("isWiFi") + private boolean isWifi; + + public String getGatewayId() { + return gatewayId; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/GatewayStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/GatewayStatus.java new file mode 100644 index 0000000000..0a91eb58ff --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/GatewayStatus.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the gateway status + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class GatewayStatus { + + @SerializedName("gatewayId") + private String gatewayId; + + @SerializedName("temperatureControlSystems") + private List temperatureControlSystems; + + @SerializedName("activeFaults") + private List activeFaults; + + public List getTemperatureControlSystems() { + return temperatureControlSystems; + } + + public boolean hasActiveFaults() { + return !activeFaults.isEmpty(); + } + + public ActiveFault getActiveFault(int index) { + return activeFaults.get(index); + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/HeatSetpointCapabilities.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/HeatSetpointCapabilities.java new file mode 100644 index 0000000000..ffc222a920 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/HeatSetpointCapabilities.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the heat set point capabilities + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class HeatSetpointCapabilities { + + @SerializedName("maxHeatSetpoint") + private double maxHeatSetpoint; + + @SerializedName("minHeatSetpoint") + private double minHeatSetpoint; + + @SerializedName("valueResolution") + private double valueResolution; + + @SerializedName("allowedSetpointModes") + private List allowedSetpointModes; + + @SerializedName("maxDuration") + private String maxDuration; + + @SerializedName("timingResolution") + private String timingResolution; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/HeatSetpointStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/HeatSetpointStatus.java new file mode 100644 index 0000000000..924b407bc8 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/HeatSetpointStatus.java @@ -0,0 +1,38 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the heat setpoint status + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class HeatSetpointStatus { + + @SerializedName("targetHeatTemperature") + private double targetTemperature; + + @SerializedName("setpointMode") + private String setpointMode; + + public double getTargetTemperature() { + return targetTemperature; + } + + public String getSetpointMode() { + return setpointMode; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Location.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Location.java new file mode 100644 index 0000000000..6a7d978077 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Location.java @@ -0,0 +1,40 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the location + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class Location { + + @SerializedName("locationInfo") + private LocationInfo locationInfo; + + @SerializedName("gateways") + private List gateways; + + public LocationInfo getLocationInfo() { + return locationInfo; + } + + public List getGateways() { + return gateways; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationInfo.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationInfo.java new file mode 100644 index 0000000000..66575c742a --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationInfo.java @@ -0,0 +1,62 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the location info + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class LocationInfo { + + @SerializedName("locationId") + private String locationId; + + @SerializedName("name") + private String name; + + @SerializedName("streetAddress") + private String streetAddress; + + @SerializedName("city") + private String city; + + @SerializedName("country") + private String country; + + @SerializedName("postcode") + private String postcode; + + @SerializedName("locationType") + private String locationType; + + @SerializedName("useDaylightSaveSwitching") + private boolean useDaylightSaveSwitching; + + @SerializedName("timeZone") + private TimeZone timeZone; + + @SerializedName("locationOwner") + private LocationOwner locationOwner; + + public String getLocationId() { + return locationId; + } + + public String getName() { + return name; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationOwner.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationOwner.java new file mode 100644 index 0000000000..1952f43923 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationOwner.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the location owner + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class LocationOwner { + + @SerializedName("userId") + private int userId; + + @SerializedName("username") + private String username; + + @SerializedName("firstname") + private String firstName; + + @SerializedName("lastname") + private String lastName; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationStatus.java new file mode 100644 index 0000000000..22caadc843 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationStatus.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.ArrayList; +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the location status + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class LocationStatus { + + @SerializedName("locationId") + private String locationId; + + @SerializedName("gateways") + private List gateways; + + public LocationStatus() { + locationId = ""; + gateways = new ArrayList<>(); + } + + public List getGateways() { + return gateways; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Locations.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Locations.java new file mode 100644 index 0000000000..f0a18bc73a --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Locations.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.ArrayList; + +/** + * Alias for a list of locations + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class Locations extends ArrayList { + private static final long serialVersionUID = 1L; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationsStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationsStatus.java new file mode 100644 index 0000000000..a40bcb3e54 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/LocationsStatus.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.ArrayList; + +/** + * Alias for a list of location statuses + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class LocationsStatus extends ArrayList { + private static final long serialVersionUID = 1L; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Mode.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Mode.java new file mode 100644 index 0000000000..cd09112308 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Mode.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the mode + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class Mode { + + @SerializedName("systemMode") + private String systemMode; + + @SerializedName("canBePermanent") + private boolean canBePermanent; + + @SerializedName("canBeTemporary") + private boolean canBeTemporary; + + @SerializedName("timingMode") + private String timingMode; + + @SerializedName("maxDuration") + private String maxDuration; + + @SerializedName("timingResolution") + private String timingResolution; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ScheduleCapabilities.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ScheduleCapabilities.java new file mode 100644 index 0000000000..9e86e512c6 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ScheduleCapabilities.java @@ -0,0 +1,36 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the schedule capabilities + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class ScheduleCapabilities { + + @SerializedName("maxSwitchpointsPerDay") + private int maxSwitchpointsPerDay; + + @SerializedName("minSwitchpointsPerDay") + private int minSwitchpointsPerDay; + + @SerializedName("setpointValueResolution") + private double setpointValueResolution; + + @SerializedName("timingResolution") + private String timingResolution; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/SystemModeStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/SystemModeStatus.java new file mode 100644 index 0000000000..93e7958207 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/SystemModeStatus.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the system mode status + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class SystemModeStatus { + + @SerializedName("mode") + private String mode; + + @SerializedName("isPermanent") + private boolean isPermanent; + + public String getMode() { + return mode; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureControlSystem.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureControlSystem.java new file mode 100644 index 0000000000..3eecdfcf28 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureControlSystem.java @@ -0,0 +1,46 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the temperature control system + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class TemperatureControlSystem { + + @SerializedName("systemId") + private String systemId; + + @SerializedName("modelType") + private String modelType; + + @SerializedName("zones") + private List zones; + + @SerializedName("allowedSystemModes") + private List allowedSystemModes; + + public String getSystemId() { + return systemId; + } + + public List getZones() { + return zones; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureControlSystemStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureControlSystemStatus.java new file mode 100644 index 0000000000..555e7bdf70 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureControlSystemStatus.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the temperature control system status + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class TemperatureControlSystemStatus { + + @SerializedName("systemId") + private String systemId; + + @SerializedName("systemModeStatus") + private SystemModeStatus mode; + + @SerializedName("zones") + private List zones; + + @SerializedName("activeFaults") + private List activeFaults; + + public String getSystemId() { + return systemId; + } + + public SystemModeStatus getMode() { + return mode; + } + + public List getZones() { + return zones; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureStatus.java new file mode 100644 index 0000000000..c064c1b4ef --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TemperatureStatus.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the temperature status + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class TemperatureStatus { + + @SerializedName("temperature") + private double temperature; + + @SerializedName("isAvailable") + private boolean isAvailable; + + public double getTemperature() { + return temperature; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TimeZone.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TimeZone.java new file mode 100644 index 0000000000..e91f5275d4 --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/TimeZone.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the time zone + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class TimeZone { + + @SerializedName("timeZoneId") + private String timeZoneId; + + @SerializedName("displayName") + private String displayName; + + @SerializedName("offsetMinutes") + private int offsetMinutes; + + @SerializedName("currentOffsetMinutes") + private int currentOffsetMinutes; + + @SerializedName("supportsDaylightSaving") + private boolean supportsDaylightSaving; +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/UserAccount.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/UserAccount.java new file mode 100644 index 0000000000..386638bb9f --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/UserAccount.java @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the user account + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class UserAccount { + + @SerializedName("userId") + private String userId; + + @SerializedName("username") + private String userName; + + @SerializedName("firstname") + private String firstName; + + @SerializedName("lastname") + private String lastName; + + @SerializedName("streetAddress") + private String streetAddress; + + @SerializedName("city") + private String city; + + @SerializedName("postcode") + private String postCode; + + @SerializedName("country") + private String country; + + @SerializedName("language") + private String language; + + public String getUserId() { + return userId; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Zone.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Zone.java new file mode 100644 index 0000000000..933fd9a88d --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/Zone.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for the zone + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class Zone { + + @SerializedName("zoneId") + private String zoneId; + + @SerializedName("modelType") + private String modelType; + + @SerializedName("name") + private String name; + + @SerializedName("zoneType") + private String zoneType; + + @SerializedName("heatSetpointCapabilities") + private HeatSetpointCapabilities heatSetpointCapabilities; + + @SerializedName("scheduleCapabilities") + private ScheduleCapabilities scheduleCapabilities; + + public String getZoneId() { + return zoneId; + } + + public String getName() { + return name; + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ZoneStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ZoneStatus.java new file mode 100644 index 0000000000..053bc11bba --- /dev/null +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/dto/response/ZoneStatus.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2010-2023 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.evohome.internal.api.models.v2.dto.response; + +import java.util.List; + +import com.google.gson.annotations.SerializedName; + +/** + * Response model for zone status + * + * @author Jasper van Zuijlen - Initial contribution + * + */ +public class ZoneStatus { + + @SerializedName("zoneId") + private String zoneId; + + @SerializedName("name") + private String name; + + @SerializedName("temperatureStatus") + private TemperatureStatus temperature; + + @SerializedName("setpointStatus") + private HeatSetpointStatus heatSetpoint; + + @SerializedName("activeFaults") + private List activeFaults; + + public String getZoneId() { + return zoneId; + } + + public TemperatureStatus getTemperature() { + return temperature; + } + + public HeatSetpointStatus getHeatSetpoint() { + return heatSetpoint; + } + + public boolean hasActiveFaults() { + return !activeFaults.isEmpty(); + } + + public ActiveFault getActiveFault(int index) { + return activeFaults.get(index); + } +} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/HeatSetPoint.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/HeatSetPoint.java deleted file mode 100644 index 127841b80a..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/HeatSetPoint.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.request; - -import com.google.gson.annotations.SerializedName; - -/** - * Request model for the mode - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class HeatSetPoint { - - /** - * Constructs an override reset - */ - HeatSetPoint() { - heatSetpointValue = 0.0; - setpointMode = "FollowSchedule"; - timeUntil = null; - } - - /** - * Constructs a permanent override with the given temperature - * - * @param setPoint The target temperature to set the set point to - */ - HeatSetPoint(double setPoint) { - // Make sure that the value is rounded toward the nearest 0.5 - heatSetpointValue = Math.round(setPoint * 2) / 2.0; - setpointMode = "PermanentOverride"; - timeUntil = null; - } - - @SerializedName("heatSetpointValue") - private double heatSetpointValue; - - @SerializedName("setpointMode") - private String setpointMode; - - @SerializedName("timeUntil") - private String timeUntil; -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/HeatSetPointBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/HeatSetPointBuilder.java deleted file mode 100644 index abc90ed782..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/HeatSetPointBuilder.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.request; - -/** - * Builder for heat set point API requests - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class HeatSetPointBuilder implements RequestBuilder { - - private double setPoint; - private boolean hasSetPoint; - private boolean cancelSetPoint; - - /** - * Creates a new heat set point command - * - * @return A heat set point command or null when the configuration is invalid - * - */ - @Override - public HeatSetPoint build() { - if (cancelSetPoint) { - return new HeatSetPoint(); - } - if (hasSetPoint) { - return new HeatSetPoint(setPoint); - } - return null; - } - - public HeatSetPointBuilder setSetPoint(double setPoint) { - this.hasSetPoint = true; - this.setPoint = setPoint; - return this; - } - - public HeatSetPointBuilder setCancelSetPoint() { - cancelSetPoint = true; - return this; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/Mode.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/Mode.java deleted file mode 100644 index 0a58be085e..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/Mode.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.request; - -import com.google.gson.annotations.SerializedName; - -/** - * Request model for the mode - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class Mode { - - Mode(String mode) { - systemMode = mode; - timeUntil = null; - permanent = true; - } - - Mode(String mode, int day, int month, int year) { - systemMode = mode; - timeUntil = String.format("%s-%s-%sT00:00:00Z", year, month, day); - permanent = false; - } - - @SerializedName("systemMode") - private String systemMode; - - @SerializedName("timeUntil") - private String timeUntil; - - @SerializedName("permanent") - private boolean permanent; -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/ModeBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/ModeBuilder.java deleted file mode 100644 index d6821b6985..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/ModeBuilder.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.request; - -/** - * Builder for mode API requests - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class ModeBuilder extends TimedRequestBuilder { - - private String mode; - private boolean hasSetMode; - - /** - * Creates a new mode command - * - * @return A mode command or null when the configuration is invalid - * - */ - @Override - public Mode build() { - if (hasSetMode) { - if (useEndTime()) { - return new Mode(mode, getYear(), getMonth(), getDay()); - } else { - return new Mode(mode); - } - } - return null; - } - - public ModeBuilder setMode(String mode) { - this.hasSetMode = true; - this.mode = mode; - return this; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/RequestBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/RequestBuilder.java deleted file mode 100644 index 301c4b855c..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/RequestBuilder.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.request; - -/** - * Builder for API requests - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public interface RequestBuilder { - - public T build(); -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/TimedRequestBuilder.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/TimedRequestBuilder.java deleted file mode 100644 index 8b6fa67551..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/request/TimedRequestBuilder.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.request; - -/** - * Builder for timed API requests - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public abstract class TimedRequestBuilder implements RequestBuilder { - private boolean useEndTime; - private int year; - private int month; - private int day; - - public RequestBuilder withEndTime(int year, int month, int day) { - this.useEndTime = true; - this.year = year; - this.month = month; - this.day = day; - return this; - } - - protected boolean useEndTime() { - return useEndTime; - } - - protected int getYear() { - return year; - } - - protected int getMonth() { - return month; - } - - protected int getDay() { - return day; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ActiveFault.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ActiveFault.java deleted file mode 100644 index ef9ede0cd2..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ActiveFault.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the active fault - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class ActiveFault { - - @SerializedName("faultType") - private String faultType; - - @SerializedName("since") - private String since; - - public String getFaultType() { - return faultType; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Authentication.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Authentication.java deleted file mode 100644 index e91e6c39c1..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Authentication.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the authentication - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class Authentication { - - @SerializedName("access_token") - private String accessToken; - - @SerializedName("token_type") - private String tokenType; - - @SerializedName("expires_in") - private int expiresIn; - - @SerializedName("refresh_token") - private String refreshToken; - - @SerializedName("scope") - private String scope; - - /** Convenience variable for current system time in seconds */ - private long systemTime; - - public String getAccessToken() { - return accessToken; - } - - public int getExpiresIn() { - return expiresIn; - } - - public String getRefreshToken() { - return refreshToken; - } - - public void setSystemTime(long systemTime) { - this.systemTime = systemTime; - } - - public long getSystemTime() { - return systemTime; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Gateway.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Gateway.java deleted file mode 100644 index 057053a716..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Gateway.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the gateway - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class Gateway { - - @SerializedName("gatewayInfo") - private GatewayInfo gatewayInfo; - - @SerializedName("temperatureControlSystems") - private List temperatureControlSystems; - - public GatewayInfo getGatewayInfo() { - return gatewayInfo; - } - - public List getTemperatureControlSystems() { - return temperatureControlSystems; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/GatewayInfo.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/GatewayInfo.java deleted file mode 100644 index 586afae161..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/GatewayInfo.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the gateway info - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class GatewayInfo { - - @SerializedName("gatewayId") - private String gatewayId; - - @SerializedName("mac") - private String macAddress; - - @SerializedName("crc") - private String crc; - - @SerializedName("isWiFi") - private boolean isWifi; - - public String getGatewayId() { - return gatewayId; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/GatewayStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/GatewayStatus.java deleted file mode 100644 index 1e57385cf3..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/GatewayStatus.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the gateway status - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class GatewayStatus { - - @SerializedName("gatewayId") - private String gatewayId; - - @SerializedName("temperatureControlSystems") - private List temperatureControlSystems; - - @SerializedName("activeFaults") - private List activeFaults; - - public List getTemperatureControlSystems() { - return temperatureControlSystems; - } - - public boolean hasActiveFaults() { - return !activeFaults.isEmpty(); - } - - public ActiveFault getActiveFault(int index) { - return activeFaults.get(index); - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/HeatSetpointCapabilities.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/HeatSetpointCapabilities.java deleted file mode 100644 index 83247db6e9..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/HeatSetpointCapabilities.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the heat set point capabilities - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class HeatSetpointCapabilities { - - @SerializedName("maxHeatSetpoint") - private double maxHeatSetpoint; - - @SerializedName("minHeatSetpoint") - private double minHeatSetpoint; - - @SerializedName("valueResolution") - private double valueResolution; - - @SerializedName("allowedSetpointModes") - private List allowedSetpointModes; - - @SerializedName("maxDuration") - private String maxDuration; - - @SerializedName("timingResolution") - private String timingResolution; -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/HeatSetpointStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/HeatSetpointStatus.java deleted file mode 100644 index 99114ea9ea..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/HeatSetpointStatus.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the heat setpoint status - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class HeatSetpointStatus { - - @SerializedName("targetHeatTemperature") - private double targetTemperature; - - @SerializedName("setpointMode") - private String setpointMode; - - public double getTargetTemperature() { - return targetTemperature; - } - - public String getSetpointMode() { - return setpointMode; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Location.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Location.java deleted file mode 100644 index 20dbeb9d1b..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Location.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the location - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class Location { - - @SerializedName("locationInfo") - private LocationInfo locationInfo; - - @SerializedName("gateways") - private List gateways; - - public LocationInfo getLocationInfo() { - return locationInfo; - } - - public List getGateways() { - return gateways; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationInfo.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationInfo.java deleted file mode 100644 index 40b81c11a8..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationInfo.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the location info - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class LocationInfo { - - @SerializedName("locationId") - private String locationId; - - @SerializedName("name") - private String name; - - @SerializedName("streetAddress") - private String streetAddress; - - @SerializedName("city") - private String city; - - @SerializedName("country") - private String country; - - @SerializedName("postcode") - private String postcode; - - @SerializedName("locationType") - private String locationType; - - @SerializedName("useDaylightSaveSwitching") - private boolean useDaylightSaveSwitching; - - @SerializedName("timeZone") - private TimeZone timeZone; - - @SerializedName("locationOwner") - private LocationOwner locationOwner; - - public String getLocationId() { - return locationId; - } - - public String getName() { - return name; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationOwner.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationOwner.java deleted file mode 100644 index 286848a829..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationOwner.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the location owner - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class LocationOwner { - - @SerializedName("userId") - private int userId; - - @SerializedName("username") - private String username; - - @SerializedName("firstname") - private String firstName; - - @SerializedName("lastname") - private String lastName; -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationStatus.java deleted file mode 100644 index 3446023048..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationStatus.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.ArrayList; -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the location status - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class LocationStatus { - - @SerializedName("locationId") - private String locationId; - - @SerializedName("gateways") - private List gateways; - - public LocationStatus() { - locationId = ""; - gateways = new ArrayList<>(); - } - - public List getGateways() { - return gateways; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Locations.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Locations.java deleted file mode 100644 index d0864b4078..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Locations.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.ArrayList; - -/** - * Alias for a list of locations - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class Locations extends ArrayList { - -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationsStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationsStatus.java deleted file mode 100644 index 3b6956457e..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/LocationsStatus.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.ArrayList; - -/** - * Alias for a list of location statuses - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class LocationsStatus extends ArrayList { - -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Mode.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Mode.java deleted file mode 100644 index 707b416347..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Mode.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the mode - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class Mode { - - @SerializedName("systemMode") - private String systemMode; - - @SerializedName("canBePermanent") - private boolean canBePermanent; - - @SerializedName("canBeTemporary") - private boolean canBeTemporary; - - @SerializedName("timingMode") - private String timingMode; - - @SerializedName("maxDuration") - private String maxDuration; - - @SerializedName("timingResolution") - private String timingResolution; -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ScheduleCapabilities.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ScheduleCapabilities.java deleted file mode 100644 index e1aec29b8c..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ScheduleCapabilities.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the schedule capabilities - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class ScheduleCapabilities { - - @SerializedName("maxSwitchpointsPerDay") - private int maxSwitchpointsPerDay; - - @SerializedName("minSwitchpointsPerDay") - private int minSwitchpointsPerDay; - - @SerializedName("setpointValueResolution") - private double setpointValueResolution; - - @SerializedName("timingResolution") - private String timingResolution; -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/SystemModeStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/SystemModeStatus.java deleted file mode 100644 index ce2af909ea..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/SystemModeStatus.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the system mode status - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class SystemModeStatus { - - @SerializedName("mode") - private String mode; - - @SerializedName("isPermanent") - private boolean isPermanent; - - public String getMode() { - return mode; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureControlSystem.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureControlSystem.java deleted file mode 100644 index b5c8d8a59a..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureControlSystem.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the temperature control system - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class TemperatureControlSystem { - - @SerializedName("systemId") - private String systemId; - - @SerializedName("modelType") - private String modelType; - - @SerializedName("zones") - private List zones; - - @SerializedName("allowedSystemModes") - private List allowedSystemModes; - - public String getSystemId() { - return systemId; - } - - public List getZones() { - return zones; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureControlSystemStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureControlSystemStatus.java deleted file mode 100644 index 019e6ec5dd..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureControlSystemStatus.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the temperature control system status - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class TemperatureControlSystemStatus { - - @SerializedName("systemId") - private String systemId; - - @SerializedName("systemModeStatus") - private SystemModeStatus mode; - - @SerializedName("zones") - private List zones; - - @SerializedName("activeFaults") - private List activeFaults; - - public String getSystemId() { - return systemId; - } - - public SystemModeStatus getMode() { - return mode; - } - - public List getZones() { - return zones; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureStatus.java deleted file mode 100644 index c0374cfde8..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TemperatureStatus.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the temperature status - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class TemperatureStatus { - - @SerializedName("temperature") - private double temperature; - - @SerializedName("isAvailable") - private boolean isAvailable; - - public double getTemperature() { - return temperature; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TimeZone.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TimeZone.java deleted file mode 100644 index eef0cff647..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/TimeZone.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the time zone - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class TimeZone { - - @SerializedName("timeZoneId") - private String timeZoneId; - - @SerializedName("displayName") - private String displayName; - - @SerializedName("offsetMinutes") - private int offsetMinutes; - - @SerializedName("currentOffsetMinutes") - private int currentOffsetMinutes; - - @SerializedName("supportsDaylightSaving") - private boolean supportsDaylightSaving; -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/UserAccount.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/UserAccount.java deleted file mode 100644 index 6967cf9ec6..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/UserAccount.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the user account - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class UserAccount { - - @SerializedName("userId") - private String userId; - - @SerializedName("username") - private String userName; - - @SerializedName("firstname") - private String firstName; - - @SerializedName("lastname") - private String lastName; - - @SerializedName("streetAddress") - private String streetAddress; - - @SerializedName("city") - private String city; - - @SerializedName("postcode") - private String postCode; - - @SerializedName("country") - private String country; - - @SerializedName("language") - private String language; - - public String getUserId() { - return userId; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Zone.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Zone.java deleted file mode 100644 index 726c988f4b..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/Zone.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for the zone - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class Zone { - - @SerializedName("zoneId") - private String zoneId; - - @SerializedName("modelType") - private String modelType; - - @SerializedName("name") - private String name; - - @SerializedName("zoneType") - private String zoneType; - - @SerializedName("heatSetpointCapabilities") - private HeatSetpointCapabilities heatSetpointCapabilities; - - @SerializedName("scheduleCapabilities") - private ScheduleCapabilities scheduleCapabilities; - - public String getZoneId() { - return zoneId; - } - - public String getName() { - return name; - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ZoneStatus.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ZoneStatus.java deleted file mode 100644 index 3a063ceecf..0000000000 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/api/models/v2/response/ZoneStatus.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2010-2023 Contributors to the openHAB project - * - * See the NOTICE file(s) distributed with this work for additional - * information. - * - * This program and the accompanying materials are made available under the - * terms of the Eclipse Public License 2.0 which is available at - * http://www.eclipse.org/legal/epl-2.0 - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.openhab.binding.evohome.internal.api.models.v2.response; - -import java.util.List; - -import com.google.gson.annotations.SerializedName; - -/** - * Response model for zone status - * - * @author Jasper van Zuijlen - Initial contribution - * - */ -public class ZoneStatus { - - @SerializedName("zoneId") - private String zoneId; - - @SerializedName("name") - private String name; - - @SerializedName("temperatureStatus") - private TemperatureStatus temperature; - - @SerializedName("setpointStatus") - private HeatSetpointStatus heatSetpoint; - - @SerializedName("activeFaults") - private List activeFaults; - - public String getZoneId() { - return zoneId; - } - - public TemperatureStatus getTemperature() { - return temperature; - } - - public HeatSetpointStatus getHeatSetpoint() { - return heatSetpoint; - } - - public boolean hasActiveFaults() { - return !activeFaults.isEmpty(); - } - - public ActiveFault getActiveFault(int index) { - return activeFaults.get(index); - } -} diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeAccountConfiguration.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeAccountConfiguration.java index 2fd30a516e..ce750c26c9 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeAccountConfiguration.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeAccountConfiguration.java @@ -12,15 +12,18 @@ */ package org.openhab.binding.evohome.internal.configuration; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Contains the configuration of the binding. * * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeAccountConfiguration { - public String username; - public String password; - public String applicationId; + public String username = ""; + public String password = ""; + public String applicationId = ""; public int refreshInterval; } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeTemperatureControlSystemConfiguration.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeTemperatureControlSystemConfiguration.java index af56d9f0f5..2c8727f991 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeTemperatureControlSystemConfiguration.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeTemperatureControlSystemConfiguration.java @@ -12,13 +12,16 @@ */ package org.openhab.binding.evohome.internal.configuration; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Contains the configuration of the binding. * * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeTemperatureControlSystemConfiguration { - public String id; - public String name; + public String id = ""; + public String name = ""; } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeThingConfiguration.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeThingConfiguration.java index 961bed76bc..42b7949981 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeThingConfiguration.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/configuration/EvohomeThingConfiguration.java @@ -12,13 +12,16 @@ */ package org.openhab.binding.evohome.internal.configuration; +import org.eclipse.jdt.annotation.NonNullByDefault; + /** * Contains the common configuration definition of an evohome Thing * * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeThingConfiguration { - public String id; - public String name; + public String id = ""; + public String name = ""; } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/discovery/EvohomeDiscoveryService.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/discovery/EvohomeDiscoveryService.java index cf9cd92216..f5b197e690 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/discovery/EvohomeDiscoveryService.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/discovery/EvohomeDiscoveryService.java @@ -15,11 +15,13 @@ package org.openhab.binding.evohome.internal.discovery; import java.util.HashMap; import java.util.Map; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.binding.evohome.internal.EvohomeBindingConstants; -import org.openhab.binding.evohome.internal.api.models.v2.response.Gateway; -import org.openhab.binding.evohome.internal.api.models.v2.response.Location; -import org.openhab.binding.evohome.internal.api.models.v2.response.TemperatureControlSystem; -import org.openhab.binding.evohome.internal.api.models.v2.response.Zone; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Gateway; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Location; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Locations; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.TemperatureControlSystem; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Zone; import org.openhab.binding.evohome.internal.handler.AccountStatusListener; import org.openhab.binding.evohome.internal.handler.EvohomeAccountBridgeHandler; import org.openhab.core.config.discovery.AbstractDiscoveryService; @@ -37,6 +39,7 @@ import org.slf4j.LoggerFactory; * @author Jasper van Zuijlen - Background discovery * */ +@NonNullByDefault public class EvohomeDiscoveryService extends AbstractDiscoveryService implements AccountStatusListener { private final Logger logger = LoggerFactory.getLogger(EvohomeDiscoveryService.class); private static final int TIMEOUT = 5; @@ -86,18 +89,29 @@ public class EvohomeDiscoveryService extends AbstractDiscoveryService implements logger.debug("Evohome Gateway not online, scanning postponed"); return; } + Locations localEvohomeConfig = bridge.getEvohomeConfig(); - for (Location location : bridge.getEvohomeConfig()) { + if (localEvohomeConfig == null) { + return; + } + for (Location location : localEvohomeConfig) { + if (location == null) { + continue; + } for (Gateway gateway : location.getGateways()) { for (TemperatureControlSystem tcs : gateway.getTemperatureControlSystems()) { + if (tcs == null) { + continue; + } addDisplayDiscoveryResult(location, tcs); for (Zone zone : tcs.getZones()) { - addZoneDiscoveryResult(location, zone); + if (zone != null) { + addZoneDiscoveryResult(location, zone); + } } } } } - stopScan(); } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/AccountStatusListener.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/AccountStatusListener.java index 7253312601..4341688a7b 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/AccountStatusListener.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/AccountStatusListener.java @@ -12,6 +12,7 @@ */ package org.openhab.binding.evohome.internal.handler; +import org.eclipse.jdt.annotation.NonNullByDefault; import org.openhab.core.thing.ThingStatus; /** @@ -20,6 +21,7 @@ import org.openhab.core.thing.ThingStatus; * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public interface AccountStatusListener { /** diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/BaseEvohomeHandler.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/BaseEvohomeHandler.java index ac5ad2378f..11048291cd 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/BaseEvohomeHandler.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/BaseEvohomeHandler.java @@ -12,7 +12,9 @@ */ package org.openhab.binding.evohome.internal.handler; -import org.openhab.binding.evohome.internal.api.models.v2.response.Locations; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Locations; import org.openhab.binding.evohome.internal.configuration.EvohomeThingConfiguration; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Thing; @@ -25,8 +27,9 @@ import org.openhab.core.thing.binding.BaseThingHandler; * * @author Jasper van Zuijlen - Initial contribution */ +@NonNullByDefault public abstract class BaseEvohomeHandler extends BaseThingHandler { - private EvohomeThingConfiguration configuration; + private EvohomeThingConfiguration configuration = new EvohomeThingConfiguration(); public BaseEvohomeHandler(Thing thing) { super(thing); @@ -40,14 +43,10 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler { @Override public void dispose() { - configuration = null; } public String getId() { - if (configuration != null) { - return configuration.id; - } - return null; + return configuration.id; } /** @@ -64,7 +63,7 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler { * * @return The evohome brdige */ - protected EvohomeAccountBridgeHandler getEvohomeBridge() { + protected @Nullable EvohomeAccountBridgeHandler getEvohomeBridge() { Bridge bridge = getBridge(); if (bridge != null) { return (EvohomeAccountBridgeHandler) bridge.getHandler(); @@ -78,10 +77,10 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler { * * @return The current evohome configuration */ - protected Locations getEvohomeConfig() { - EvohomeAccountBridgeHandler bridge = getEvohomeBridge(); - if (bridge != null) { - return bridge.getEvohomeConfig(); + protected @Nullable Locations getEvohomeConfig() { + EvohomeAccountBridgeHandler bridgeAccountHandler = getEvohomeBridge(); + if (bridgeAccountHandler != null) { + return bridgeAccountHandler.getEvohomeConfig(); } return null; @@ -115,7 +114,7 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler { * @param detail The status detail value * @param message The message to show with the status */ - protected void updateEvohomeThingStatus(ThingStatus newStatus, ThingStatusDetail detail, String message) { + protected void updateEvohomeThingStatus(ThingStatus newStatus, ThingStatusDetail detail, @Nullable String message) { // Prevent spamming the log file if (!newStatus.equals(getThing().getStatus())) { updateStatus(newStatus, detail, message); @@ -128,10 +127,7 @@ public abstract class BaseEvohomeHandler extends BaseThingHandler { * @param configuration The configuration to check */ private void checkConfig() { - if (configuration == null) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, - "Configuration is missing or corrupted"); - } else if (configuration.id == null || configuration.id.isEmpty()) { + if (configuration.id.isEmpty()) { updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Id not configured"); } } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeAccountBridgeHandler.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeAccountBridgeHandler.java index 22054a4e2a..e472ce9680 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeAccountBridgeHandler.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeAccountBridgeHandler.java @@ -22,19 +22,21 @@ import java.util.concurrent.ScheduledFuture; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jetty.client.HttpClient; import org.openhab.binding.evohome.internal.RunnableWithTimeout; import org.openhab.binding.evohome.internal.api.EvohomeApiClient; -import org.openhab.binding.evohome.internal.api.models.v2.response.Gateway; -import org.openhab.binding.evohome.internal.api.models.v2.response.GatewayStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.Location; -import org.openhab.binding.evohome.internal.api.models.v2.response.LocationStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.Locations; -import org.openhab.binding.evohome.internal.api.models.v2.response.LocationsStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.TemperatureControlSystem; -import org.openhab.binding.evohome.internal.api.models.v2.response.TemperatureControlSystemStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.Zone; -import org.openhab.binding.evohome.internal.api.models.v2.response.ZoneStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Gateway; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.GatewayStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Location; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.LocationStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Locations; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.LocationsStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.TemperatureControlSystem; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.TemperatureControlSystemStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.Zone; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.ZoneStatus; import org.openhab.binding.evohome.internal.configuration.EvohomeAccountConfiguration; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; @@ -54,15 +56,16 @@ import org.slf4j.LoggerFactory; * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeAccountBridgeHandler extends BaseBridgeHandler { private final Logger logger = LoggerFactory.getLogger(EvohomeAccountBridgeHandler.class); private final HttpClient httpClient; - private EvohomeAccountConfiguration configuration; - private EvohomeApiClient apiClient; + private EvohomeAccountConfiguration configuration = new EvohomeAccountConfiguration(); + private @Nullable EvohomeApiClient apiClient; private List listeners = new CopyOnWriteArrayList<>(); - protected ScheduledFuture refreshTask; + protected @Nullable ScheduledFuture refreshTask; public EvohomeAccountBridgeHandler(Bridge thing, HttpClient httpClient) { super(thing); @@ -73,13 +76,14 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler { public void initialize() { configuration = getConfigAs(EvohomeAccountConfiguration.class); - if (checkConfig()) { + if (checkConfig(configuration)) { apiClient = new EvohomeApiClient(configuration, this.httpClient); // Initialization can take a while, so kick it off on a separate thread scheduler.schedule(() -> { - if (apiClient.login()) { - if (checkInstallationInfoHasDuplicateIds(apiClient.getInstallationInfo())) { + EvohomeApiClient localApiCLient = apiClient; + if (localApiCLient != null && localApiCLient.login()) { + if (checkInstallationInfoHasDuplicateIds(localApiCLient.getInstallationInfo())) { startRefreshTask(); } else { updateAccountStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, @@ -104,24 +108,41 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler { public void handleCommand(ChannelUID channelUID, Command command) { } - public Locations getEvohomeConfig() { - return apiClient.getInstallationInfo(); + public @Nullable Locations getEvohomeConfig() { + EvohomeApiClient localApiCLient = apiClient; + if (localApiCLient != null) { + return localApiCLient.getInstallationInfo(); + } + return null; } - public LocationsStatus getEvohomeStatus() { - return apiClient.getInstallationStatus(); + public @Nullable LocationsStatus getEvohomeStatus() { + EvohomeApiClient localApiCLient = apiClient; + if (localApiCLient != null) { + return localApiCLient.getInstallationStatus(); + } + return null; } public void setTcsMode(String tcsId, String mode) { - tryToCall(() -> apiClient.setTcsMode(tcsId, mode)); + EvohomeApiClient localApiCLient = apiClient; + if (localApiCLient != null) { + tryToCall(() -> localApiCLient.setTcsMode(tcsId, mode)); + } } public void setPermanentSetPoint(String zoneId, double doubleValue) { - tryToCall(() -> apiClient.setHeatingZoneOverride(zoneId, doubleValue)); + EvohomeApiClient localApiCLient = apiClient; + if (localApiCLient != null) { + tryToCall(() -> localApiCLient.setHeatingZoneOverride(zoneId, doubleValue)); + } } public void cancelSetPointOverride(String zoneId) { - tryToCall(() -> apiClient.cancelHeatingZoneOverride(zoneId)); + EvohomeApiClient localApiCLient = apiClient; + if (localApiCLient != null) { + tryToCall(() -> localApiCLient.cancelHeatingZoneOverride(zoneId)); + } } public void addAccountStatusListener(AccountStatusListener listener) { @@ -164,26 +185,27 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler { } private void disposeApiClient() { - if (apiClient != null) { - apiClient.logout(); + EvohomeApiClient localApiClient = apiClient; + if (localApiClient != null) { + localApiClient.logout(); + this.apiClient = null; } - apiClient = null; } private void disposeRefreshTask() { - if (refreshTask != null) { - refreshTask.cancel(true); + ScheduledFuture localRefreshTask = refreshTask; + if (localRefreshTask != null) { + localRefreshTask.cancel(true); + this.refreshTask = null; } } - private boolean checkConfig() { + private boolean checkConfig(EvohomeAccountConfiguration configuration) { String errorMessage = ""; - if (configuration == null) { - errorMessage = "Configuration is missing or corrupted"; - } else if (configuration.username == null || configuration.username.isEmpty()) { + if (configuration.username.isBlank()) { errorMessage = "Username not configured"; - } else if (configuration.password == null || configuration.password.isEmpty()) { + } else if (configuration.password.isBlank()) { errorMessage = "Password not configured"; } else { return true; @@ -202,7 +224,10 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler { private void update() { try { - apiClient.update(); + EvohomeApiClient localApiCLient = apiClient; + if (localApiCLient != null) { + localApiCLient.update(); + } updateAccountStatus(ThingStatus.ONLINE); updateThings(); } catch (Exception e) { @@ -215,7 +240,7 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler { updateAccountStatus(newStatus, ThingStatusDetail.NONE, null); } - private void updateAccountStatus(ThingStatus newStatus, ThingStatusDetail detail, String message) { + private void updateAccountStatus(ThingStatus newStatus, ThingStatusDetail detail, @Nullable String message) { // Prevent spamming the log file if (!newStatus.equals(getThing().getStatus())) { updateStatus(newStatus, detail, message); @@ -236,15 +261,32 @@ public class EvohomeAccountBridgeHandler extends BaseBridgeHandler { Map zoneIdToTcsIdMap = new HashMap<>(); Map idToTcsThingsStatusMap = new HashMap<>(); - // First, create a lookup table - for (LocationStatus location : apiClient.getInstallationStatus()) { - for (GatewayStatus gateway : location.getGateways()) { - for (TemperatureControlSystemStatus tcs : gateway.getTemperatureControlSystems()) { - idToTcsMap.put(tcs.getSystemId(), tcs); - tcsIdToGatewayMap.put(tcs.getSystemId(), gateway); - for (ZoneStatus zone : tcs.getZones()) { - idToZoneMap.put(zone.getZoneId(), zone); - zoneIdToTcsIdMap.put(zone.getZoneId(), tcs.getSystemId()); + EvohomeApiClient localApiClient = apiClient; + if (localApiClient != null) { + // First, create a lookup table + LocationsStatus localLocationsStatus = localApiClient.getInstallationStatus(); + if (localLocationsStatus != null) { + for (LocationStatus location : localLocationsStatus) { + for (GatewayStatus gateway : location.getGateways()) { + if (gateway == null) { + continue; + } + for (TemperatureControlSystemStatus tcs : gateway.getTemperatureControlSystems()) { + String systemId = tcs.getSystemId(); + if (systemId != null) { + idToTcsMap.put(systemId, tcs); + tcsIdToGatewayMap.put(systemId, gateway); + } + for (ZoneStatus zone : tcs.getZones()) { + String zoneId = zone.getZoneId(); + if (zoneId != null) { + idToZoneMap.put(zoneId, zone); + if (systemId != null) { + zoneIdToTcsIdMap.put(zoneId, systemId); + } + } + } + } } } } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeHeatingZoneHandler.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeHeatingZoneHandler.java index 1fb6d43456..8dc6cbb391 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeHeatingZoneHandler.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeHeatingZoneHandler.java @@ -12,10 +12,15 @@ */ package org.openhab.binding.evohome.internal.handler; +import javax.measure.quantity.Temperature; + +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.evohome.internal.EvohomeBindingConstants; -import org.openhab.binding.evohome.internal.api.models.v2.response.ZoneStatus; -import org.openhab.core.library.types.DecimalType; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.ZoneStatus; +import org.openhab.core.library.types.QuantityType; import org.openhab.core.library.types.StringType; +import org.openhab.core.library.unit.SIUnits; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingStatus; @@ -30,12 +35,14 @@ import org.openhab.core.types.RefreshType; * @author Jasper van Zuijlen - Initial contribution * @author Neil Renaud - Working implementation * @author Jasper van Zuijlen - Refactor + Permanent Zone temperature setting + * @author Leo Siepel - Add UoM */ +@NonNullByDefault public class EvohomeHeatingZoneHandler extends BaseEvohomeHandler { private static final int CANCEL_SET_POINT_OVERRIDE = 0; - private ThingStatus tcsStatus; - private ZoneStatus zoneStatus; + private @Nullable ThingStatus tcsStatus; + private @Nullable ZoneStatus zoneStatus; public EvohomeHeatingZoneHandler(Thing thing) { super(thing); @@ -46,7 +53,7 @@ public class EvohomeHeatingZoneHandler extends BaseEvohomeHandler { super.initialize(); } - public void update(ThingStatus tcsStatus, ZoneStatus zoneStatus) { + public void update(@Nullable ThingStatus tcsStatus, @Nullable ZoneStatus zoneStatus) { this.tcsStatus = tcsStatus; this.zoneStatus = zoneStatus; @@ -62,11 +69,11 @@ public class EvohomeHeatingZoneHandler extends BaseEvohomeHandler { updateEvohomeThingStatus(ThingStatus.ONLINE); updateState(EvohomeBindingConstants.ZONE_TEMPERATURE_CHANNEL, - new DecimalType(zoneStatus.getTemperature().getTemperature())); + new QuantityType(zoneStatus.getTemperature().getTemperature(), SIUnits.CELSIUS)); updateState(EvohomeBindingConstants.ZONE_SET_POINT_STATUS_CHANNEL, new StringType(zoneStatus.getHeatSetpoint().getSetpointMode())); - updateState(EvohomeBindingConstants.ZONE_SET_POINT_CHANNEL, - new DecimalType(zoneStatus.getHeatSetpoint().getTargetTemperature())); + updateState(EvohomeBindingConstants.ZONE_SET_POINT_CHANNEL, new QuantityType( + zoneStatus.getHeatSetpoint().getTargetTemperature(), SIUnits.CELSIUS)); } } @@ -78,16 +85,19 @@ public class EvohomeHeatingZoneHandler extends BaseEvohomeHandler { EvohomeAccountBridgeHandler bridge = getEvohomeBridge(); if (bridge != null) { String channelId = channelUID.getId(); - if (EvohomeBindingConstants.ZONE_SET_POINT_CHANNEL.equals(channelId) - && command instanceof DecimalType) { - double newTemp = ((DecimalType) command).doubleValue(); - if (newTemp == CANCEL_SET_POINT_OVERRIDE) { - bridge.cancelSetPointOverride(getEvohomeThingConfig().id); - } else if (newTemp < 5) { - newTemp = 5; - } - if (newTemp >= 5 && newTemp <= 35) { - bridge.setPermanentSetPoint(getEvohomeThingConfig().id, newTemp); + if (EvohomeBindingConstants.ZONE_SET_POINT_CHANNEL.equals(channelId)) { + if (command instanceof QuantityType) { + QuantityType state = ((QuantityType) command).toUnit(SIUnits.CELSIUS); + double newTempInCelsius = state.doubleValue(); + + if (newTempInCelsius == CANCEL_SET_POINT_OVERRIDE) { + bridge.cancelSetPointOverride(getEvohomeThingConfig().id); + } else if (newTempInCelsius < 5) { + newTempInCelsius = 5; + } + if (newTempInCelsius >= 5 && newTempInCelsius <= 35) { + bridge.setPermanentSetPoint(getEvohomeThingConfig().id, newTempInCelsius); + } } } } diff --git a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeTemperatureControlSystemHandler.java b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeTemperatureControlSystemHandler.java index 6781e22b35..5d07539cd8 100644 --- a/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeTemperatureControlSystemHandler.java +++ b/bundles/org.openhab.binding.evohome/src/main/java/org/openhab/binding/evohome/internal/handler/EvohomeTemperatureControlSystemHandler.java @@ -12,9 +12,11 @@ */ package org.openhab.binding.evohome.internal.handler; +import org.eclipse.jdt.annotation.NonNullByDefault; +import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.evohome.internal.EvohomeBindingConstants; -import org.openhab.binding.evohome.internal.api.models.v2.response.GatewayStatus; -import org.openhab.binding.evohome.internal.api.models.v2.response.TemperatureControlSystemStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.GatewayStatus; +import org.openhab.binding.evohome.internal.api.models.v2.dto.response.TemperatureControlSystemStatus; import org.openhab.core.library.types.StringType; import org.openhab.core.thing.ChannelUID; import org.openhab.core.thing.Thing; @@ -29,9 +31,10 @@ import org.openhab.core.types.RefreshType; * @author Jasper van Zuijlen - Initial contribution * */ +@NonNullByDefault public class EvohomeTemperatureControlSystemHandler extends BaseEvohomeHandler { - private GatewayStatus gatewayStatus; - private TemperatureControlSystemStatus tcsStatus; + private @Nullable GatewayStatus gatewayStatus; + private @Nullable TemperatureControlSystemStatus tcsStatus; public EvohomeTemperatureControlSystemHandler(Thing thing) { super(thing); @@ -42,7 +45,7 @@ public class EvohomeTemperatureControlSystemHandler extends BaseEvohomeHandler { super.initialize(); } - public void update(GatewayStatus gatewayStatus, TemperatureControlSystemStatus tcsStatus) { + public void update(@Nullable GatewayStatus gatewayStatus, @Nullable TemperatureControlSystemStatus tcsStatus) { this.gatewayStatus = gatewayStatus; this.tcsStatus = tcsStatus; diff --git a/bundles/org.openhab.binding.evohome/src/main/resources/OH-INF/thing/channels.xml b/bundles/org.openhab.binding.evohome/src/main/resources/OH-INF/thing/channels.xml index c7b8c7e253..0d8978b5ff 100644 --- a/bundles/org.openhab.binding.evohome/src/main/resources/OH-INF/thing/channels.xml +++ b/bundles/org.openhab.binding.evohome/src/main/resources/OH-INF/thing/channels.xml @@ -20,19 +20,27 @@ - Number + Number:Temperature Current zone temperature temperature - + + Measurement + Temperature + + - Number + Number:Temperature Gets or sets the set point of this zone (0 cancels the override). heating - + + Setpoint + Temperature + + String