2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.plugwise.internal.config;
15 import static org.openhab.binding.plugwise.internal.config.PlugwiseRelayConfig.PowerStateChanging.COMMAND_SWITCHING;
17 import java.time.Duration;
18 import java.util.Objects;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.plugwise.internal.PlugwiseUtils;
22 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
23 import org.openhab.core.util.StringUtils;
26 * The {@link PlugwiseRelayConfig} class represents the configuration for a Plugwise relay device (Circle, Circle+,
29 * @author Wouter Born - Initial contribution
32 public class PlugwiseRelayConfig {
34 public enum PowerStateChanging {
40 private String macAddress = "";
41 private String powerStateChanging = Objects
42 .requireNonNull(StringUtils.capitalizeByUnderscore(COMMAND_SWITCHING.name()));
43 private boolean suppliesPower = false;
44 private int measurementInterval = 60; // minutes
45 private boolean temporarilyNotInNetwork = false;
46 private boolean updateConfiguration = true;
48 public MACAddress getMACAddress() {
49 return new MACAddress(macAddress);
52 public PowerStateChanging getPowerStateChanging() {
53 return PowerStateChanging.valueOf(PlugwiseUtils.lowerCamelToUpperUnderscore(powerStateChanging));
56 public boolean isSuppliesPower() {
60 public Duration getMeasurementInterval() {
61 return Duration.ofMinutes(measurementInterval);
64 public boolean isTemporarilyNotInNetwork() {
65 return temporarilyNotInNetwork;
68 public boolean isUpdateConfiguration() {
69 return updateConfiguration;
73 public String toString() {
74 return "PlugwiseRelayConfig [macAddress=" + macAddress + ", powerStateChanging=" + powerStateChanging
75 + ", suppliesPower=" + suppliesPower + ", measurementInterval=" + measurementInterval
76 + ", temporarilyNotInNetwork=" + temporarilyNotInNetwork + ", updateConfiguration="
77 + updateConfiguration + "]";