2 * Copyright (c) 2010-2023 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.api;
15 import static org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.*;
17 import javax.ws.rs.core.UriBuilder;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.netatmo.internal.api.data.NetatmoConstants.FeatureArea;
22 import org.openhab.binding.netatmo.internal.api.dto.NAMain;
23 import org.openhab.binding.netatmo.internal.api.dto.NAMain.StationDataResponse;
24 import org.openhab.binding.netatmo.internal.handler.ApiBridgeHandler;
27 * Base class for all Air Care related endpoints
29 * @author Gaƫl L'hopital - Initial contribution
32 public class AircareApi extends RestManager {
34 public AircareApi(ApiBridgeHandler apiClient) {
35 super(apiClient, FeatureArea.AIR_CARE);
39 * Returns data from Healthy Home Coach Station (measures and device specific data).
41 * @param deviceId Id of the device you want to retrieve information of (optional)
42 * @return StationDataResponse
43 * @throws NetatmoException If fail to call the API, e.g. server error or deserializing
45 public StationDataResponse getHomeCoachData(@Nullable String deviceId) throws NetatmoException {
46 UriBuilder uriBuilder = getApiUriBuilder(SUB_PATH_HOMECOACH, PARAM_DEVICE_ID, deviceId);
47 return get(uriBuilder, StationDataResponse.class);
50 public NAMain getHomeCoach(String deviceId) throws NetatmoException {
51 ListBodyResponse<NAMain> answer = getHomeCoachData(deviceId).getBody();
53 NAMain station = answer.getElement(deviceId);
54 if (station != null) {
58 throw new NetatmoException("Unexpected answer querying device '%s' : not found.", deviceId);