2 * Copyright (c) 2010-2021 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.model;
15 import org.apache.commons.lang.StringUtils;
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
27 public class UniFiDevice {
29 protected final transient UniFiController controller;
31 @SerializedName("_id")
34 @JsonAdapter(UniFiTidyLowerCaseStringDeserializer.class)
41 private String siteId;
43 public UniFiDevice(UniFiController controller) {
44 this.controller = controller;
47 public String getId() {
51 public String getModel() {
55 public String getName() {
56 return StringUtils.defaultIfBlank(name, mac);
59 public String getMac() {
63 public UniFiSite getSite() {
64 return controller.getSite(siteId);
68 public String toString() {
69 return String.format("UniFiDevice{mac: '%s', name: '%s', model: '%s', site: %s}", mac, name, model, getSite());