]> git.basschouten.com Git - openhab-addons.git/blob
2c74ef19a36301d1a2371ad8b630a10059882fd3
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.unifi.internal.api.model;
14
15 import org.openhab.binding.unifi.internal.api.util.UniFiTidyLowerCaseStringDeserializer;
16
17 import com.google.gson.annotations.JsonAdapter;
18 import com.google.gson.annotations.SerializedName;
19
20 /**
21  * The {@link UniFiDevice} represents the data model of a UniFi Wireless Device
22  * (better known as an Access Point).
23  *
24  * @author Matthew Bowman - Initial contribution
25  */
26 public class UniFiDevice {
27
28     protected final transient UniFiController controller;
29
30     @SerializedName("_id")
31     private String id;
32
33     @JsonAdapter(UniFiTidyLowerCaseStringDeserializer.class)
34     private String mac;
35
36     private String model;
37
38     private String name;
39
40     private String siteId;
41
42     public UniFiDevice(UniFiController controller) {
43         this.controller = controller;
44     }
45
46     public String getId() {
47         return id;
48     }
49
50     public String getModel() {
51         return model;
52     }
53
54     public String getName() {
55         return name == null || name.isBlank() ? mac : name;
56     }
57
58     public String getMac() {
59         return mac;
60     }
61
62     public UniFiSite getSite() {
63         return controller.getSite(siteId);
64     }
65
66     @Override
67     public String toString() {
68         return String.format("UniFiDevice{mac: '%s', name: '%s', model: '%s', site: %s}", mac, name, model, getSite());
69     }
70 }