]> git.basschouten.com Git - openhab-addons.git/blob
600294c0e26b212a968c144bd0c5cf8c411fa3d8
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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.hue.internal.api.dto.clip1;
14
15 import java.util.ArrayList;
16 import java.util.Date;
17 import java.util.List;
18 import java.util.Map;
19
20 import com.google.gson.annotations.SerializedName;
21
22 /**
23  * Detailed bridge info available if authenticated.
24  *
25  * @author Q42 - Initial contribution
26  * @author Denis Dudnik - moved Jue library source code inside the smarthome Hue binding, minor code cleanup
27  * @author Samuel Leisering - added API-Version
28  */
29 public class Config {
30     private String name;
31     private String swversion;
32     private String apiversion;
33     private String bridgeid;
34     private String mac;
35     private String modelid;
36     private boolean dhcp;
37     private String ipaddress;
38     private String netmask;
39     private String gateway;
40     private String proxyaddress;
41     private int proxyport;
42     @SerializedName("UTC")
43     private Date utc;
44     private boolean linkbutton;
45     private Map<String, User> whitelist;
46     private SoftwareUpdate swupdate;
47
48     Config() {
49     }
50
51     /**
52      * Returns the name.
53      *
54      * @return name of the bridge
55      */
56     public String getName() {
57         return name;
58     }
59
60     /**
61      * Returns the version of the software.
62      *
63      * @return version of software on the bridge
64      */
65     public String getSoftwareVersion() {
66         return swversion;
67     }
68
69     /**
70      * Returns the bridge id
71      *
72      * @return bridge id
73      */
74     public String getBridgeId() {
75         return bridgeid;
76     }
77
78     /**
79      * Returns the MAC address.
80      *
81      * @return mac address of bridge
82      */
83     public String getMACAddress() {
84         return mac;
85     }
86
87     /**
88      * Returns the model id
89      *
90      * @return model id
91      */
92     public String getModelId() {
93         return modelid;
94     }
95
96     /**
97      * Returns if the current IP address was obtained with DHCP.
98      *
99      * @return true if the current IP address was obtained with DHCP, false otherwise.
100      */
101     public boolean isDHCPEnabled() {
102         return dhcp;
103     }
104
105     /**
106      * Returns the IP address.
107      *
108      * @return ip address of bridge
109      */
110     public String getIPAddress() {
111         return ipaddress;
112     }
113
114     /**
115      * Returns the network mask.
116      *
117      * @return network mask
118      */
119     public String getNetworkMask() {
120         return netmask;
121     }
122
123     /**
124      * Returns the IP address of the gateway.
125      *
126      * @return ip address of gateway
127      */
128     public String getGateway() {
129         return gateway;
130     }
131
132     /**
133      * Returns the IP address of the proxy or null if there is none.
134      *
135      * @return ip address of proxy or null
136      */
137     public String getProxyAddress() {
138         return "none".equals(proxyaddress) ? null : proxyaddress;
139     }
140
141     /**
142      * Returns the port of the proxy or null if there is none.
143      *
144      * @return port of proxy or null
145      */
146     public Integer getProxyPort() {
147         return "none".equals(proxyaddress) ? null : proxyport;
148     }
149
150     /**
151      * Returns the time on the bridge.
152      *
153      * @return time on the bridge
154      */
155     public Date getUTCTime() {
156         return utc;
157     }
158
159     /**
160      * Returns if the link button has been pressed within the last 30 seconds.
161      *
162      * @return true if the link button has been pressed within the last 30 seconds, false otherwise
163      */
164     public boolean isLinkButtonPressed() {
165         return linkbutton;
166     }
167
168     /**
169      * Returns the list of whitelisted users.
170      *
171      * @return list of whitelisted users
172      */
173     public List<User> getWhitelist() {
174         ArrayList<User> usersList = new ArrayList<>();
175
176         usersList.addAll(whitelist.values());
177
178         return usersList;
179     }
180
181     /**
182      * Returns information about a bridge firmware update.
183      *
184      * @return bridge firmware update info
185      */
186     public SoftwareUpdate getSoftwareUpdate() {
187         return swupdate;
188     }
189
190     /**
191      * Returns the current API-Version of the Bridge. This always returns <code>1.0</code>
192      * for bridges with version less than <code>1.2.1</code>, which introduces this call.
193      *
194      * @return
195      */
196     public String getApiVersion() {
197         if (apiversion == null) {
198             return "1.0";
199         }
200         return apiversion;
201     }
202 }