]> git.basschouten.com Git - openhab-addons.git/blob
9524c2c2b7df8a005c7954d379848cc7797cbbb6
[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.lifx.internal;
14
15 import java.net.InetSocketAddress;
16 import java.time.Duration;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.lifx.internal.fields.MACAddress;
21
22 /**
23  * Configuration class for LIFX lights.
24  *
25  * @author Wouter Born - Initial contribution
26  */
27 @NonNullByDefault
28 public class LifxLightConfig {
29
30     private @Nullable String deviceId;
31     private @Nullable String host;
32     private long fadetime = 300; // milliseconds
33
34     public @Nullable MACAddress getMACAddress() {
35         String localDeviceId = deviceId;
36         return localDeviceId == null ? null : new MACAddress(localDeviceId);
37     }
38
39     public @Nullable InetSocketAddress getHost() {
40         return host == null ? null : new InetSocketAddress(host, LifxBindingConstants.UNICAST_PORT);
41     }
42
43     public Duration getFadeTime() {
44         return Duration.ofMillis(fadetime);
45     }
46 }