2 * Copyright (c) 2010-2022 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.annotations.JsonAdapter;
19 import com.google.gson.annotations.SerializedName;
22 * The {@link UniFiDevice} represents the data model of a UniFi Wireless Device
23 * (better known as an Access Point).
25 * @author Matthew Bowman - Initial contribution
26 * @author Hilbrand Bouwkamp - Added PoEPort support
28 public class UniFiDevice implements HasId {
30 protected final transient UniFiControllerCache cache;
32 @SerializedName("_id")
35 @JsonAdapter(UniFiTidyLowerCaseStringDeserializer.class)
42 private String siteId;
44 private UniFiPortTable[] portTable;
46 public UniFiDevice(final UniFiControllerCache cache) {
51 public String getId() {
55 public String getModel() {
59 public String getName() {
60 return name == null || name.isBlank() ? mac : name;
63 public String getMac() {
67 public UniFiSite getSite() {
68 return cache.getSite(siteId);
71 public UniFiPortTable[] getPortTable() {
76 public String toString() {
77 return String.format("UniFiDevice{mac: '%s', name: '%s', model: '%s', site: %s}", mac, name, model, getSite());