]> git.basschouten.com Git - openhab-addons.git/blob
351fbf951be5f5b211dc875dddd86f94606b76e2
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.netatmo.internal.handler.capability;
14
15 import java.util.List;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.netatmo.internal.api.AircareApi;
19 import org.openhab.binding.netatmo.internal.api.NetatmoException;
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;
24
25 /**
26  * {@link AirCareCapability} give the ability to read home coach api
27  *
28  * @author GaĆ«l L'hopital - Initial contribution
29  *
30  */
31 @NonNullByDefault
32 public class AirCareCapability extends RestCapability<AircareApi> {
33     private final Logger logger = LoggerFactory.getLogger(AirCareCapability.class);
34
35     public AirCareCapability(CommonInterface handler) {
36         super(handler, AircareApi.class);
37     }
38
39     @Override
40     protected List<NAObject> updateReadings(AircareApi api) {
41         try {
42             return List.of(api.getHomeCoach(handler.getId()));
43         } catch (NetatmoException e) {
44             logger.warn("Error retrieving home-coach data '{}' : {}", handler.getId(), e.getMessage());
45         }
46         return List.of();
47     }
48 }