From 15ac04e5cc267ea6eed3e71662154b0eb7596382 Mon Sep 17 00:00:00 2001 From: Florian Hotze Date: Thu, 15 Feb 2024 14:29:51 +0100 Subject: [PATCH] [openweathermap] Code clean-up (#16369) * [openweathermap] Remove UV Index Thing The UV Index API has been retired on 1st April 2021 and replaced by OneCall API 3.0. Therefore, this Thing is not working anymore and can be removed from the source code. * [openweathermap] Clean-Up DTOs - Improve class JavaDoc. - Remove setters as they are not needed. (All OWM APIs get required the data as query params.) Signed-off-by: Florian Hotze Signed-off-by: Ciprian Pascu --- .../README.md | 29 --- .../OpenWeatherMapBindingConstants.java | 4 - .../OpenWeatherMapUVIndexConfiguration.java | 27 --- .../connection/OpenWeatherMapConnection.java | 45 ---- .../OpenWeatherMapJsonAirPollutionData.java | 4 +- .../OpenWeatherMapJsonDailyForecastData.java | 24 +- .../OpenWeatherMapJsonHourlyForecastData.java | 5 +- .../dto/OpenWeatherMapJsonUVIndexData.java | 70 ------ .../dto/OpenWeatherMapJsonWeatherData.java | 4 +- .../dto/OpenWeatherMapOneCallAPIData.java | 41 +--- .../dto/OpenWeatherMapOneCallHistAPIData.java | 9 +- .../internal/dto/airpollution/Components.java | 2 +- .../internal/dto/airpollution/List.java | 2 +- .../internal/dto/airpollution/Main.java | 2 +- .../internal/dto/base/City.java | 20 -- .../internal/dto/base/Clouds.java | 4 - .../internal/dto/base/Coord.java | 10 +- .../internal/dto/base/Precipitation.java | 8 - .../internal/dto/base/Weather.java | 16 -- .../internal/dto/base/Wind.java | 12 - .../dto/forecast/daily/FeelsLikeTemp.java | 18 +- .../internal/dto/forecast/daily/List.java | 62 +----- .../internal/dto/forecast/daily/Temp.java | 26 +-- .../internal/dto/forecast/hourly/List.java | 39 +--- .../internal/dto/forecast/hourly/Main.java | 3 +- .../internal/dto/forecast/hourly/Sys.java | 3 +- .../internal/dto/onecall/Alert.java | 32 ++- .../internal/dto/onecall/Current.java | 75 +------ .../internal/dto/onecall/Daily.java | 79 +------ .../internal/dto/onecall/Hourly.java | 67 +----- .../internal/dto/onecall/Minutely.java | 15 +- .../internal/dto/onecall/Precipitation.java | 11 +- .../internal/dto/onecall/Weather.java | 23 +- .../internal/dto/onecallhist/Hourly.java | 63 +----- .../internal/dto/weather/Main.java | 26 +-- .../internal/dto/weather/Sys.java | 26 +-- .../factory/OpenWeatherMapHandlerFactory.java | 3 - .../AbstractOpenWeatherMapHandler.java | 3 +- .../handler/OpenWeatherMapOneCallHandler.java | 10 +- .../handler/OpenWeatherMapUVIndexHandler.java | 205 ------------------ .../OH-INF/i18n/openweathermap.properties | 20 -- .../resources/OH-INF/thing/channel-types.xml | 18 -- .../resources/OH-INF/thing/thing-types.xml | 37 ---- 43 files changed, 69 insertions(+), 1133 deletions(-) delete mode 100644 bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/config/OpenWeatherMapUVIndexConfiguration.java delete mode 100644 bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonUVIndexData.java delete mode 100644 bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapUVIndexHandler.java diff --git a/bundles/org.openhab.binding.openweathermap/README.md b/bundles/org.openhab.binding.openweathermap/README.md index 23eb14c0723..2b5aecb95ff 100644 --- a/bundles/org.openhab.binding.openweathermap/README.md +++ b/bundles/org.openhab.binding.openweathermap/README.md @@ -21,17 +21,6 @@ You can add as many `weather-and-forecast` things for different locations to you The binding tries to request daily forecast data from the OpenWeatherMap API. If the request fails, all daily forecast channel groups will be removed from the thing and further request will be omitted. -### Current UV Index And Forecast - -::: tip Note -The product will retire on 1st April 2021, please find UV data in the One Call API. -One Call API includes current, hourly forecast for 7 days and 5 days historical UV data. -::: - -The third thing `uvindex` supports the [current UV Index](https://openweathermap.org/api/uvi#current) and [forecasted UV Index](https://openweathermap.org/api/uvi#forecast) for a specific location. -It requires coordinates of the location of your interest. -You can add as much `uvindex` things for different locations to your setup as you like to observe. - ### Current And Forecasted Air Pollution Another thing is the `air-pollution` which provides the [current air pollution](https://openweathermap.org/api/air-pollution) and [forecasted air pollution](https://openweathermap.org/api/air-pollution#forecast) for a specific location. @@ -84,15 +73,6 @@ Once the system location will be changed, the background discovery updates the c Once the parameters `forecastHours` or `forecastDays` will be changed, the available channel groups on the thing will be created or removed accordingly. -### Current UV Index And Forecast - -| Parameter | Description | -|----------------|----------------------------------------------------------------------------------------------------------------------------------| -| location | Location of weather in geographical coordinates (latitude/longitude/altitude). **Mandatory** | -| forecastDays | Number of days for UV Index forecast (including todays forecast). Optional, the default value is 6 (min="1", max="8", step="1"). | - -Once the parameter `forecastDays` will be changed, the available channel groups on the thing will be created or removed accordingly. - ### Current Air Pollution And Forecast | Parameter | Description | @@ -257,15 +237,6 @@ In a future release, the `forecastToday` to `forecastDay7` channel groups won't | alerts1, alerts2, ... | expires | DateTime | End Date and Time for which the warning is valid. | | alerts1, alerts2, ... | source | String | The source of the alert. **Advanced** | -### UV Index - -| Channel Group ID | Channel ID | Item Type | Description | -|-----------------------------------------------------------|------------|-----------|--------------------------------------| -| current, forecastTomorrow, forecastDay2, ... forecastDay7 | time-stamp | DateTime | Date of data observation / forecast. | -| current, forecastTomorrow, forecastDay2, ... forecastDay7 | uvindex | Number | Current or forecasted UV Index. | - -The `uvindex` channel is also available in the current data and the daily forecast of the One Call API. - ### Air Pollution | Channel Group ID | Channel ID | Item Type | Description | diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/OpenWeatherMapBindingConstants.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/OpenWeatherMapBindingConstants.java index f7a8a353739..b614aab1aee 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/OpenWeatherMapBindingConstants.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/OpenWeatherMapBindingConstants.java @@ -35,7 +35,6 @@ public class OpenWeatherMapBindingConstants { // Thing public static final ThingTypeUID THING_TYPE_WEATHER_AND_FORECAST = new ThingTypeUID(BINDING_ID, "weather-and-forecast"); - public static final ThingTypeUID THING_TYPE_UVINDEX = new ThingTypeUID(BINDING_ID, "uvindex"); public static final ThingTypeUID THING_TYPE_AIR_POLLUTION = new ThingTypeUID(BINDING_ID, "air-pollution"); // One Call API forecast public static final ThingTypeUID THING_TYPE_ONECALL_WEATHER_AND_FORECAST = new ThingTypeUID(BINDING_ID, "onecall"); @@ -53,8 +52,6 @@ public class OpenWeatherMapBindingConstants { "hourlyForecast"); public static final ChannelGroupTypeUID CHANNEL_GROUP_TYPE_DAILY_FORECAST = new ChannelGroupTypeUID(BINDING_ID, "dailyForecast"); - public static final ChannelGroupTypeUID CHANNEL_GROUP_TYPE_UVINDEX_FORECAST = new ChannelGroupTypeUID(BINDING_ID, - "uvindexForecast"); public static final ChannelGroupTypeUID CHANNEL_GROUP_TYPE_AIR_POLLUTION_FORECAST = new ChannelGroupTypeUID( BINDING_ID, "airPollutionForecast"); public static final ChannelGroupTypeUID CHANNEL_GROUP_TYPE_ONECALL_MINUTELY_FORECAST = new ChannelGroupTypeUID( @@ -73,7 +70,6 @@ public class OpenWeatherMapBindingConstants { public static final String CHANNEL_GROUP_CURRENT_WEATHER = "current"; public static final String CHANNEL_GROUP_FORECAST_TODAY = "forecastToday"; public static final String CHANNEL_GROUP_FORECAST_TOMORROW = "forecastTomorrow"; - public static final String CHANNEL_GROUP_CURRENT_UVINDEX = "current"; public static final String CHANNEL_GROUP_CURRENT_AIR_POLLUTION = "current"; public static final String CHANNEL_GROUP_ONECALL_CURRENT = "current"; public static final String CHANNEL_GROUP_ONECALL_HISTORY = "history"; diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/config/OpenWeatherMapUVIndexConfiguration.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/config/OpenWeatherMapUVIndexConfiguration.java deleted file mode 100644 index 33595d36209..00000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/config/OpenWeatherMapUVIndexConfiguration.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.openweathermap.internal.config; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapUVIndexHandler; - -/** - * The {@link OpenWeatherMapUVIndexConfiguration} is the class used to match the - * {@link OpenWeatherMapUVIndexHandler}s configuration. - * - * @author Christoph Weitkamp - Initial contribution - */ -@NonNullByDefault -public class OpenWeatherMapUVIndexConfiguration extends OpenWeatherMapLocationConfiguration { - public int forecastDays; -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java index 08bde19187f..8efc1e8d5a4 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/connection/OpenWeatherMapConnection.java @@ -20,7 +20,6 @@ import java.nio.charset.StandardCharsets; import java.time.ZoneId; import java.time.ZonedDateTime; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -38,7 +37,6 @@ import org.openhab.binding.openweathermap.internal.config.OpenWeatherMapAPIConfi import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonAirPollutionData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonDailyForecastData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonHourlyForecastData; -import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonUVIndexData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonWeatherData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallAPIData; import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallHistAPIData; @@ -88,9 +86,6 @@ public class OpenWeatherMapConnection { private static final String THREE_HOUR_FORECAST_URL = "https://api.openweathermap.org/data/2.5/forecast"; // 16 day / daily forecast (see https://openweathermap.org/forecast16) private static final String DAILY_FORECAST_URL = "https://api.openweathermap.org/data/2.5/forecast/daily"; - // UV Index (see https://openweathermap.org/api/uvi) - private static final String UVINDEX_URL = "https://api.openweathermap.org/data/2.5/uvi"; - private static final String UVINDEX_FORECAST_URL = "https://api.openweathermap.org/data/2.5/uvi/forecast"; // Air Pollution (see https://openweathermap.org/api/air-pollution) private static final String AIR_POLLUTION_URL = "https://api.openweathermap.org/data/2.5/air_pollution"; private static final String AIR_POLLUTION_FORECAST_URL = "https://api.openweathermap.org/data/2.5/air_pollution/forecast"; @@ -181,46 +176,6 @@ public class OpenWeatherMapConnection { OpenWeatherMapJsonDailyForecastData.class); } - /** - * Requests the UV Index data for the given location (see https://openweathermap.org/api/uvi). - * - * @param location location represented as {@link PointType} - * @return the UV Index data - * @throws JsonSyntaxException - * @throws CommunicationException - * @throws ConfigurationException - */ - public synchronized @Nullable OpenWeatherMapJsonUVIndexData getUVIndexData(@Nullable PointType location) - throws JsonSyntaxException, CommunicationException, ConfigurationException { - return gson.fromJson( - getResponseFromCache( - buildURL(UVINDEX_URL, getRequestParams(handler.getOpenWeatherMapAPIConfig(), location))), - OpenWeatherMapJsonUVIndexData.class); - } - - /** - * Requests the UV Index forecast data for the given location (see https://openweathermap.org/api/uvi). - * - * @param location location represented as {@link PointType} - * @return the UV Index forecast data - * @throws JsonSyntaxException - * @throws CommunicationException - * @throws ConfigurationException - */ - public synchronized @Nullable List getUVIndexForecastData( - @Nullable PointType location, int count) - throws JsonSyntaxException, CommunicationException, ConfigurationException { - if (count <= 0) { - throw new ConfigurationException("@text/offline.conf-error-not-supported-uvindex-number-of-days"); - } - - Map params = getRequestParams(handler.getOpenWeatherMapAPIConfig(), location); - params.put(PARAM_FORECAST_CNT, Integer.toString(count)); - - return Arrays.asList(gson.fromJson(getResponseFromCache(buildURL(UVINDEX_FORECAST_URL, params)), - OpenWeatherMapJsonUVIndexData[].class)); - } - /** * Requests the Air Pollution data for the given location (see https://openweathermap.org/api/air-pollution). * diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java index ac09d09c094..bd711a8fcf3 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonAirPollutionData.java @@ -16,8 +16,8 @@ import org.openhab.binding.openweathermap.internal.dto.airpollution.List; import org.openhab.binding.openweathermap.internal.dto.base.Coord; /** - * The {@link OpenWeatherMapJsonAirPollutionData} is the Java class used to map the JSON response to an OpenWeatherMap - * request. + * Holds the data from the deserialised JSON response of the Air + * Pollution API. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonDailyForecastData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonDailyForecastData.java index 760a5b53e8c..a9f97756e11 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonDailyForecastData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonDailyForecastData.java @@ -16,8 +16,8 @@ import org.openhab.binding.openweathermap.internal.dto.base.City; import org.openhab.binding.openweathermap.internal.dto.forecast.daily.List; /** - * The {@link OpenWeatherMapJsonDailyForecastData} is the Java class used to map the JSON response to an OpenWeatherMap - * request. + * Holds the data from the deserialised JSON response of the Daily + * Forecast 16 Days API. * * @author Christoph Weitkamp - Initial contribution */ @@ -32,39 +32,19 @@ public class OpenWeatherMapJsonDailyForecastData { return city; } - public void setCity(City city) { - this.city = city; - } - public String getCod() { return cod; } - public void setCod(String cod) { - this.cod = cod; - } - public Double getMessage() { return message; } - public void setMessage(Double message) { - this.message = message; - } - public Integer getCnt() { return cnt; } - public void setCnt(Integer cnt) { - this.cnt = cnt; - } - public java.util.List getList() { return list; } - - public void setList(java.util.List list) { - this.list = list; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonHourlyForecastData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonHourlyForecastData.java index 8c21fa0230f..7c7b0441d86 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonHourlyForecastData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonHourlyForecastData.java @@ -16,8 +16,9 @@ import org.openhab.binding.openweathermap.internal.dto.base.City; import org.openhab.binding.openweathermap.internal.dto.forecast.hourly.List; /** - * The {@link OpenWeatherMapJsonHourlyForecastData} is the Java class used to map the JSON response to an OpenWeatherMap - * request. + * Holds the data from the deserialised JSON response of the + * Hourly forecast API and the + * 5 day weather forecast API. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonUVIndexData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonUVIndexData.java deleted file mode 100644 index 5ca61d8277a..00000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonUVIndexData.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.openweathermap.internal.dto; - -import com.google.gson.annotations.SerializedName; - -/** - * The {@link OpenWeatherMapJsonUVIndexData} is the Java class used to map the JSON response to an OpenWeatherMap - * request. - * - * @author Christoph Weitkamp - Initial contribution - */ -public class OpenWeatherMapJsonUVIndexData { - private Double lat; - private Double lon; - @SerializedName("date_iso") - private String dateIso; - private Integer date; - private Double value; - - public Double getLat() { - return lat; - } - - public void setLat(Double lat) { - this.lat = lat; - } - - public Double getLon() { - return lon; - } - - public void setLon(Double lon) { - this.lon = lon; - } - - public String getDateIso() { - return dateIso; - } - - public void setDateIso(String dateIso) { - this.dateIso = dateIso; - } - - public Integer getDate() { - return date; - } - - public void setDate(Integer date) { - this.date = date; - } - - public Double getValue() { - return value; - } - - public void setValue(Double value) { - this.value = value; - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java index 3378fbcdb95..6f9af2ae2bf 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapJsonWeatherData.java @@ -24,8 +24,8 @@ import org.openhab.binding.openweathermap.internal.dto.weather.Main; import org.openhab.binding.openweathermap.internal.dto.weather.Sys; /** - * The {@link OpenWeatherMapJsonWeatherData} is the Java class used to map the JSON response to an OpenWeatherMap - * request. + * Holds the data from the deserialised JSON response of the Current + * weather data API * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallAPIData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallAPIData.java index aa751896fee..cf3b26334ff 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallAPIData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallAPIData.java @@ -24,12 +24,9 @@ import org.openhab.binding.openweathermap.internal.dto.onecall.Minutely; import com.google.gson.annotations.SerializedName; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the deserialised JSON response of the One Call APIs. + * See One Call API 3.0. and + * One Call API 2.5. * * @author Wolfgang Klimt - Initial contribution * @author Christoph Weitkamp - Added weather alerts @@ -51,63 +48,31 @@ public class OpenWeatherMapOneCallAPIData { return lat; } - public void setLat(double lat) { - this.lat = lat; - } - public double getLon() { return lon; } - public void setLon(double lon) { - this.lon = lon; - } - public String getTimezone() { return timezone; } - public void setTimezone(String timezone) { - this.timezone = timezone; - } - public int getTimezoneOffset() { return timezoneOffset; } - public void setTimezoneOffset(int timezoneOffset) { - this.timezoneOffset = timezoneOffset; - } - public Current getCurrent() { return current; } - public void setCurrent(Current current) { - this.current = current; - } - public List getMinutely() { return minutely; } - public void setMinutely(List minutely) { - this.minutely = minutely; - } - public List getHourly() { return hourly; } - public void setHourly(List hourly) { - this.hourly = hourly; - } - public List getDaily() { return daily; } - - public void setDaily(List daily) { - this.daily = daily; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallHistAPIData.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallHistAPIData.java index e92a9804d3d..6efafe12e49 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallHistAPIData.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/OpenWeatherMapOneCallHistAPIData.java @@ -20,12 +20,9 @@ import org.openhab.binding.openweathermap.internal.dto.onecallhist.Hourly; import com.google.gson.annotations.SerializedName; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the historical data from the deserialised JSON response of the One Call APIs. + * See One Call API 3.0. and + * One Call API 2.5. * * @author Wolfgang Klimt - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Components.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Components.java index ade8fcd5a01..73ae37f119b 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Components.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Components.java @@ -15,7 +15,7 @@ package org.openhab.binding.openweathermap.internal.dto.airpollution; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link Components} from JSON. + * Holds the data from the components object of the JSON response of the Air Pollution API. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/List.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/List.java index 5e86e5d4b9b..9df66afafa3 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/List.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/List.java @@ -15,7 +15,7 @@ package org.openhab.binding.openweathermap.internal.dto.airpollution; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link List} from JSON. + * Holds the data from the list object of the JSON response of the Air Pollution API. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Main.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Main.java index ac80038b02d..bbca1a37f1d 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Main.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/airpollution/Main.java @@ -15,7 +15,7 @@ package org.openhab.binding.openweathermap.internal.dto.airpollution; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link Main} from JSON. + * Holds the data from the main object of the JSON response of the Air Pollution API. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/City.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/City.java index 76a90f43463..2074cf51f45 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/City.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/City.java @@ -28,39 +28,19 @@ public class City { return id; } - public void setId(Integer id) { - this.id = id; - } - public String getName() { return name; } - public void setName(String name) { - this.name = name; - } - public Coord getCoord() { return coord; } - public void setCoord(Coord coord) { - this.coord = coord; - } - public String getCountry() { return country; } - public void setCountry(String country) { - this.country = country; - } - public Integer getPopulation() { return population; } - - public void setPopulation(Integer population) { - this.population = population; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Clouds.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Clouds.java index b2cf854fc7f..6f10f3c75e4 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Clouds.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Clouds.java @@ -23,8 +23,4 @@ public class Clouds { public Integer getAll() { return all; } - - public void setAll(Integer all) { - this.all = all; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Coord.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Coord.java index b2cbbbefa38..e24f6dc6920 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Coord.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Coord.java @@ -13,7 +13,7 @@ package org.openhab.binding.openweathermap.internal.dto.base; /** - * Generated Plain Old Java Objects class for {@link Coord} from JSON. + * Holds the data from the coord object of the JSON response. * * @author Christoph Weitkamp - Initial contribution */ @@ -25,15 +25,7 @@ public class Coord { return lon; } - public void setLon(Double lon) { - this.lon = lon; - } - public Double getLat() { return lat; } - - public void setLat(Double lat) { - this.lat = lat; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Precipitation.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Precipitation.java index 65574a9833c..ad0cb40bc64 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Precipitation.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Precipitation.java @@ -31,18 +31,10 @@ public class Precipitation { return oneHour; } - public void set1h(Double oneHour) { - this.oneHour = oneHour; - } - public @Nullable Double get3h() { return threeHours; } - public void set3h(Double threeHours) { - this.threeHours = threeHours; - } - public Double getVolume() { return oneHour != null ? oneHour : threeHours != null ? threeHours / 3 : 0; } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Weather.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Weather.java index d6cd231a3f4..e6f596ba095 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Weather.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Weather.java @@ -27,31 +27,15 @@ public class Weather { return id; } - public void setId(Integer id) { - this.id = id; - } - public String getMain() { return main; } - public void setMain(String main) { - this.main = main; - } - public String getDescription() { return description; } - public void setDescription(String description) { - this.description = description; - } - public String getIcon() { return icon; } - - public void setIcon(String icon) { - this.icon = icon; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Wind.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Wind.java index 9c14c40fe46..d70c89f9862 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Wind.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/base/Wind.java @@ -28,23 +28,11 @@ public class Wind { return speed; } - public void setSpeed(Double speed) { - this.speed = speed; - } - public Double getDeg() { return deg; } - public void setDeg(Double deg) { - this.deg = deg; - } - public @Nullable Double getGust() { return gust; } - - public void setGust(Double gust) { - this.gust = speed; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/FeelsLikeTemp.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/FeelsLikeTemp.java index ba314385d6f..0c0575ea865 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/FeelsLikeTemp.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/FeelsLikeTemp.java @@ -13,7 +13,7 @@ package org.openhab.binding.openweathermap.internal.dto.forecast.daily; /** - * Generated Plain Old Java Objects class for {@link FeelsLikeTemp} from JSON. + * Holds the data from the feels_like object of the JSON response of the Daily Forecast 16 Days API. * * @author Christoph Weitkamp - Initial contribution */ @@ -27,31 +27,15 @@ public class FeelsLikeTemp { return day; } - public void setDay(Double day) { - this.day = day; - } - public Double getNight() { return night; } - public void setNight(Double night) { - this.night = night; - } - public Double getEve() { return eve; } - public void setEve(Double eve) { - this.eve = eve; - } - public Double getMorn() { return morn; } - - public void setMorn(Double morn) { - this.morn = morn; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java index 47f853d3027..f783c951aac 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/List.java @@ -18,7 +18,7 @@ import org.openhab.binding.openweathermap.internal.dto.base.Weather; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link List} from JSON. + * Holds the data from the list object of the JSON response of the Daily Forecast 16 Days API. * * @author Christoph Weitkamp - Initial contribution */ @@ -44,119 +44,59 @@ public class List { return dt; } - public void setDt(Integer dt) { - this.dt = dt; - } - public @Nullable Integer getSunrise() { return sunrise; } - public void setSunrise(Integer sunrise) { - this.sunrise = sunrise; - } - public @Nullable Integer getSunset() { return sunset; } - public void setSunset(Integer sunset) { - this.sunset = sunset; - } - public Temp getTemp() { return temp; } - public void setTemp(Temp temp) { - this.temp = temp; - } - public @Nullable FeelsLikeTemp getFeelsLike() { return feelsLikeTemp; } - public void setFeelsLike(FeelsLikeTemp feelsLikeTemp) { - this.feelsLikeTemp = feelsLikeTemp; - } - public Double getPressure() { return pressure; } - public void setPressure(Double pressure) { - this.pressure = pressure; - } - public Integer getHumidity() { return humidity; } - public void setHumidity(Integer humidity) { - this.humidity = humidity; - } - public java.util.List getWeather() { return weather; } - public void setWeather(java.util.List weather) { - this.weather = weather; - } - public Double getSpeed() { return speed; } - public void setSpeed(Double speed) { - this.speed = speed; - } - public Double getDeg() { return deg; } - public void setDeg(Double deg) { - this.deg = deg; - } - public @Nullable Double getGust() { return gust; } - public void setGust(Double gust) { - this.gust = speed; - } - public Integer getClouds() { return clouds; } - public void setClouds(Integer clouds) { - this.clouds = clouds; - } - public @Nullable Double getRain() { return rain; } - public void setRain(Double rain) { - this.rain = rain; - } - public @Nullable Double getSnow() { return snow; } - public void setSnow(Double snow) { - this.snow = snow; - } - public @Nullable Double getPop() { return pop; } - - public void setPop(Double pop) { - this.pop = pop; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/Temp.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/Temp.java index e9d16f52c5f..19109080eb9 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/Temp.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/daily/Temp.java @@ -13,7 +13,7 @@ package org.openhab.binding.openweathermap.internal.dto.forecast.daily; /** - * Generated Plain Old Java Objects class for {@link Temp} from JSON. + * Holds the data from the temp object of the JSON response of the Daily Forecast 16 Days API. * * @author Christoph Weitkamp - Initial contribution */ @@ -29,47 +29,23 @@ public class Temp { return day; } - public void setDay(Double day) { - this.day = day; - } - public Double getMin() { return min; } - public void setMin(Double min) { - this.min = min; - } - public Double getMax() { return max; } - public void setMax(Double max) { - this.max = max; - } - public Double getNight() { return night; } - public void setNight(Double night) { - this.night = night; - } - public Double getEve() { return eve; } - public void setEve(Double eve) { - this.eve = eve; - } - public Double getMorn() { return morn; } - - public void setMorn(Double morn) { - this.morn = morn; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java index 5fd3f2c05b8..9c6bfe33fcc 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/List.java @@ -22,7 +22,8 @@ import org.openhab.binding.openweathermap.internal.dto.weather.Main; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link List} from JSON. + * Holds the data from the list object of the JSON response of the Hourly forecast API and the 5 day + * weather forecast API. * * @author Christoph Weitkamp - Initial contribution */ @@ -42,71 +43,35 @@ public class List { return dt; } - public void setDt(Integer dt) { - this.dt = dt; - } - public Main getMain() { return main; } - public void setMain(Main main) { - this.main = main; - } - public java.util.List getWeather() { return weather; } - public void setWeather(java.util.List weather) { - this.weather = weather; - } - public Clouds getClouds() { return clouds; } - public void setClouds(Clouds clouds) { - this.clouds = clouds; - } - public Wind getWind() { return wind; } - public void setWind(Wind wind) { - this.wind = wind; - } - public @Nullable Precipitation getRain() { return rain; } - public void setRain(Precipitation rain) { - this.rain = rain; - } - public @Nullable Precipitation getSnow() { return snow; } - public void setSnow(Precipitation snow) { - this.snow = snow; - } - public Sys getSys() { return sys; } - public void setSys(Sys sys) { - this.sys = sys; - } - public String getDtTxt() { return dtTxt; } - - public void setDtTxt(String dtTxt) { - this.dtTxt = dtTxt; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Main.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Main.java index 149fabf03a9..15670419dd0 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Main.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Main.java @@ -17,7 +17,8 @@ import org.eclipse.jdt.annotation.Nullable; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link Main} from JSON. + * Holds the data from the main object of the JSON response of the Hourly forecast API and the 5 day + * weather forecast API. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Sys.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Sys.java index ae85505785d..620d5e61da5 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Sys.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/forecast/hourly/Sys.java @@ -13,7 +13,8 @@ package org.openhab.binding.openweathermap.internal.dto.forecast.hourly; /** - * Generated Plain Old Java Objects class for {@link Sys} from JSON. + * Holds the data from the pod object of the JSON response of the Hourly forecast API and the 5 day weather + * forecast API. * * @author Christoph Weitkamp - Initial contribution */ diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Alert.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Alert.java index 08510b4ea97..70327de91cb 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Alert.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Alert.java @@ -15,15 +15,35 @@ package org.openhab.binding.openweathermap.internal.dto.onecall; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link Alert} from JSON. + * Holds the data from the alerts object of the JSON response of the One Call APIs. * * @author Christoph Weitkamp - Initial contribution */ public class Alert { - public String event; - public int start; - public int end; - public String description; + private String event; + private int start; + private int end; + private String description; @SerializedName("sender_name") - public String senderName; + private String senderName; + + public String getEvent() { + return event; + } + + public int getStart() { + return start; + } + + public int getEnd() { + return end; + } + + public String getDescription() { + return description; + } + + public String getSenderName() { + return senderName; + } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java index d6f360c0c59..46a43d18a41 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Current.java @@ -17,12 +17,7 @@ import java.util.List; import com.google.gson.annotations.SerializedName; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the current object of the JSON response of the One Call APIs. * * @author Wolfgang Klimt - Initial contribution */ @@ -54,135 +49,67 @@ public class Current { return dt; } - public void setDt(int dt) { - this.dt = dt; - } - public int getSunrise() { return sunrise; } - public void setSunrise(int sunrise) { - this.sunrise = sunrise; - } - public int getSunset() { return sunset; } - public void setSunset(int sunset) { - this.sunset = sunset; - } - public double getTemp() { return temp; } - public void setTemp(double temp) { - this.temp = temp; - } - public double getFeelsLike() { return feelsLike; } - public void setFeelsLike(double feelsLike) { - this.feelsLike = feelsLike; - } - public int getPressure() { return pressure; } - public void setPressure(int pressure) { - this.pressure = pressure; - } - public int getHumidity() { return humidity; } - public void setHumidity(int humidity) { - this.humidity = humidity; - } - public double getDewPoint() { return dewPoint; } - public void setDewPoint(double dewPoint) { - this.dewPoint = dewPoint; - } - public double getUvi() { return uvi; } - public void setUvi(double uvi) { - this.uvi = uvi; - } - public int getClouds() { return clouds; } - public void setClouds(int clouds) { - this.clouds = clouds; - } - public int getVisibility() { return visibility; } - public void setVisibility(int visibility) { - this.visibility = visibility; - } - public double getWindSpeed() { return windSpeed; } - public void setWindSpeed(double windSpeed) { - this.windSpeed = windSpeed; - } - public int getWindDeg() { return windDeg; } - public void setWindDeg(int windDeg) { - this.windDeg = windDeg; - } - public double getWindGust() { return windGust; } - public void setWindGust(double windGust) { - this.windGust = windGust; - } - public List getWeather() { return weather; } - public void setWeather(List weather) { - this.weather = weather; - } - public Precipitation getRain() { return rain; } - public void setRain(Precipitation rain) { - this.rain = rain; - } - public Precipitation getSnow() { return snow; } - - public void setSnow(Precipitation snow) { - this.snow = snow; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java index bb5a6775d74..edf312c7d8f 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Daily.java @@ -20,12 +20,7 @@ import org.openhab.binding.openweathermap.internal.dto.forecast.daily.Temp; import com.google.gson.annotations.SerializedName; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the daily object of the JSON response of the One Call APIs. * * @author Wolfgang Klimt - Initial contribution */ @@ -58,143 +53,71 @@ public class Daily { return dt; } - public void setDt(int dt) { - this.dt = dt; - } - public int getSunrise() { return sunrise; } - public void setSunrise(int sunrise) { - this.sunrise = sunrise; - } - public int getSunset() { return sunset; } - public void setSunset(int sunset) { - this.sunset = sunset; - } - public Temp getTemp() { return temp; } - public void setTemp(Temp temp) { - this.temp = temp; - } - public FeelsLikeTemp getFeelsLike() { return feelsLikeTemp; } - public void setFeelsLike(FeelsLikeTemp feelsLikeTemp) { - this.feelsLikeTemp = feelsLikeTemp; - } - public int getPressure() { return pressure; } - public void setPressure(int pressure) { - this.pressure = pressure; - } - public int getHumidity() { return humidity; } - public void setHumidity(int humidity) { - this.humidity = humidity; - } - public double getDewPoint() { return dewPoint; } - public void setDewPoint(double dewPoint) { - this.dewPoint = dewPoint; - } - public double getWindSpeed() { return windSpeed; } - public void setWindSpeed(double windSpeed) { - this.windSpeed = windSpeed; - } - public int getWindDeg() { return windDeg; } - public void setWindDeg(int windDeg) { - this.windDeg = windDeg; - } - public double getWindGust() { return windGust; } - public void setWindGust(double windGust) { - this.windGust = windGust; - } - public List getWeather() { return weather; } - public void setWeather(List weather) { - this.weather = weather; - } - public int getClouds() { return clouds; } - public void setClouds(int clouds) { - this.clouds = clouds; - } - public double getPop() { return pop; } - public void setPop(double pop) { - this.pop = pop; - } - public double getRain() { return rain; } - public void setRain(double rain) { - this.rain = rain; - } - public double getUvi() { return uvi; } - public void setUvi(double uvi) { - this.uvi = uvi; - } - public int getVisibility() { return visibility; } - public void setVisibility(int visibility) { - this.visibility = visibility; - } - public double getSnow() { return snow; } - - public void setSnow(double snow) { - this.snow = snow; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java index d6ca539988d..146c16d3261 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Hourly.java @@ -17,12 +17,7 @@ import java.util.List; import com.google.gson.annotations.SerializedName; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the hourly object of the JSON response of the One Call APIs. * * @author Wolfgang Klimt - Initial contribution */ @@ -52,119 +47,59 @@ public class Hourly { return dt; } - public void setDt(int dt) { - this.dt = dt; - } - public double getTemp() { return temp; } - public void setTemp(double temp) { - this.temp = temp; - } - public double getFeelsLike() { return feelsLike; } - public void setFeelsLike(double feelsLike) { - this.feelsLike = feelsLike; - } - public int getPressure() { return pressure; } - public void setPressure(int pressure) { - this.pressure = pressure; - } - public int getHumidity() { return humidity; } - public void setHumidity(int humidity) { - this.humidity = humidity; - } - public double getDewPoint() { return dewPoint; } - public void setDewPoint(double dewPoint) { - this.dewPoint = dewPoint; - } - public int getClouds() { return clouds; } - public void setClouds(int clouds) { - this.clouds = clouds; - } - public int getVisibility() { return visibility; } - public void setVisibility(int visibility) { - this.visibility = visibility; - } - public double getWindSpeed() { return windSpeed; } - public void setWindSpeed(double windSpeed) { - this.windSpeed = windSpeed; - } - public int getWindDeg() { return windDeg; } - public void setWindDeg(int windDeg) { - this.windDeg = windDeg; - } - public double getWindGust() { return windGust; } - public void setWindGust(double windGust) { - this.windGust = windGust; - } - public List getWeather() { return weather; } - public void setWeather(List weather) { - this.weather = weather; - } - public double getPop() { return pop; } - public void setPop(double pop) { - this.pop = pop; - } - public Precipitation getRain() { return rain; } - public void setRain(Precipitation rain) { - this.rain = rain; - } - public Precipitation getSnow() { return snow; } - - public void setSnow(Precipitation snow) { - this.snow = snow; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java index ceceff34678..2d1fb4e8578 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Minutely.java @@ -13,12 +13,7 @@ package org.openhab.binding.openweathermap.internal.dto.onecall; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the minutely object of the JSON response of the One Call APIs. * * @author Wolfgang Klimt - Initial contribution */ @@ -30,15 +25,7 @@ public class Minutely { return dt; } - public void setDt(int dt) { - this.dt = dt; - } - public double getPrecipitation() { return precipitation; } - - public void setPrecipitation(double precipitation) { - this.precipitation = precipitation; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Precipitation.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Precipitation.java index 08b1aa10c07..ce3ae10bd38 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Precipitation.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Precipitation.java @@ -15,12 +15,7 @@ package org.openhab.binding.openweathermap.internal.dto.onecall; import com.google.gson.annotations.SerializedName; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the rain and snow object of the JSON response of the One Call APIs. * * @author Wolfgang Klimt - Initial contribution */ @@ -31,8 +26,4 @@ public class Precipitation { public double get1h() { return oneHour; } - - public void set1h(double oneHour) { - this.oneHour = oneHour; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java index b9a7afdd20e..64847db1d8f 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecall/Weather.java @@ -13,12 +13,7 @@ package org.openhab.binding.openweathermap.internal.dto.onecall; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the weather object of the JSON response of the One Call APIs. * * @author Wolfgang Klimt - Initial contribution */ @@ -32,31 +27,15 @@ public class Weather { return id; } - public void setId(int id) { - this.id = id; - } - public String getMain() { return main; } - public void setMain(String main) { - this.main = main; - } - public String getDescription() { return description; } - public void setDescription(String description) { - this.description = description; - } - public String getIcon() { return icon; } - - public void setIcon(String icon) { - this.icon = icon; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java index 4091ae8908f..f6c4e374983 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/onecallhist/Hourly.java @@ -20,12 +20,7 @@ import org.openhab.binding.openweathermap.internal.dto.onecall.Weather; import com.google.gson.annotations.SerializedName; /** - * Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/. - * Settings: - * Annotation Style: GSON - * Use primitive types - * Use double numbers - * allow additional properties + * Holds the data from the JSON response of the One Call History APIs. * * @author Wolfgang Klimt - Initial contribution */ @@ -54,111 +49,55 @@ public class Hourly { return dt; } - public void setDt(int dt) { - this.dt = dt; - } - public double getTemp() { return temp; } - public void setTemp(double temp) { - this.temp = temp; - } - public double getFeelsLike() { return feelsLike; } - public void setFeelsLike(double feelsLike) { - this.feelsLike = feelsLike; - } - public int getPressure() { return pressure; } - public void setPressure(int pressure) { - this.pressure = pressure; - } - public int getHumidity() { return humidity; } - public void setHumidity(int humidity) { - this.humidity = humidity; - } - public double getDewPoint() { return dewPoint; } - public void setDewPoint(double dewPoint) { - this.dewPoint = dewPoint; - } - public int getClouds() { return clouds; } - public void setClouds(int clouds) { - this.clouds = clouds; - } - public int getVisibility() { return visibility; } - public void setVisibility(int visibility) { - this.visibility = visibility; - } - public double getWindSpeed() { return windSpeed; } - public void setWindSpeed(double windSpeed) { - this.windSpeed = windSpeed; - } - public int getWindDeg() { return windDeg; } - public void setWindDeg(int windDeg) { - this.windDeg = windDeg; - } - public double getWindGust() { return windGust; } - public void setWindGust(double windGust) { - this.windGust = windGust; - } - public List getWeather() { return weather; } - public void setWeather(List weather) { - this.weather = weather; - } - public Precipitation getRain() { return rain; } - public void setRain(Precipitation rain) { - this.rain = rain; - } - public Precipitation getSnow() { return snow; } - - public void setSnow(Precipitation snow) { - this.snow = snow; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Main.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Main.java index 94d9fcde0eb..2223179f65f 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Main.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Main.java @@ -17,7 +17,7 @@ import org.eclipse.jdt.annotation.Nullable; import com.google.gson.annotations.SerializedName; /** - * Generated Plain Old Java Objects class for {@link Main} from JSON. + * Holds the data from the main object of the JSON response of the Current weather data API. * * @author Christoph Weitkamp - Initial contribution */ @@ -36,47 +36,23 @@ public class Main { return temp; } - public void setTemp(Double temp) { - this.temp = temp; - } - public @Nullable Double getFeelsLikeTemp() { return feelsLikeTemp; } - public void setFeelsLikeTemp(Double feelsLikeTemp) { - this.feelsLikeTemp = feelsLikeTemp; - } - public Double getPressure() { return pressure; } - public void setPressure(Double pressure) { - this.pressure = pressure; - } - public Integer getHumidity() { return humidity; } - public void setHumidity(Integer humidity) { - this.humidity = humidity; - } - public Double getTempMin() { return tempMin; } - public void setTempMin(Double tempMin) { - this.tempMin = tempMin; - } - public Double getTempMax() { return tempMax; } - - public void setTempMax(Double tempMax) { - this.tempMax = tempMax; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Sys.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Sys.java index 011db4af214..65fab415fcf 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Sys.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/dto/weather/Sys.java @@ -13,7 +13,7 @@ package org.openhab.binding.openweathermap.internal.dto.weather; /** - * Generated Plain Old Java Objects class for {@link Sys} from JSON. + * Holds the data from the sys object of the JSON response of the Current weather data API. * * @author Christoph Weitkamp - Initial contribution */ @@ -29,47 +29,23 @@ public class Sys { return type; } - public void setType(Integer type) { - this.type = type; - } - public Integer getId() { return id; } - public void setId(Integer id) { - this.id = id; - } - public Double getMessage() { return message; } - public void setMessage(Double message) { - this.message = message; - } - public String getCountry() { return country; } - public void setCountry(String country) { - this.country = country; - } - public Integer getSunrise() { return sunrise; } - public void setSunrise(Integer sunrise) { - this.sunrise = sunrise; - } - public Integer getSunset() { return sunset; } - - public void setSunset(Integer sunset) { - this.sunset = sunset; - } } diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/factory/OpenWeatherMapHandlerFactory.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/factory/OpenWeatherMapHandlerFactory.java index 31f74cd341b..44857d1651f 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/factory/OpenWeatherMapHandlerFactory.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/factory/OpenWeatherMapHandlerFactory.java @@ -30,7 +30,6 @@ import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapAPIHand import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapAirPollutionHandler; import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapOneCallHandler; import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapOneCallHistoryHandler; -import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapUVIndexHandler; import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapWeatherAndForecastHandler; import org.openhab.core.config.discovery.DiscoveryService; import org.openhab.core.i18n.LocaleProvider; @@ -100,8 +99,6 @@ public class OpenWeatherMapHandlerFactory extends BaseThingHandlerFactory { return handler; } else if (THING_TYPE_WEATHER_AND_FORECAST.equals(thingTypeUID)) { return new OpenWeatherMapWeatherAndForecastHandler(thing, timeZoneProvider); - } else if (THING_TYPE_UVINDEX.equals(thingTypeUID)) { - return new OpenWeatherMapUVIndexHandler(thing, timeZoneProvider); } else if (THING_TYPE_AIR_POLLUTION.equals(thingTypeUID)) { return new OpenWeatherMapAirPollutionHandler(thing, timeZoneProvider); } else if (THING_TYPE_ONECALL_WEATHER_AND_FORECAST.equals(thingTypeUID)) { diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java index eca9ca7e76a..846ca2554b6 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/AbstractOpenWeatherMapHandler.java @@ -67,8 +67,7 @@ public abstract class AbstractOpenWeatherMapHandler extends BaseThingHandler { private final Logger logger = LoggerFactory.getLogger(AbstractOpenWeatherMapHandler.class); public static final Set SUPPORTED_THING_TYPES = Set.of(THING_TYPE_WEATHER_AND_FORECAST, - THING_TYPE_UVINDEX, THING_TYPE_AIR_POLLUTION, THING_TYPE_ONECALL_WEATHER_AND_FORECAST, - THING_TYPE_ONECALL_HISTORY); + THING_TYPE_AIR_POLLUTION, THING_TYPE_ONECALL_WEATHER_AND_FORECAST, THING_TYPE_ONECALL_HISTORY); private final TimeZoneProvider timeZoneProvider; diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java index b86e4ebee2c..80bf8c5dd8c 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java +++ b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapOneCallHandler.java @@ -809,19 +809,19 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler Alert alert = alerts.get(count); switch (channelId) { case CHANNEL_ALERT_EVENT: - state = getStringTypeState(alert.event); + state = getStringTypeState(alert.getEvent()); break; case CHANNEL_ALERT_DESCRIPTION: - state = getStringTypeState(alert.description); + state = getStringTypeState(alert.getDescription()); break; case CHANNEL_ALERT_ONSET: - state = getDateTimeTypeState(alert.start); + state = getDateTimeTypeState(alert.getStart()); break; case CHANNEL_ALERT_EXPIRES: - state = getDateTimeTypeState(alert.end); + state = getDateTimeTypeState(alert.getEnd()); break; case CHANNEL_ALERT_SOURCE: - state = getStringTypeState(alert.senderName); + state = getStringTypeState(alert.getSenderName()); break; } logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state); diff --git a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapUVIndexHandler.java b/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapUVIndexHandler.java deleted file mode 100644 index 4f24a4ecd7f..00000000000 --- a/bundles/org.openhab.binding.openweathermap/src/main/java/org/openhab/binding/openweathermap/internal/handler/OpenWeatherMapUVIndexHandler.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Copyright (c) 2010-2024 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.openweathermap.internal.handler; - -import static org.openhab.binding.openweathermap.internal.OpenWeatherMapBindingConstants.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import org.eclipse.jdt.annotation.NonNullByDefault; -import org.eclipse.jdt.annotation.Nullable; -import org.openhab.binding.openweathermap.internal.config.OpenWeatherMapUVIndexConfiguration; -import org.openhab.binding.openweathermap.internal.connection.OpenWeatherMapConnection; -import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonUVIndexData; -import org.openhab.core.i18n.CommunicationException; -import org.openhab.core.i18n.ConfigurationException; -import org.openhab.core.i18n.TimeZoneProvider; -import org.openhab.core.thing.Channel; -import org.openhab.core.thing.ChannelUID; -import org.openhab.core.thing.Thing; -import org.openhab.core.thing.ThingStatus; -import org.openhab.core.thing.ThingStatusDetail; -import org.openhab.core.thing.binding.builder.ThingBuilder; -import org.openhab.core.types.State; -import org.openhab.core.types.UnDefType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import com.google.gson.JsonSyntaxException; - -/** - * The {@link OpenWeatherMapUVIndexHandler} is responsible for handling commands, which are sent to one of the - * channels. - * - * @author Christoph Weitkamp - Initial contribution - */ -@NonNullByDefault -public class OpenWeatherMapUVIndexHandler extends AbstractOpenWeatherMapHandler { - - private final Logger logger = LoggerFactory.getLogger(OpenWeatherMapUVIndexHandler.class); - - private static final String CHANNEL_GROUP_FORECAST_PREFIX = "forecastDay"; - private static final Pattern CHANNEL_GROUP_FORECAST_PREFIX_PATTERN = Pattern - .compile(CHANNEL_GROUP_FORECAST_PREFIX + "([0-9]*)"); - - // keeps track of the parsed count - private int forecastDays = 6; - - private @Nullable OpenWeatherMapJsonUVIndexData uvindexData; - private @Nullable List uvindexForecastData; - - public OpenWeatherMapUVIndexHandler(Thing thing, final TimeZoneProvider timeZoneProvider) { - super(thing, timeZoneProvider); - } - - @Override - public void initialize() { - super.initialize(); - logger.debug("Initialize OpenWeatherMapUVIndexHandler handler '{}'.", getThing().getUID()); - OpenWeatherMapUVIndexConfiguration config = getConfigAs(OpenWeatherMapUVIndexConfiguration.class); - - boolean configValid = true; - int newForecastDays = config.forecastDays; - if (newForecastDays < 1 || newForecastDays > 8) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, - "@text/offline.conf-error-not-supported-uvindex-number-of-days"); - configValid = false; - } - - if (configValid) { - logger.debug("Rebuilding thing '{}'.", getThing().getUID()); - List toBeAddedChannels = new ArrayList<>(); - List toBeRemovedChannels = new ArrayList<>(); - if (forecastDays != newForecastDays) { - logger.debug("Rebuilding UV index channel groups."); - if (forecastDays > newForecastDays) { - if (newForecastDays < 2) { - toBeRemovedChannels.addAll(removeChannelsOfGroup(CHANNEL_GROUP_FORECAST_TOMORROW)); - } - for (int i = newForecastDays; i < forecastDays; ++i) { - toBeRemovedChannels - .addAll(removeChannelsOfGroup(CHANNEL_GROUP_FORECAST_PREFIX + Integer.toString(i))); - } - } else { - if (forecastDays <= 1 && newForecastDays > 1) { - toBeAddedChannels.addAll(createChannelsForGroup(CHANNEL_GROUP_FORECAST_TOMORROW, - CHANNEL_GROUP_TYPE_UVINDEX_FORECAST)); - } - for (int i = (forecastDays < 2) ? 2 : forecastDays; i < newForecastDays; ++i) { - toBeAddedChannels - .addAll(createChannelsForGroup(CHANNEL_GROUP_FORECAST_PREFIX + Integer.toString(i), - CHANNEL_GROUP_TYPE_UVINDEX_FORECAST)); - } - } - forecastDays = newForecastDays; - } - ThingBuilder builder = editThing().withoutChannels(toBeRemovedChannels); - for (Channel channel : toBeAddedChannels) { - builder.withChannel(channel); - } - updateThing(builder.build()); - } - } - - @Override - protected boolean requestData(OpenWeatherMapConnection connection) - throws CommunicationException, ConfigurationException { - logger.debug("Update UV Index data of thing '{}'.", getThing().getUID()); - try { - uvindexData = connection.getUVIndexData(location); - if (forecastDays > 0) { - uvindexForecastData = connection.getUVIndexForecastData(location, forecastDays); - } - return true; - } catch (JsonSyntaxException e) { - logger.debug("JsonSyntaxException occurred during execution: {}", e.getMessage(), e); - return false; - } - } - - @Override - protected void updateChannel(ChannelUID channelUID) { - switch (channelUID.getGroupId()) { - case CHANNEL_GROUP_CURRENT_UVINDEX: - updateUVIndexChannel(channelUID); - break; - case CHANNEL_GROUP_FORECAST_TOMORROW: - updateUVIndexForecastChannel(channelUID, 1); - break; - default: - Matcher m = CHANNEL_GROUP_FORECAST_PREFIX_PATTERN.matcher(channelUID.getGroupId()); - int i; - if (m.find() && (i = Integer.parseInt(m.group(1))) > 1 && i <= 8) { - updateUVIndexForecastChannel(channelUID, i); - } - break; - } - } - - /** - * Update the channel from the last OpenWeatherMap data retrieved. - * - * @param channelUID the id identifying the channel to be updated - */ - private void updateUVIndexChannel(ChannelUID channelUID) { - String channelId = channelUID.getIdWithoutGroup(); - String channelGroupId = channelUID.getGroupId(); - OpenWeatherMapJsonUVIndexData localUVIndexData = uvindexData; - if (localUVIndexData != null) { - State state = UnDefType.UNDEF; - switch (channelId) { - case CHANNEL_TIME_STAMP: - state = getDateTimeTypeState(localUVIndexData.getDate()); - break; - case CHANNEL_UVINDEX: - state = getDecimalTypeState(localUVIndexData.getValue()); - break; - } - logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state); - updateState(channelUID, state); - } else { - logger.debug("No UV Index data available to update channel '{}' of group '{}'.", channelId, channelGroupId); - } - } - - /** - * Update the channel from the last OpenWeatherMap data retrieved. - * - * @param channelUID the id identifying the channel to be updated - * @param count - */ - private void updateUVIndexForecastChannel(ChannelUID channelUID, int count) { - String channelId = channelUID.getIdWithoutGroup(); - String channelGroupId = channelUID.getGroupId(); - List localUVIndexForecastData = uvindexForecastData; - if (localUVIndexForecastData != null && localUVIndexForecastData.size() >= count) { - OpenWeatherMapJsonUVIndexData forecastData = localUVIndexForecastData.get(count - 1); - State state = UnDefType.UNDEF; - switch (channelId) { - case CHANNEL_TIME_STAMP: - state = getDateTimeTypeState(forecastData.getDate()); - break; - case CHANNEL_UVINDEX: - state = getDecimalTypeState(forecastData.getValue()); - break; - } - logger.debug("Update channel '{}' of group '{}' with new state '{}'.", channelId, channelGroupId, state); - updateState(channelUID, state); - } else { - logger.debug("No UV Index data available to update channel '{}' of group '{}'.", channelId, channelGroupId); - } - } -} diff --git a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties index 8bc59e69b3a..9ed91981c85 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties +++ b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/i18n/openweathermap.properties @@ -27,18 +27,6 @@ thing-type.openweathermap.onecall.group.forecastToday.label = One Call API Today thing-type.openweathermap.onecall.group.forecastToday.description = This is the weather forecast for today from the one call API. thing-type.openweathermap.onecall.group.forecastTomorrow.label = One Call API Tomorrows Forecast thing-type.openweathermap.onecall.group.forecastTomorrow.description = This is the weather forecast for tomorrow from the one call API. -thing-type.openweathermap.uvindex.label = UV Index -thing-type.openweathermap.uvindex.description = Provides UV Index data from the OpenWeatherMap API. -thing-type.openweathermap.uvindex.group.forecastDay2.label = 2 Day Forecast -thing-type.openweathermap.uvindex.group.forecastDay2.description = This is the UV Index forecast in two days. -thing-type.openweathermap.uvindex.group.forecastDay3.label = 3 Day Forecast -thing-type.openweathermap.uvindex.group.forecastDay3.description = This is the UV Index forecast in three days. -thing-type.openweathermap.uvindex.group.forecastDay4.label = 4 Day Forecast -thing-type.openweathermap.uvindex.group.forecastDay4.description = This is the UV Index forecast in four days. -thing-type.openweathermap.uvindex.group.forecastDay5.label = 5 Day Forecast -thing-type.openweathermap.uvindex.group.forecastDay5.description = This is the UV Index forecast in five days. -thing-type.openweathermap.uvindex.group.forecastTomorrow.label = Tomorrows Forecast -thing-type.openweathermap.uvindex.group.forecastTomorrow.description = This is the UV Index forecast for tomorrow. thing-type.openweathermap.weather-and-forecast.label = Weather and Forecast thing-type.openweathermap.weather-and-forecast.description = Provides current weather and forecast data from the OpenWeatherMap API. thing-type.openweathermap.weather-and-forecast.group.forecastDay2.label = 2 Day Forecast @@ -146,10 +134,6 @@ thing-type.config.openweathermap.onecall.location.label = Location of Weather thing-type.config.openweathermap.onecall.location.description = Location of weather in geographical coordinates (latitude/longitude/altitude). thing-type.config.openweathermap.onecall.numberOfAlerts.label = Number of Alerts thing-type.config.openweathermap.onecall.numberOfAlerts.description = Number of alerts to be shown. -thing-type.config.openweathermap.uvindex.forecastDays.label = Number of Days -thing-type.config.openweathermap.uvindex.forecastDays.description = Number of days for UV Index forecast. -thing-type.config.openweathermap.uvindex.location.label = Location of Weather -thing-type.config.openweathermap.uvindex.location.description = Location of weather in geographical coordinates (latitude/longitude/altitude). thing-type.config.openweathermap.weather-and-forecast.forecastDays.label = Number of Days thing-type.config.openweathermap.weather-and-forecast.forecastDays.description = Number of days for daily forecast. thing-type.config.openweathermap.weather-and-forecast.forecastHours.label = Number of Hours @@ -190,10 +174,6 @@ channel-group-type.openweathermap.oneCallMinutelyTimeSeries.description = Minute channel-group-type.openweathermap.station.label = Weather Station channel-group-type.openweathermap.station.description = This is a weather station. channel-group-type.openweathermap.station.channel.location.description = Location of the weather station or the city. -channel-group-type.openweathermap.uvindex.label = Current UV Index -channel-group-type.openweathermap.uvindex.description = This is the current UV Index. -channel-group-type.openweathermap.uvindexForecast.label = Forecasted UV Index -channel-group-type.openweathermap.uvindexForecast.description = This is the forecasted UV Index. channel-group-type.openweathermap.weather.label = Current Weather channel-group-type.openweathermap.weather.description = This is the current weather. diff --git a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/channel-types.xml b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/channel-types.xml index 8b353c15245..67573a833d2 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/channel-types.xml +++ b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/channel-types.xml @@ -90,24 +90,6 @@ - - - This is the current UV Index. - - - - - - - - - This is the forecasted UV Index. - - - - - - This is the current air pollution. diff --git a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/thing-types.xml index bc9a2aad61b..041c2694644 100644 --- a/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.openweathermap/src/main/resources/OH-INF/thing/thing-types.xml @@ -79,43 +79,6 @@ - - - - - - - Provides UV Index data from the OpenWeatherMap API. - - - - - - This is the UV Index forecast for tomorrow. - - - - This is the UV Index forecast in two days. - - - - This is the UV Index forecast in three days. - - - - This is the UV Index forecast in four days. - - - - This is the UV Index forecast in five days. - - - - location - - - -