]> git.basschouten.com Git - openhab-addons.git/blob
5cc19fc674ebd8466ed533a3eb7c47f4cf61cfb0
[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 java.time.Duration;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
19
20 /**
21  * The {@link PlugwiseSwitchConfig} class represents the configuration for a Plugwise Switch.
22  *
23  * @author Wouter Born - Initial contribution
24  */
25 @NonNullByDefault
26 public class PlugwiseSwitchConfig {
27
28     private String macAddress = "";
29     private int wakeupInterval = 1440; // minutes (1 day)
30     private int wakeupDuration = 10; // seconds
31     private boolean updateConfiguration = true;
32
33     public MACAddress getMACAddress() {
34         return new MACAddress(macAddress);
35     }
36
37     public Duration getWakeupInterval() {
38         return Duration.ofMinutes(wakeupInterval);
39     }
40
41     public Duration getWakeupDuration() {
42         return Duration.ofSeconds(wakeupDuration);
43     }
44
45     public boolean isUpdateConfiguration() {
46         return updateConfiguration;
47     }
48
49     public boolean equalSleepParameters(PlugwiseSwitchConfig other) {
50         return this.wakeupInterval == other.wakeupInterval && this.wakeupDuration == other.wakeupDuration;
51     }
52
53     @Override
54     public String toString() {
55         return "PlugwiseSwitchConfig [macAddress=" + macAddress + ", wakeupInterval=" + wakeupInterval
56                 + ", wakeupDuration=" + wakeupDuration + ", updateConfiguration=" + updateConfiguration + "]";
57     }
58 }