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.protocol.field.Sensitivity.MEDIUM;
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.binding.plugwise.internal.protocol.field.Sensitivity;
24 import org.openhab.core.util.StringUtils;
27 * The {@link PlugwiseScanConfig} class represents the configuration for a Plugwise Scan.
29 * @author Wouter Born - Initial contribution
32 public class PlugwiseScanConfig {
34 private String macAddress = "";
35 private String sensitivity = Objects.requireNonNull(StringUtils.capitalizeByUnderscore(MEDIUM.name()));
36 private int switchOffDelay = 5; // minutes
37 private boolean daylightOverride = false;
38 private int wakeupInterval = 1440; // minutes (1 day)
39 private int wakeupDuration = 10; // seconds
40 private boolean recalibrate = false;
41 private boolean updateConfiguration = true;
43 public MACAddress getMACAddress() {
44 return new MACAddress(macAddress);
47 public Sensitivity getSensitivity() {
48 return Sensitivity.valueOf(PlugwiseUtils.lowerCamelToUpperUnderscore(sensitivity));
51 public Duration getSwitchOffDelay() {
52 return Duration.ofMinutes(switchOffDelay);
55 public boolean isDaylightOverride() {
56 return daylightOverride;
59 public Duration getWakeupInterval() {
60 return Duration.ofMinutes(wakeupInterval);
63 public Duration getWakeupDuration() {
64 return Duration.ofSeconds(wakeupDuration);
67 public boolean isRecalibrate() {
71 public boolean isUpdateConfiguration() {
72 return updateConfiguration;
75 public boolean equalScanParameters(PlugwiseScanConfig other) {
76 return this.sensitivity.equals(other.sensitivity) && this.switchOffDelay == other.switchOffDelay
77 && this.daylightOverride == other.daylightOverride;
80 public boolean equalSleepParameters(PlugwiseScanConfig other) {
81 return this.wakeupInterval == other.wakeupInterval && this.wakeupDuration == other.wakeupDuration;
85 public String toString() {
86 return "PlugwiseScanConfig [macAddress=" + macAddress + ", sensitivity=" + sensitivity + ", switchOffDelay="
87 + switchOffDelay + ", daylightOverride=" + daylightOverride + ", wakeupInterval=" + wakeupInterval
88 + ", wakeupDuration=" + wakeupDuration + ", recalibrate=" + recalibrate + ", updateConfiguration="
89 + updateConfiguration + "]";