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.PlugwiseUtils.*;
16 import static org.openhab.binding.plugwise.internal.protocol.field.Sensitivity.MEDIUM;
18 import java.time.Duration;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
22 import org.openhab.binding.plugwise.internal.protocol.field.Sensitivity;
25 * The {@link PlugwiseScanConfig} class represents the configuration for a Plugwise Scan.
27 * @author Wouter Born - Initial contribution
30 public class PlugwiseScanConfig {
32 private String macAddress = "";
33 private String sensitivity = upperUnderscoreToLowerCamel(MEDIUM.name());
34 private int switchOffDelay = 5; // minutes
35 private boolean daylightOverride = false;
36 private int wakeupInterval = 1440; // minutes (1 day)
37 private int wakeupDuration = 10; // seconds
38 private boolean recalibrate = false;
39 private boolean updateConfiguration = true;
41 public MACAddress getMACAddress() {
42 return new MACAddress(macAddress);
45 public Sensitivity getSensitivity() {
46 return Sensitivity.valueOf(lowerCamelToUpperUnderscore(sensitivity));
49 public Duration getSwitchOffDelay() {
50 return Duration.ofMinutes(switchOffDelay);
53 public boolean isDaylightOverride() {
54 return daylightOverride;
57 public Duration getWakeupInterval() {
58 return Duration.ofMinutes(wakeupInterval);
61 public Duration getWakeupDuration() {
62 return Duration.ofSeconds(wakeupDuration);
65 public boolean isRecalibrate() {
69 public boolean isUpdateConfiguration() {
70 return updateConfiguration;
73 public boolean equalScanParameters(PlugwiseScanConfig other) {
74 return this.sensitivity.equals(other.sensitivity) && this.switchOffDelay == other.switchOffDelay
75 && this.daylightOverride == other.daylightOverride;
78 public boolean equalSleepParameters(PlugwiseScanConfig other) {
79 return this.wakeupInterval == other.wakeupInterval && this.wakeupDuration == other.wakeupDuration;
83 public String toString() {
84 return "PlugwiseScanConfig [macAddress=" + macAddress + ", sensitivity=" + sensitivity + ", switchOffDelay="
85 + switchOffDelay + ", daylightOverride=" + daylightOverride + ", wakeupInterval=" + wakeupInterval
86 + ", wakeupDuration=" + wakeupDuration + ", recalibrate=" + recalibrate + ", updateConfiguration="
87 + updateConfiguration + "]";