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.loxone.internal.controls;
15 import org.junit.jupiter.api.BeforeEach;
16 import org.junit.jupiter.api.Test;
17 import org.openhab.core.library.types.DecimalType;
18 import org.openhab.core.library.types.OnOffType;
19 import org.openhab.core.library.types.PercentType;
20 import org.openhab.core.library.types.StringType;
21 import org.openhab.core.types.UnDefType;
24 * Test class for (@link LxControlSauna} - version with no door sensor and no vaporizer
26 * @author Pawel Pieczul - initial contribution
29 public class LxControlSaunaTest extends LxControlTest {
30 private static final String ACTIVE_CHANNEL = " / Active";
31 private static final String POWER_CHANNEL = " / Power";
32 private static final String TEMP_ACTUAL_CHANNEL = " / Temperature / Actual";
33 private static final String TEMP_BENCH_CHANNEL = " / Temperature / Bench";
34 private static final String TEMP_TARGET_CHANNEL = " / Temperature / Target";
35 private static final String FAN_CHANNEL = " / Fan";
36 private static final String DRYING_CHANNEL = " / Drying";
37 static final String DOOR_CLOSED_CHANNEL = " / Door Closed";
38 private static final String ERROR_CODE_CHANNEL = " / Error Code";
39 static final String VAPOR_POWER_CHANNEL = " / Evaporator / Power";
40 private static final String TIMER_CURRENT_CHANNEL = " / Timer / Current";
41 private static final String TIMER_TRIGGER_CHANNEL = " / Timer / Trigger";
42 private static final String TIMER_TOTAL_CHANNEL = " / Timer / Total";
43 static final String OUT_OF_WATER_CHANNEL = " / Evaporator / Out Of Water";
44 static final String ACTUAL_HUMIDITY_CHANNEL = " / Evaporator / Humidity / Actual";
45 static final String TARGET_HUMIDITY_CHANNEL = " / Evaporator / Humidity / Target";
46 static final String EVAPORATOR_MODE_CHANNEL = " / Evaporator / Mode";
47 private static final String NEXT_STATE_CHANNEL = " / Next State";
51 setupControl("17452951-02ae-1b6e-ffff266cf17271db", "0b734138-037d-034e-ffff403fb0c34b9e",
52 "0fe650c2-0004-d446-ffff504f9410790f", "Sauna Controller No Vaporizer No Door Sensor");
56 public void testControlCreation() {
57 testControlCreation(LxControlSauna.class, 3, 0, 12, 12, 14);
61 public void testChannels() {
62 testChannel("Switch", ACTIVE_CHANNEL);
63 testChannel("Number", POWER_CHANNEL);
64 testChannel("Number", TEMP_ACTUAL_CHANNEL);
65 testChannel("Number", TEMP_BENCH_CHANNEL);
66 testChannel("Number", TEMP_TARGET_CHANNEL);
67 testChannel("Switch", FAN_CHANNEL);
68 testChannel("Switch", DRYING_CHANNEL);
69 testChannel("Number", ERROR_CODE_CHANNEL);
70 testChannel("Number", TIMER_CURRENT_CHANNEL);
71 testChannel("Switch", TIMER_TRIGGER_CHANNEL);
72 testChannel("Number", TIMER_TOTAL_CHANNEL);
73 testChannel("Switch", NEXT_STATE_CHANNEL);
77 public void testActiveChannel() {
78 for (int i = 0; i < 5; i++) {
79 changeLoxoneState("active", 0.0);
80 testChannelState(ACTIVE_CHANNEL, OnOffType.OFF);
81 changeLoxoneState("active", 1.0);
82 testChannelState(ACTIVE_CHANNEL, OnOffType.ON);
84 for (int i = 0; i < 5; i++) {
85 executeCommand(ACTIVE_CHANNEL, OnOffType.ON);
87 executeCommand(ACTIVE_CHANNEL, DecimalType.ZERO);
89 executeCommand(ACTIVE_CHANNEL, OnOffType.OFF);
91 executeCommand(ACTIVE_CHANNEL, StringType.EMPTY);
97 public void testPowerChannel() {
98 for (Double i = 0.0; i <= 100.0; i += 1.0) {
99 changeLoxoneState("power", i);
100 testChannelState(POWER_CHANNEL, new PercentType(i.intValue()));
102 changeLoxoneState("power", -1.0);
103 testChannelState(POWER_CHANNEL, UnDefType.UNDEF);
104 changeLoxoneState("power", 100.1);
105 testChannelState(POWER_CHANNEL, UnDefType.UNDEF);
109 public void testTempActualBenchChannels() {
110 for (Double i = -20.0; i <= 150.0; i += 0.37) {
111 changeLoxoneState("tempactual", i);
112 testChannelState(TEMP_ACTUAL_CHANNEL, new DecimalType(i));
113 changeLoxoneState("tempbench", i * 1.1);
114 testChannelState(TEMP_BENCH_CHANNEL, new DecimalType(i * 1.1));
115 changeLoxoneState("temptarget", i * 1.2);
116 testChannelState(TEMP_TARGET_CHANNEL, new DecimalType(i * 1.2));
121 public void testTempTargetSetCommand() {
122 for (Double i = 0.0; i <= 150.0; i += 0.37) {
123 executeCommand(TEMP_TARGET_CHANNEL, new DecimalType(i));
124 testAction("temp/" + i.toString());
129 public void testFanChannel() {
130 for (int i = 0; i < 5; i++) {
131 changeLoxoneState("fan", 0.0);
132 testChannelState(FAN_CHANNEL, OnOffType.OFF);
133 changeLoxoneState("fan", 1.0);
134 testChannelState(FAN_CHANNEL, OnOffType.ON);
136 for (int i = 0; i < 5; i++) {
137 executeCommand(FAN_CHANNEL, OnOffType.ON);
139 executeCommand(FAN_CHANNEL, DecimalType.ZERO);
141 executeCommand(FAN_CHANNEL, OnOffType.OFF);
142 testAction("fanoff");
143 executeCommand(FAN_CHANNEL, StringType.EMPTY);
149 public void testDryingChannel() {
150 for (int i = 0; i < 5; i++) {
151 changeLoxoneState("drying", 0.0);
152 testChannelState(DRYING_CHANNEL, OnOffType.OFF);
153 changeLoxoneState("drying", 1.0);
154 testChannelState(DRYING_CHANNEL, OnOffType.ON);
159 public void testDoorClosedChannel() {
160 testNoChannel(DOOR_CLOSED_CHANNEL);
164 public void testErrorCodeChannel() {
165 for (Double i = 0.0; i < 10.0; i += 1.0) {
166 changeLoxoneState("saunaerror", i);
167 changeLoxoneState("error", 0.0);
168 testChannelState(ERROR_CODE_CHANNEL, DecimalType.ZERO);
169 changeLoxoneState("error", 1.0);
170 testChannelState(ERROR_CODE_CHANNEL, new DecimalType(i));
175 public void testTimerCurrentTotalChannels() {
176 for (Double i = 0.0; i <= 150.0; i += 0.21) {
177 changeLoxoneState("timer", i);
178 testChannelState(TIMER_CURRENT_CHANNEL, new DecimalType(i));
179 changeLoxoneState("timertotal", i * 1.3);
180 testChannelState(TIMER_TOTAL_CHANNEL, new DecimalType(i * 1.3));
185 public void testTimerTriggerChannel() {
186 for (int i = 0; i <= 10; i++) {
187 executeCommand(TIMER_TRIGGER_CHANNEL, DecimalType.ZERO);
189 testChannelState(TIMER_TRIGGER_CHANNEL, OnOffType.OFF);
190 executeCommand(TIMER_TRIGGER_CHANNEL, OnOffType.ON);
191 testAction("starttimer");
192 testChannelState(TIMER_TRIGGER_CHANNEL, OnOffType.OFF);
193 executeCommand(TIMER_TRIGGER_CHANNEL, OnOffType.OFF);
195 testChannelState(TIMER_TRIGGER_CHANNEL, OnOffType.OFF);
200 public void vaporPowerChannel() {
201 testNoChannel(VAPOR_POWER_CHANNEL);
205 public void testOutOfWaterChannel() {
206 testNoChannel(OUT_OF_WATER_CHANNEL);
210 public void testActualHumidityChannel() {
211 testNoChannel(ACTUAL_HUMIDITY_CHANNEL);
215 public void testTargetHumidityChannel() {
216 testNoChannel(TARGET_HUMIDITY_CHANNEL);
220 public void testEvaporatorModelChannel() {
221 testNoChannel(EVAPORATOR_MODE_CHANNEL);
225 public void testNextStateTriggerChannel() {
226 for (int i = 0; i <= 10; i++) {
227 executeCommand(NEXT_STATE_CHANNEL, DecimalType.ZERO);
229 testChannelState(NEXT_STATE_CHANNEL, OnOffType.OFF);
230 executeCommand(NEXT_STATE_CHANNEL, OnOffType.ON);
232 testChannelState(NEXT_STATE_CHANNEL, OnOffType.OFF);
233 executeCommand(NEXT_STATE_CHANNEL, OnOffType.OFF);
235 testChannelState(NEXT_STATE_CHANNEL, OnOffType.OFF);