Search in sources :

Example 1 with LocationConfig

use of org.openhab.binding.weather.internal.common.LocationConfig 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);
    }
}
Also used : JobDataMap(org.quartz.JobDataMap) JobExecutionException(org.quartz.JobExecutionException) WeatherProvider(org.openhab.binding.weather.internal.provider.WeatherProvider) LocationConfig(org.openhab.binding.weather.internal.common.LocationConfig) JobExecutionException(org.quartz.JobExecutionException)

Aggregations

LocationConfig (org.openhab.binding.weather.internal.common.LocationConfig)1 WeatherProvider (org.openhab.binding.weather.internal.provider.WeatherProvider)1 JobDataMap (org.quartz.JobDataMap)1 JobExecutionException (org.quartz.JobExecutionException)1