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.unifi.internal.api.dto;
15 import org.openhab.binding.unifi.internal.api.cache.UniFiControllerCache;
16 import org.openhab.binding.unifi.internal.api.util.UniFiTidyLowerCaseStringDeserializer;
18 import com.google.gson.JsonObject;
19 import com.google.gson.annotations.JsonAdapter;
20 import com.google.gson.annotations.SerializedName;
23 * The {@link UniFiDevice} represents the data model of a UniFi Wireless Device
24 * (better known as an Access Point).
26 * @author Matthew Bowman - Initial contribution
27 * @author Hilbrand Bouwkamp - Added PoEPort support
29 public class UniFiDevice implements HasId {
31 protected final transient UniFiControllerCache cache;
33 @SerializedName("_id")
36 @JsonAdapter(UniFiTidyLowerCaseStringDeserializer.class)
41 private String version;
43 private String serial;
49 private String siteId;
51 private UniFiPortTable[] portTable;
53 private JsonObject[] portOverrides;
55 private boolean disabled;
57 public UniFiDevice(final UniFiControllerCache cache) {
62 public String getId() {
66 public String getType() {
70 public String getModel() {
74 public String getVersion() {
78 public String getSerial() {
82 public String getName() {
83 return name == null || name.isBlank() ? mac : name;
86 public String getMac() {
90 public UniFiSite getSite() {
91 return cache.getSite(siteId);
94 public UniFiPortTable[] getPortTable() {
98 public JsonObject[] getPortOverrides() {
102 public boolean isDisabled() {
107 public String toString() {
108 return String.format("UniFiDevice{mac: '%s', name: '%s', type: %s, model: '%s', disabled: %b, site: %s}", mac,
109 name, type, model, disabled, getSite());