2 * Copyright (c) 2010-2022 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.BoundaryAction.OFF_BELOW_ON_ABOVE;
17 import static org.openhab.binding.plugwise.internal.protocol.field.BoundaryType.NONE;
19 import java.time.Duration;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.openhab.binding.plugwise.internal.protocol.field.BoundaryAction;
23 import org.openhab.binding.plugwise.internal.protocol.field.BoundaryType;
24 import org.openhab.binding.plugwise.internal.protocol.field.Humidity;
25 import org.openhab.binding.plugwise.internal.protocol.field.MACAddress;
26 import org.openhab.binding.plugwise.internal.protocol.field.Temperature;
29 * The {@link PlugwiseScanConfig} class represents the configuration for a Plugwise Sense.
31 * @author Wouter Born - Initial contribution
34 public class PlugwiseSenseConfig {
36 private String macAddress = "";
37 private int measurementInterval = 15; // minutes
38 private String boundaryType = upperUnderscoreToLowerCamel(NONE.name());
39 private String boundaryAction = upperUnderscoreToLowerCamel(OFF_BELOW_ON_ABOVE.name());
40 private int temperatureBoundaryMin = 15; // degrees Celsius
41 private int temperatureBoundaryMax = 25; // degrees Celsius
42 private int humidityBoundaryMin = 45; // relative humidity (RH)
43 private int humidityBoundaryMax = 65; // relative humidity (RH)
44 private int wakeupInterval = 1440; // minutes (1 day)
45 private int wakeupDuration = 10; // seconds
46 private boolean updateConfiguration = true;
48 public MACAddress getMACAddress() {
49 return new MACAddress(macAddress);
52 public Duration getMeasurementInterval() {
53 return Duration.ofMinutes(measurementInterval);
56 public BoundaryType getBoundaryType() {
57 return BoundaryType.valueOf(lowerCamelToUpperUnderscore(boundaryType));
60 public BoundaryAction getBoundaryAction() {
61 return BoundaryAction.valueOf(lowerCamelToUpperUnderscore(boundaryAction));
64 public Temperature getTemperatureBoundaryMin() {
65 return new Temperature(temperatureBoundaryMin);
68 public Temperature getTemperatureBoundaryMax() {
69 return new Temperature(temperatureBoundaryMax);
72 public Humidity getHumidityBoundaryMin() {
73 return new Humidity(humidityBoundaryMin);
76 public Humidity getHumidityBoundaryMax() {
77 return new Humidity(humidityBoundaryMax);
80 public Duration getWakeupInterval() {
81 return Duration.ofMinutes(wakeupInterval);
84 public Duration getWakeupDuration() {
85 return Duration.ofSeconds(wakeupDuration);
88 public boolean isUpdateConfiguration() {
89 return updateConfiguration;
92 public boolean equalBoundaryParameters(PlugwiseSenseConfig other) {
93 return boundaryType.equals(other.boundaryType) && boundaryAction.equals(other.boundaryAction)
94 && temperatureBoundaryMin == other.temperatureBoundaryMin
95 && temperatureBoundaryMax == other.temperatureBoundaryMax
96 && humidityBoundaryMin == other.humidityBoundaryMin && humidityBoundaryMax == other.humidityBoundaryMax;
99 public boolean equalSleepParameters(PlugwiseSenseConfig other) {
100 return this.wakeupInterval == other.wakeupInterval && this.wakeupDuration == other.wakeupDuration;
104 public String toString() {
105 return "PlugwiseSenseConfig [macAddress=" + macAddress + ", measurementInterval=" + measurementInterval
106 + ", boundaryType=" + boundaryType + ", boundaryAction=" + boundaryAction + ", temperatureBoundaryMin="
107 + temperatureBoundaryMin + ", temperatureBoundaryMax=" + temperatureBoundaryMax
108 + ", humidityBoundaryMin=" + humidityBoundaryMin + ", humidityBoundaryMax=" + humidityBoundaryMax
109 + ", wakeupInterval=" + wakeupInterval + ", wakeupDuration=" + wakeupDuration + ", updateConfiguration="
110 + updateConfiguration + "]";