]> git.basschouten.com Git - openhab-addons.git/blob
9a8fac8f1289e545fc3bc41ee4d82a77af002f8e
[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 /**
16  * Collection of updates to the bridge configuration.
17  *
18  * @author Q42 - Initial contribution
19  * @author Denis Dudnik - moved Jue library source code inside the smarthome Hue binding, minor code cleanup
20  * @author Samuel Leisering - added Sensor support
21  */
22 public class BridgeConfigUpdate extends ConfigUpdate {
23     /**
24      * Set the port of the proxy or null if there is no proxy.
25      *
26      * @param port port for proxy
27      * @return this object for chaining calls
28      */
29     public BridgeConfigUpdate setProxyPort(Integer port) {
30         if (port != null && port < 0) {
31             throw new IllegalArgumentException("Invalid value for port");
32         }
33
34         commands.add(new Command("proxyport", port == null ? 0 : port));
35         return this;
36     }
37
38     /**
39      * Set the name of the bridge, which also functions as the UPnP name.
40      *
41      * @param name new name [4..16]
42      * @return this object for chaining calls
43      */
44     public BridgeConfigUpdate setName(String name) {
45         if (Util.stringSize(name) < 4 || Util.stringSize(name) > 16) {
46             throw new IllegalArgumentException("Bridge name must be between 4 and 16 characters long");
47         }
48
49         commands.add(new Command("name", name));
50         return this;
51     }
52
53     /**
54      * Set the address of the proxy or null if there is no proxy.
55      *
56      * @param ip ip of proxy
57      * @return this object for chaining calls
58      */
59     public BridgeConfigUpdate setProxyAddress(String ip) {
60         if (ip != null && Util.stringSize(ip) > 40) {
61             throw new IllegalArgumentException("Bridge proxy address can be at most 40 characters long");
62         }
63
64         commands.add(new Command("proxyaddress", ip == null ? "none" : ip));
65         return this;
66     }
67
68     /**
69      * Set whether the link button has been pressed within the last 30 seconds or not.
70      *
71      * @param pressed true for pressed, false for not pressed
72      * @return this object for chaining calls
73      */
74     public BridgeConfigUpdate setLinkButton(boolean pressed) {
75         commands.add(new Command("linkbutton", pressed));
76         return this;
77     }
78
79     /**
80      * Set the IP address of the bridge.
81      *
82      * @param ip ip address of bridge
83      * @return this object for chaining calls
84      */
85     public BridgeConfigUpdate setIPAddress(String ip) {
86         commands.add(new Command("ipaddress", ip));
87         return this;
88     }
89
90     /**
91      * Set the network mask of the bridge.
92      *
93      * @param netmask network mask
94      * @return this object for chaining calls
95      */
96     public BridgeConfigUpdate setNetworkMask(String netmask) {
97         commands.add(new Command("netmask", netmask));
98         return this;
99     }
100
101     /**
102      * Set the gateway address of the bridge.
103      *
104      * @param ip gateway address
105      * @return this object for chaining calls
106      */
107     public BridgeConfigUpdate setGateway(String ip) {
108         commands.add(new Command("gateway", ip));
109         return this;
110     }
111
112     /**
113      * Set whether the bridge uses DHCP to get an ip address or not.
114      *
115      * @param enabled dhcp enabled
116      * @return this object for chaining calls
117      */
118     public BridgeConfigUpdate setDHCP(boolean enabled) {
119         commands.add(new Command("dhcp", enabled));
120         return this;
121     }
122 }