]> git.basschouten.com Git - openhab-addons.git/blob
9477ad0a177bf35f7809c150581b408700310245
[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.plugwise.internal.config;
14
15 import static org.openhab.binding.plugwise.internal.PlugwiseUtils.*;
16 import static org.openhab.binding.plugwise.internal.config.PlugwiseRelayConfig.PowerStateChanging.COMMAND_SWITCHING;
17
18 import java.time.Duration;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
22
23 /**
24  * The {@link PlugwiseRelayConfig} class represents the configuration for a Plugwise relay device (Circle, Circle+,
25  * Stealth).
26  *
27  * @author Wouter Born - Initial contribution
28  */
29 @NonNullByDefault
30 public class PlugwiseRelayConfig {
31
32     public enum PowerStateChanging {
33         COMMAND_SWITCHING,
34         ALWAYS_ON,
35         ALWAYS_OFF
36     }
37
38     private String macAddress = "";
39     private String powerStateChanging = upperUnderscoreToLowerCamel(COMMAND_SWITCHING.name());
40     private boolean suppliesPower = false;
41     private int measurementInterval = 60; // minutes
42     private boolean temporarilyNotInNetwork = false;
43     private boolean updateConfiguration = true;
44
45     public MACAddress getMACAddress() {
46         return new MACAddress(macAddress);
47     }
48
49     public PowerStateChanging getPowerStateChanging() {
50         return PowerStateChanging.valueOf(lowerCamelToUpperUnderscore(powerStateChanging));
51     }
52
53     public boolean isSuppliesPower() {
54         return suppliesPower;
55     }
56
57     public Duration getMeasurementInterval() {
58         return Duration.ofMinutes(measurementInterval);
59     }
60
61     public boolean isTemporarilyNotInNetwork() {
62         return temporarilyNotInNetwork;
63     }
64
65     public boolean isUpdateConfiguration() {
66         return updateConfiguration;
67     }
68
69     @Override
70     public String toString() {
71         return "PlugwiseRelayConfig [macAddress=" + macAddress + ", powerStateChanging=" + powerStateChanging
72                 + ", suppliesPower=" + suppliesPower + ", measurementInterval=" + measurementInterval
73                 + ", temporarilyNotInNetwork=" + temporarilyNotInNetwork + ", updateConfiguration="
74                 + updateConfiguration + "]";
75     }
76 }