2 * Copyright (c) 2010-2024 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 static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.netatmo.internal.api.dto.NAMain;
19 import org.openhab.binding.netatmo.internal.handler.CommonInterface;
22 * The {@link DeviceCapability} takes care of handling properties for netatmo devices
24 * @author Gaƫl L'hopital - Initial contribution
28 public class DeviceCapability extends Capability {
29 private static final int DATA_AGE_LIMIT_S = 3600;
32 * Whether the device is owned or not by the user (a favorite station or a guest station is not owned by the user).
33 * It will be updated when handling the result of the getstationsdata API.
34 * It must be initialized to false to be sure that the first call to the API will not fail for a favorite/guest
37 protected boolean owned;
39 public DeviceCapability(CommonInterface handler) {
44 protected void updateNAMain(NAMain newData) {
45 owned = !newData.isReadOnly();
47 newData.getPlace().ifPresent(place -> {
48 place.getCity().map(city -> properties.put(PROPERTY_CITY, city));
49 place.getCountry().map(country -> properties.put(PROPERTY_COUNTRY, country));
50 place.getTimezone().map(tz -> properties.put(PROPERTY_TIMEZONE, tz));
53 if (!newData.hasFreshData(DATA_AGE_LIMIT_S)) {
54 statusReason = "@text/data-over-limit";