2 * Copyright (c) 2010-2022 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.netatmo.internal.handler.capability;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.netatmo.internal.api.NetatmoException;
19 import org.openhab.binding.netatmo.internal.api.WeatherApi;
20 import org.openhab.binding.netatmo.internal.api.dto.NAObject;
21 import org.openhab.binding.netatmo.internal.handler.CommonInterface;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
26 * {@link WeatherCapability} give the ability to read weather station api
28 * @author Gaƫl L'hopital - Initial contribution
32 public class WeatherCapability extends RestCapability<WeatherApi> {
33 private final Logger logger = LoggerFactory.getLogger(WeatherCapability.class);
35 public WeatherCapability(CommonInterface handler) {
36 super(handler, WeatherApi.class);
40 protected List<NAObject> updateReadings(WeatherApi api) {
42 return List.of(owned ? api.getOwnedStationData(handler.getId()) : api.getStationData(handler.getId()));
43 } catch (NetatmoException e) {
44 logger.warn("Error retrieving weather data '{}' : {}", handler.getId(), e.getMessage());