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.dto;
15 import java.time.ZonedDateTime;
16 import java.util.Optional;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.netatmo.internal.api.data.ModuleType;
22 import com.google.gson.annotations.SerializedName;
25 * The {@link NAThing} is the base class for devices and modules.
27 * @author Gaƫl L'hopital - Initial contribution
32 public class NAThing extends NAObject implements NAModule {
33 @SerializedName(value = "rf_status", alternate = { "wifi_status", "rf_strength", "wifi_strength" })
34 private int radioStatus = -1;
35 @SerializedName(value = "last_seen", alternate = { "last_therm_seen", "last_status_store", "last_plug_seen",
36 "last_message", "last_activity" })
37 protected @Nullable ZonedDateTime lastSeen;
38 @SerializedName(value = "firmware", alternate = { "firmware_revision" })
39 private @Nullable String firmware;
40 private @Nullable Boolean reachable;
41 private @Nullable Dashboard dashboardData;
43 private @Nullable String roomId;
44 private @Nullable String bridge;
45 private ModuleType type = ModuleType.UNKNOWN;
48 public ModuleType getType() {
52 public boolean isReachable() {
53 // This is not implemented on all devices/modules, so if absent we consider it is reachable
54 Boolean localReachable = this.reachable;
55 return localReachable != null ? localReachable : true;
58 public void setReachable(boolean reachable) {
59 this.reachable = reachable;
62 public @Nullable Dashboard getDashboardData() {
66 public @Nullable String getFirmware() {
70 public int getRadioStatus() {
74 public Optional<ZonedDateTime> getLastSeen() {
75 return Optional.ofNullable(lastSeen);
79 * @return true if the equipment has no parent, meaning its a device.
81 public boolean isDevice() {
82 return bridge == null;
85 public @Nullable String getBridge() {
89 public @Nullable String getRoomId() {