[openweathermap] Code cleanup (#12311)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2022-02-18 08:47:35 +01:00 committed by GitHub
parent b5e480bd30
commit bc7e01726f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 87 additions and 865 deletions

View File

@ -40,8 +40,8 @@ import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonDailyFo
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.onecall.OpenWeatherMapOneCallAPIData;
import org.openhab.binding.openweathermap.internal.dto.onecallhist.OpenWeatherMapOneCallHistAPIData;
import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallAPIData;
import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallHistAPIData;
import org.openhab.binding.openweathermap.internal.handler.OpenWeatherMapAPIHandler;
import org.openhab.core.cache.ByteArrayFileCache;
import org.openhab.core.cache.ExpiringCacheMap;

View File

@ -12,6 +12,7 @@
*/
package org.openhab.binding.openweathermap.internal.dto;
import org.openhab.binding.openweathermap.internal.dto.airpollution.List;
import org.openhab.binding.openweathermap.internal.dto.base.Coord;
/**
@ -22,5 +23,5 @@ import org.openhab.binding.openweathermap.internal.dto.base.Coord;
*/
public class OpenWeatherMapJsonAirPollutionData {
public Coord coord;
public java.util.List<org.openhab.binding.openweathermap.internal.dto.airpollution.List> list;
public java.util.List<List> list;
}

View File

@ -17,8 +17,7 @@ import java.util.List;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.openweathermap.internal.dto.base.Clouds;
import org.openhab.binding.openweathermap.internal.dto.base.Coord;
import org.openhab.binding.openweathermap.internal.dto.base.Rain;
import org.openhab.binding.openweathermap.internal.dto.base.Snow;
import org.openhab.binding.openweathermap.internal.dto.base.Precipitation;
import org.openhab.binding.openweathermap.internal.dto.base.Weather;
import org.openhab.binding.openweathermap.internal.dto.base.Wind;
import org.openhab.binding.openweathermap.internal.dto.weather.Main;
@ -38,8 +37,8 @@ public class OpenWeatherMapJsonWeatherData {
private @Nullable Integer visibility;
private Wind wind;
private Clouds clouds;
private @Nullable Rain rain;
private @Nullable Snow snow;
private @Nullable Precipitation rain;
private @Nullable Precipitation snow;
private Integer dt;
private Sys sys;
private Integer id;
@ -102,19 +101,19 @@ public class OpenWeatherMapJsonWeatherData {
this.clouds = clouds;
}
public @Nullable Rain getRain() {
public @Nullable Precipitation getRain() {
return rain;
}
public void setRain(Rain rain) {
public void setRain(Precipitation rain) {
this.rain = rain;
}
public @Nullable Snow getSnow() {
public @Nullable Precipitation getSnow() {
return snow;
}
public void setSnow(Snow snow) {
public void setSnow(Precipitation snow) {
this.snow = snow;
}

View File

@ -10,11 +10,16 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.openweathermap.internal.dto.onecall;
package org.openhab.binding.openweathermap.internal.dto;
import java.util.List;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.openweathermap.internal.dto.onecall.Alert;
import org.openhab.binding.openweathermap.internal.dto.onecall.Current;
import org.openhab.binding.openweathermap.internal.dto.onecall.Daily;
import org.openhab.binding.openweathermap.internal.dto.onecall.Hourly;
import org.openhab.binding.openweathermap.internal.dto.onecall.Minutely;
import com.google.gson.annotations.SerializedName;
@ -30,7 +35,6 @@ import com.google.gson.annotations.SerializedName;
* @author Christoph Weitkamp - Added weather alerts
*/
public class OpenWeatherMapOneCallAPIData {
private double lat;
private double lon;
private String timezone;

View File

@ -10,11 +10,13 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.openweathermap.internal.dto.onecallhist;
package org.openhab.binding.openweathermap.internal.dto;
import java.util.List;
import com.google.gson.annotations.Expose;
import org.openhab.binding.openweathermap.internal.dto.onecall.Current;
import org.openhab.binding.openweathermap.internal.dto.onecallhist.Hourly;
import com.google.gson.annotations.SerializedName;
/**
@ -28,24 +30,12 @@ import com.google.gson.annotations.SerializedName;
* @author Wolfgang Klimt - Initial contribution
*/
public class OpenWeatherMapOneCallHistAPIData {
@SerializedName("lat")
@Expose
private double lat;
@SerializedName("lon")
@Expose
private double lon;
@SerializedName("timezone")
@Expose
private String timezone;
@SerializedName("timezone_offset")
@Expose
private int timezoneOffset;
@SerializedName("current")
@Expose
private Current current;
@SerializedName("hourly")
@Expose
private List<Hourly> hourly = null;
public double getLat() {

View File

@ -17,11 +17,11 @@ import org.eclipse.jdt.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
/**
* Generated Plain Old Java Objects class for {@link Rain} from JSON.
* Generated Plain Old Java Objects class for {@link Precipitation} from JSON.
*
* @author Christoph Weitkamp - Initial contribution
*/
public class Rain {
public class Precipitation {
@SerializedName("1h")
private @Nullable Double oneHour;
@SerializedName("3h")

View File

@ -1,49 +0,0 @@
/**
* Copyright (c) 2010-2022 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.base;
import org.eclipse.jdt.annotation.Nullable;
import com.google.gson.annotations.SerializedName;
/**
* Generated Plain Old Java Objects class for {@link Snow} from JSON.
*
* @author Christoph Weitkamp - Initial contribution
*/
public class Snow {
@SerializedName("1h")
private @Nullable Double oneHour;
@SerializedName("3h")
private @Nullable Double threeHours;
public @Nullable Double get1h() {
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;
}
}

View File

@ -72,11 +72,11 @@ public class List {
this.temp = temp;
}
public @Nullable FeelsLikeTemp getFeelsLikeTemp() {
public @Nullable FeelsLikeTemp getFeelsLike() {
return feelsLikeTemp;
}
public void setFeelsLikeTemp(FeelsLikeTemp feelsLikeTemp) {
public void setFeelsLike(FeelsLikeTemp feelsLikeTemp) {
this.feelsLikeTemp = feelsLikeTemp;
}

View File

@ -14,8 +14,7 @@ package org.openhab.binding.openweathermap.internal.dto.forecast.hourly;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.openweathermap.internal.dto.base.Clouds;
import org.openhab.binding.openweathermap.internal.dto.base.Rain;
import org.openhab.binding.openweathermap.internal.dto.base.Snow;
import org.openhab.binding.openweathermap.internal.dto.base.Precipitation;
import org.openhab.binding.openweathermap.internal.dto.base.Weather;
import org.openhab.binding.openweathermap.internal.dto.base.Wind;
import org.openhab.binding.openweathermap.internal.dto.weather.Main;
@ -33,8 +32,8 @@ public class List {
private java.util.List<Weather> weather;
private Clouds clouds;
private Wind wind;
private @Nullable Rain rain;
private @Nullable Snow snow;
private @Nullable Precipitation rain;
private @Nullable Precipitation snow;
private Sys sys;
@SerializedName("dt_txt")
private String dtTxt;
@ -79,19 +78,19 @@ public class List {
this.wind = wind;
}
public @Nullable Rain getRain() {
public @Nullable Precipitation getRain() {
return rain;
}
public void setRain(Rain rain) {
public void setRain(Precipitation rain) {
this.rain = rain;
}
public @Nullable Snow getSnow() {
public @Nullable Precipitation getSnow() {
return snow;
}
public void setSnow(Snow snow) {
public void setSnow(Precipitation snow) {
this.snow = snow;
}

View File

@ -14,7 +14,6 @@ package org.openhab.binding.openweathermap.internal.dto.onecall;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
@ -28,58 +27,28 @@ import com.google.gson.annotations.SerializedName;
* @author Wolfgang Klimt - Initial contribution
*/
public class Current {
@SerializedName("dt")
@Expose
private int dt;
@SerializedName("sunrise")
@Expose
private int sunrise;
@SerializedName("sunset")
@Expose
private int sunset;
@SerializedName("temp")
@Expose
private double temp;
@SerializedName("feels_like")
@Expose
private double feelsLike;
@SerializedName("pressure")
@Expose
private int pressure;
@SerializedName("humidity")
@Expose
private int humidity;
@SerializedName("dew_point")
@Expose
private double dewPoint;
@SerializedName("uvi")
@Expose
private double uvi;
@SerializedName("clouds")
@Expose
private int clouds;
@SerializedName("visibility")
@Expose
private int visibility;
@SerializedName("wind_speed")
@Expose
private double windSpeed;
@SerializedName("wind_deg")
@Expose
private int windDeg;
@SerializedName("wind_gust")
@Expose
private double windGust;
@SerializedName("weather")
@Expose
private List<Weather> weather = null;
@SerializedName("rain")
@Expose
private Rain rain;
@SerializedName("snow")
@Expose
private Snow snow;
private Precipitation rain;
private Precipitation snow;
public int getDt() {
return dt;
@ -201,19 +170,19 @@ public class Current {
this.weather = weather;
}
public Rain getRain() {
public Precipitation getRain() {
return rain;
}
public void setRain(Rain rain) {
public void setRain(Precipitation rain) {
this.rain = rain;
}
public Snow getSnow() {
public Precipitation getSnow() {
return snow;
}
public void setSnow(Snow snow) {
public void setSnow(Precipitation snow) {
this.snow = snow;
}
}

View File

@ -14,7 +14,9 @@ package org.openhab.binding.openweathermap.internal.dto.onecall;
import java.util.List;
import com.google.gson.annotations.Expose;
import org.openhab.binding.openweathermap.internal.dto.forecast.daily.FeelsLikeTemp;
import org.openhab.binding.openweathermap.internal.dto.forecast.daily.Temp;
import com.google.gson.annotations.SerializedName;
/**
@ -28,60 +30,28 @@ import com.google.gson.annotations.SerializedName;
* @author Wolfgang Klimt - Initial contribution
*/
public class Daily {
@SerializedName("dt")
@Expose
private int dt;
@SerializedName("sunrise")
@Expose
private int sunrise;
@SerializedName("sunset")
@Expose
private int sunset;
@SerializedName("temp")
@Expose
private Temp temp;
@SerializedName("feels_like")
@Expose
private FeelsLike feelsLike;
@SerializedName("pressure")
@Expose
private FeelsLikeTemp feelsLikeTemp;
private int pressure;
@SerializedName("humidity")
@Expose
private int humidity;
@SerializedName("dew_point")
@Expose
private double dewPoint;
@SerializedName("wind_speed")
@Expose
private double windSpeed;
@SerializedName("wind_deg")
@Expose
private int windDeg;
@SerializedName("wind_gust")
@Expose
private double windGust;
@SerializedName("weather")
@Expose
private List<Weather> weather = null;
@SerializedName("clouds")
@Expose
private int clouds;
@SerializedName("pop")
@Expose
private double pop;
@SerializedName("visibility")
@Expose
private int visibility;
@SerializedName("rain")
@Expose
private double rain;
@SerializedName("snow")
@Expose
private double snow;
@SerializedName("uvi")
@Expose
private double uvi;
public int getDt() {
@ -116,12 +86,12 @@ public class Daily {
this.temp = temp;
}
public FeelsLike getFeelsLike() {
return feelsLike;
public FeelsLikeTemp getFeelsLike() {
return feelsLikeTemp;
}
public void setFeelsLike(FeelsLike feelsLike) {
this.feelsLike = feelsLike;
public void setFeelsLike(FeelsLikeTemp feelsLikeTemp) {
this.feelsLikeTemp = feelsLikeTemp;
}
public int getPressure() {

View File

@ -1,74 +0,0 @@
/**
* Copyright (c) 2010-2022 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.onecall;
import com.google.gson.annotations.Expose;
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
*
* @author Wolfgang Klimt - Initial contribution
*/
public class FeelsLike {
@SerializedName("day")
@Expose
private double day;
@SerializedName("night")
@Expose
private double night;
@SerializedName("eve")
@Expose
private double eve;
@SerializedName("morn")
@Expose
private double morn;
public double getDay() {
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;
}
}

View File

@ -14,7 +14,6 @@ package org.openhab.binding.openweathermap.internal.dto.onecall;
import java.util.List;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
@ -28,52 +27,26 @@ import com.google.gson.annotations.SerializedName;
* @author Wolfgang Klimt - Initial contribution
*/
public class Hourly {
@SerializedName("dt")
@Expose
private int dt;
@SerializedName("temp")
@Expose
private double temp;
@SerializedName("feels_like")
@Expose
private double feelsLike;
@SerializedName("pressure")
@Expose
private int pressure;
@SerializedName("humidity")
@Expose
private int humidity;
@SerializedName("dew_point")
@Expose
private double dewPoint;
@SerializedName("clouds")
@Expose
private int clouds;
@SerializedName("visibility")
@Expose
private int visibility;
@SerializedName("wind_speed")
@Expose
private double windSpeed;
@SerializedName("wind_deg")
@Expose
private int windDeg;
@SerializedName("wind_gust")
@Expose
private double windGust;
@SerializedName("weather")
@Expose
private List<Weather> weather = null;
@SerializedName("pop")
@Expose
private double pop;
@SerializedName("rain")
@Expose
private Rain rain;
@SerializedName("snow")
@Expose
private Snow snow;
private Precipitation rain;
private Precipitation snow;
public int getDt() {
return dt;
@ -179,19 +152,19 @@ public class Hourly {
this.pop = pop;
}
public Rain getRain() {
public Precipitation getRain() {
return rain;
}
public void setRain(Rain rain) {
public void setRain(Precipitation rain) {
this.rain = rain;
}
public Snow getSnow() {
public Precipitation getSnow() {
return snow;
}
public void setSnow(Snow snow) {
public void setSnow(Precipitation snow) {
this.snow = snow;
}
}

View File

@ -12,9 +12,6 @@
*/
package org.openhab.binding.openweathermap.internal.dto.onecall;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/.
* Settings:
@ -26,12 +23,7 @@ import com.google.gson.annotations.SerializedName;
* @author Wolfgang Klimt - Initial contribution
*/
public class Minutely {
@SerializedName("dt")
@Expose
private int dt;
@SerializedName("precipitation")
@Expose
private double precipitation;
public int getDt() {

View File

@ -12,7 +12,6 @@
*/
package org.openhab.binding.openweathermap.internal.dto.onecall;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
@ -25,17 +24,15 @@ import com.google.gson.annotations.SerializedName;
*
* @author Wolfgang Klimt - Initial contribution
*/
public class Snow {
public class Precipitation {
@SerializedName("1h")
@Expose
private double _1h;
private double oneHour;
public double get1h() {
return _1h;
return oneHour;
}
public void set1h(double _1h) {
this._1h = _1h;
public void set1h(double oneHour) {
this.oneHour = oneHour;
}
}

View File

@ -1,41 +0,0 @@
/**
* Copyright (c) 2010-2022 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.onecall;
import com.google.gson.annotations.Expose;
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
*
* @author Wolfgang Klimt - Initial contribution
*/
public class Rain {
@SerializedName("1h")
@Expose
private double _1h;
public double get1h() {
return _1h;
}
public void set1h(double _1h) {
this._1h = _1h;
}
}

View File

@ -1,96 +0,0 @@
/**
* Copyright (c) 2010-2022 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.onecall;
import com.google.gson.annotations.Expose;
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
*
* @author Wolfgang Klimt - Initial contribution
*/
public class Temp {
@SerializedName("day")
@Expose
private double day;
@SerializedName("min")
@Expose
private double min;
@SerializedName("max")
@Expose
private double max;
@SerializedName("night")
@Expose
private double night;
@SerializedName("eve")
@Expose
private double eve;
@SerializedName("morn")
@Expose
private double morn;
public double getDay() {
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;
}
}

View File

@ -12,9 +12,6 @@
*/
package org.openhab.binding.openweathermap.internal.dto.onecall;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
/**
* Holds the data from the deserialised JSON response. Created using http://www.jsonschema2pojo.org/.
* Settings:
@ -26,18 +23,9 @@ import com.google.gson.annotations.SerializedName;
* @author Wolfgang Klimt - Initial contribution
*/
public class Weather {
@SerializedName("id")
@Expose
private int id;
@SerializedName("main")
@Expose
private String main;
@SerializedName("description")
@Expose
private String description;
@SerializedName("icon")
@Expose
private String icon;
public int getId() {

View File

@ -1,219 +0,0 @@
/**
* Copyright (c) 2010-2022 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.onecallhist;
import java.util.List;
import com.google.gson.annotations.Expose;
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
*
* @author Wolfgang Klimt - Initial contribution
*/
public class Current {
@SerializedName("dt")
@Expose
private int dt;
@SerializedName("sunrise")
@Expose
private int sunrise;
@SerializedName("sunset")
@Expose
private int sunset;
@SerializedName("temp")
@Expose
private double temp;
@SerializedName("feels_like")
@Expose
private double feelsLike;
@SerializedName("pressure")
@Expose
private int pressure;
@SerializedName("humidity")
@Expose
private int humidity;
@SerializedName("dew_point")
@Expose
private double dewPoint;
@SerializedName("uvi")
@Expose
private double uvi;
@SerializedName("clouds")
@Expose
private int clouds;
@SerializedName("visibility")
@Expose
private int visibility;
@SerializedName("wind_speed")
@Expose
private double windSpeed;
@SerializedName("wind_deg")
@Expose
private int windDeg;
@SerializedName("wind_gust")
@Expose
private double windGust;
@SerializedName("weather")
@Expose
private List<Weather> weather = null;
@SerializedName("rain")
@Expose
private Rain rain;
@SerializedName("snow")
@Expose
private Snow snow;
public int getDt() {
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<Weather> getWeather() {
return weather;
}
public void setWeather(List<Weather> weather) {
this.weather = weather;
}
public Rain getRain() {
return rain;
}
public void setRain(Rain rain) {
this.rain = rain;
}
public Snow getSnow() {
return snow;
}
public void setSnow(Snow snow) {
this.snow = snow;
}
}

View File

@ -14,7 +14,9 @@ package org.openhab.binding.openweathermap.internal.dto.onecallhist;
import java.util.List;
import com.google.gson.annotations.Expose;
import org.openhab.binding.openweathermap.internal.dto.onecall.Precipitation;
import org.openhab.binding.openweathermap.internal.dto.onecall.Weather;
import com.google.gson.annotations.SerializedName;
/**
@ -28,49 +30,25 @@ import com.google.gson.annotations.SerializedName;
* @author Wolfgang Klimt - Initial contribution
*/
public class Hourly {
@SerializedName("dt")
@Expose
private int dt;
@SerializedName("temp")
@Expose
private double temp;
@SerializedName("feels_like")
@Expose
private double feelsLike;
@SerializedName("pressure")
@Expose
private int pressure;
@SerializedName("humidity")
@Expose
private int humidity;
@SerializedName("dew_point")
@Expose
private double dewPoint;
@SerializedName("clouds")
@Expose
private int clouds;
@SerializedName("visibility")
@Expose
private int visibility;
@SerializedName("wind_speed")
@Expose
private double windSpeed;
@SerializedName("wind_deg")
@Expose
private int windDeg;
@SerializedName("wind_gust")
@Expose
private double windGust;
@SerializedName("weather")
@Expose
private List<Weather> weather = null;
@SerializedName("rain")
@Expose
private Rain rain;
@SerializedName("snow")
@Expose
private Snow snow;
private Precipitation rain;
private Precipitation snow;
public int getDt() {
return dt;
@ -168,19 +146,19 @@ public class Hourly {
this.weather = weather;
}
public Rain getRain() {
public Precipitation getRain() {
return rain;
}
public void setRain(Rain rain) {
public void setRain(Precipitation rain) {
this.rain = rain;
}
public Snow getSnow() {
public Precipitation getSnow() {
return snow;
}
public void setSnow(Snow snow) {
public void setSnow(Precipitation snow) {
this.snow = snow;
}
}

View File

@ -1,41 +0,0 @@
/**
* Copyright (c) 2010-2022 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.onecallhist;
import com.google.gson.annotations.Expose;
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
*
* @author Wolfgang Klimt - Initial contribution
*/
public class Rain {
@SerializedName("1h")
@Expose
private double _1h;
public double get1h() {
return _1h;
}
public void set1h(double _1h) {
this._1h = _1h;
}
}

View File

@ -1,41 +0,0 @@
/**
* Copyright (c) 2010-2022 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.onecallhist;
import com.google.gson.annotations.Expose;
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
*
* @author Wolfgang Klimt - Initial contribution
*/
public class Snow {
@SerializedName("1h")
@Expose
private double _1h;
public double get1h() {
return _1h;
}
public void set1h(double _1h) {
this._1h = _1h;
}
}

View File

@ -1,74 +0,0 @@
/**
* Copyright (c) 2010-2022 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.onecallhist;
import com.google.gson.annotations.Expose;
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
*
* @author Wolfgang Klimt - Initial contribution
*/
public class Weather {
@SerializedName("id")
@Expose
private int id;
@SerializedName("main")
@Expose
private String main;
@SerializedName("description")
@Expose
private String description;
@SerializedName("icon")
@Expose
private String icon;
public int getId() {
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;
}
}

View File

@ -26,12 +26,11 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.openweathermap.internal.config.OpenWeatherMapOneCallConfiguration;
import org.openhab.binding.openweathermap.internal.connection.OpenWeatherMapConnection;
import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallAPIData;
import org.openhab.binding.openweathermap.internal.dto.forecast.daily.FeelsLikeTemp;
import org.openhab.binding.openweathermap.internal.dto.forecast.daily.Temp;
import org.openhab.binding.openweathermap.internal.dto.onecall.Alert;
import org.openhab.binding.openweathermap.internal.dto.onecall.FeelsLike;
import org.openhab.binding.openweathermap.internal.dto.onecall.OpenWeatherMapOneCallAPIData;
import org.openhab.binding.openweathermap.internal.dto.onecall.Rain;
import org.openhab.binding.openweathermap.internal.dto.onecall.Snow;
import org.openhab.binding.openweathermap.internal.dto.onecall.Temp;
import org.openhab.binding.openweathermap.internal.dto.onecall.Precipitation;
import org.openhab.core.i18n.CommunicationException;
import org.openhab.core.i18n.ConfigurationException;
import org.openhab.core.i18n.TimeZoneProvider;
@ -348,11 +347,11 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler
state = getDecimalTypeState(localWeatherData.getCurrent().getUvi());
break;
case CHANNEL_RAIN:
Rain rain = localWeatherData.getCurrent().getRain();
Precipitation rain = localWeatherData.getCurrent().getRain();
state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE));
break;
case CHANNEL_SNOW:
Snow snow = localWeatherData.getCurrent().getSnow();
Precipitation snow = localWeatherData.getCurrent().getSnow();
state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE));
break;
case CHANNEL_VISIBILITY:
@ -487,11 +486,11 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler
state = getQuantityTypeState(forecastData.getPop() * 100.0, PERCENT);
break;
case CHANNEL_RAIN:
Rain rain = forecastData.getRain();
Precipitation rain = forecastData.getRain();
state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE));
break;
case CHANNEL_SNOW:
Snow snow = forecastData.getSnow();
Precipitation snow = forecastData.getSnow();
state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE));
break;
default:
@ -527,7 +526,7 @@ public class OpenWeatherMapOneCallHandler extends AbstractOpenWeatherMapHandler
.get(count);
State state = UnDefType.UNDEF;
Temp temp;
FeelsLike feelsLike;
FeelsLikeTemp feelsLike;
switch (channelId) {
case CHANNEL_TIME_STAMP:
state = getDateTimeTypeState(forecastData.getDt());

View File

@ -24,10 +24,9 @@ import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.openweathermap.internal.config.OpenWeatherMapOneCallHistoryConfiguration;
import org.openhab.binding.openweathermap.internal.connection.OpenWeatherMapConnection;
import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapOneCallHistAPIData;
import org.openhab.binding.openweathermap.internal.dto.onecall.Precipitation;
import org.openhab.binding.openweathermap.internal.dto.onecallhist.Hourly;
import org.openhab.binding.openweathermap.internal.dto.onecallhist.OpenWeatherMapOneCallHistAPIData;
import org.openhab.binding.openweathermap.internal.dto.onecallhist.Rain;
import org.openhab.binding.openweathermap.internal.dto.onecallhist.Snow;
import org.openhab.core.i18n.CommunicationException;
import org.openhab.core.i18n.ConfigurationException;
import org.openhab.core.i18n.TimeZoneProvider;
@ -198,11 +197,11 @@ public class OpenWeatherMapOneCallHistoryHandler extends AbstractOpenWeatherMapH
state = getDecimalTypeState(localWeatherData.getCurrent().getUvi());
break;
case CHANNEL_RAIN:
Rain rain = localWeatherData.getCurrent().getRain();
Precipitation rain = localWeatherData.getCurrent().getRain();
state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE));
break;
case CHANNEL_SNOW:
Snow snow = localWeatherData.getCurrent().getSnow();
Precipitation snow = localWeatherData.getCurrent().getSnow();
state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE));
break;
case CHANNEL_VISIBILITY:
@ -295,11 +294,11 @@ public class OpenWeatherMapOneCallHistoryHandler extends AbstractOpenWeatherMapH
State tempstate = new QuantityType<>(historyData.getVisibility(), METRE).toUnit(KILO(METRE));
state = (tempstate == null ? state : tempstate);
case CHANNEL_RAIN:
Rain rain = historyData.getRain();
Precipitation rain = historyData.getRain();
state = getQuantityTypeState(rain == null ? 0 : rain.get1h(), MILLI(METRE));
break;
case CHANNEL_SNOW:
Snow snow = historyData.getSnow();
Precipitation snow = historyData.getSnow();
state = getQuantityTypeState(snow == null ? 0 : snow.get1h(), MILLI(METRE));
break;
default:

View File

@ -31,8 +31,7 @@ import org.openhab.binding.openweathermap.internal.connection.OpenWeatherMapConn
import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonDailyForecastData;
import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonHourlyForecastData;
import org.openhab.binding.openweathermap.internal.dto.OpenWeatherMapJsonWeatherData;
import org.openhab.binding.openweathermap.internal.dto.base.Rain;
import org.openhab.binding.openweathermap.internal.dto.base.Snow;
import org.openhab.binding.openweathermap.internal.dto.base.Precipitation;
import org.openhab.binding.openweathermap.internal.dto.forecast.daily.FeelsLikeTemp;
import org.openhab.core.config.core.Configuration;
import org.openhab.core.i18n.CommunicationException;
@ -301,11 +300,11 @@ public class OpenWeatherMapWeatherAndForecastHandler extends AbstractOpenWeather
state = getQuantityTypeState(localWeatherData.getClouds().getAll(), PERCENT);
break;
case CHANNEL_RAIN:
Rain rain = localWeatherData.getRain();
Precipitation rain = localWeatherData.getRain();
state = getQuantityTypeState(rain == null ? 0 : rain.getVolume(), MILLI(METRE));
break;
case CHANNEL_SNOW:
Snow snow = localWeatherData.getSnow();
Precipitation snow = localWeatherData.getSnow();
state = getQuantityTypeState(snow == null ? 0 : snow.getVolume(), MILLI(METRE));
break;
case CHANNEL_VISIBILITY:
@ -395,11 +394,11 @@ public class OpenWeatherMapWeatherAndForecastHandler extends AbstractOpenWeather
state = getQuantityTypeState(forecastData.getClouds().getAll(), PERCENT);
break;
case CHANNEL_RAIN:
Rain rain = forecastData.getRain();
Precipitation rain = forecastData.getRain();
state = getQuantityTypeState(rain == null ? 0 : rain.getVolume(), MILLI(METRE));
break;
case CHANNEL_SNOW:
Snow snow = forecastData.getSnow();
Precipitation snow = forecastData.getSnow();
state = getQuantityTypeState(snow == null ? 0 : snow.getVolume(), MILLI(METRE));
break;
}
@ -462,7 +461,7 @@ public class OpenWeatherMapWeatherAndForecastHandler extends AbstractOpenWeather
state = getQuantityTypeState(forecastData.getTemp().getMax(), CELSIUS);
break;
case CHANNEL_APPARENT_TEMPERATURE:
FeelsLikeTemp feelsLikeTemp = forecastData.getFeelsLikeTemp();
FeelsLikeTemp feelsLikeTemp = forecastData.getFeelsLike();
if (feelsLikeTemp != null) {
state = getQuantityTypeState(feelsLikeTemp.getDay(), CELSIUS);
}