use of org.openhab.binding.weather.internal.provider.WeatherProvider in project openhab1-addons by openhab.
the class WeatherJob method execute.
/**
* {@inheritDoc}
*/
@Override
public void execute(JobExecutionContext jobContext) throws JobExecutionException {
JobDataMap jobDataMap = jobContext.getJobDetail().getJobDataMap();
String locationId = jobDataMap.getString("locationId");
logger.debug("Starting Weather job for location '{}'", locationId);
try {
LocationConfig locationConfig = context.getConfig().getLocationConfig(locationId);
WeatherProvider weatherProvider = WeatherProviderFactory.createWeatherProvider(locationConfig.getProviderName());
context.setWeather(locationId, weatherProvider.getWeather(locationConfig));
weatherPublisher.publish(locationId);
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
throw new JobExecutionException(ex.getMessage(), ex);
}
}
Aggregations