use of org.eclipse.smarthome.core.library.types.DateTimeType in project smarthome by eclipse.
the class WeatherUndergroundHandler method updateCurrentObservationChannel.
private State updateCurrentObservationChannel(String channelId, WeatherUndergroundJsonCurrent current) {
WUQuantity quantity;
String channelTypeId = getChannelTypeId(channelId);
switch(channelTypeId) {
case "location":
return undefOrState(current.getLocation(), new StringType(current.getLocation()));
case "stationId":
return undefOrState(current.getStationId(), new StringType(current.getStationId()));
case "observationTime":
return undefOrState(current.getObservationTime(), new DateTimeType(current.getObservationTime()));
case "conditions":
return undefOrState(current.getConditions(), new StringType(current.getConditions()));
case "temperature":
quantity = getTemperature(current.getTemperatureC(), current.getTemperatureF());
return undefOrQuantity(quantity);
case "relativeHumidity":
return undefOrState(current.getRelativeHumidity(), new QuantityType<>(current.getRelativeHumidity(), SmartHomeUnits.PERCENT));
case "windDirection":
return undefOrState(current.getWindDirection(), new StringType(current.getWindDirection()));
case "windDirectionDegrees":
return undefOrState(current.getWindDirectionDegrees(), new QuantityType<>(current.getWindDirectionDegrees(), SmartHomeUnits.DEGREE_ANGLE));
case "windSpeed":
quantity = getSpeed(current.getWindSpeedKmh(), current.getWindSpeedMph());
return undefOrQuantity(quantity);
case "windGust":
quantity = getSpeed(current.getWindGustKmh(), current.getWindGustMph());
return undefOrQuantity(quantity);
case "pressure":
quantity = getPressure(current.getPressureHPa(), current.getPressureInHg());
return undefOrQuantity(quantity);
case "pressureTrend":
return undefOrState(current.getPressureTrend(), new StringType(current.getPressureTrend()));
case "dewPoint":
quantity = getTemperature(current.getDewPointC(), current.getDewPointF());
return undefOrQuantity(quantity);
case "heatIndex":
quantity = getTemperature(current.getHeatIndexC(), current.getHeatIndexF());
return undefOrQuantity(quantity);
case "windChill":
quantity = getTemperature(current.getWindChillC(), current.getWindChillF());
return undefOrQuantity(quantity);
case "feelingTemperature":
quantity = getTemperature(current.getFeelingTemperatureC(), current.getFeelingTemperatureF());
return undefOrQuantity(quantity);
case "visibility":
quantity = getWUQuantity(KILO(SIUnits.METRE), ImperialUnits.MILE, current.getVisibilityKm(), current.getVisibilityMi());
return undefOrQuantity(quantity);
case "solarRadiation":
return undefOrQuantity(new WUQuantity(current.getSolarRadiation(), SmartHomeUnits.IRRADIANCE));
case "UVIndex":
return undefOrDecimal(current.getUVIndex());
case "precipitationDay":
quantity = getPrecipitation(current.getPrecipitationDayMm(), current.getPrecipitationDayIn());
return undefOrQuantity(quantity);
case "precipitationHour":
quantity = getPrecipitation(current.getPrecipitationHourMm(), current.getPrecipitationHourIn());
return undefOrQuantity(quantity);
case "iconKey":
return undefOrState(current.getIconKey(), new StringType(current.getIconKey()));
case "icon":
State icon = HttpUtil.downloadImage(current.getIcon().toExternalForm());
if (icon == null) {
logger.debug("Failed to download the content of URL {}", current.getIcon().toExternalForm());
return null;
}
return icon;
default:
return null;
}
}
Aggregations