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;
17 import org.junit.jupiter.api.BeforeEach;
18 import org.junit.jupiter.api.Test;
19 import org.openhab.core.library.types.DecimalType;
20 import org.openhab.core.library.types.OnOffType;
21 import org.openhab.core.library.types.PercentType;
22 import org.openhab.core.library.types.StopMoveType;
23 import org.openhab.core.library.types.UpDownType;
26 * Test class for (@link LxControlJalousie}
28 * @author Pawel Pieczul - initial contribution
31 public class LxControlJalousieTest extends LxControlTest {
33 private static final String ROLLERSHUTTER_CHANNEL = null;
34 private static final String SHADE_CHANNEL = " / Shade";
35 private static final String AUTO_SHADE_CHANNEL = " / Auto Shade";
39 setupControl("0e367c09-0161-e2c1-ffff403fb0c34b9e", "0e368d32-014f-4604-ffff403fb0c34b9e",
40 "0b734138-033e-02d8-ffff403fb0c34b9e", "Window Blinds");
44 public void testControlCreation() {
45 testControlCreation(LxControlJalousie.class, 1, 0, 3, 3, 11);
49 public void testChannels() {
50 testChannel("Rollershutter", Set.of("Blinds"));
51 Set<String> tags = Set.of("Switchable");
52 testChannel("Switch", SHADE_CHANNEL, tags);
53 testChannel("Switch", AUTO_SHADE_CHANNEL, tags);
57 public void testLoxonePositionAutoShadeStates() {
59 testChannelState(ROLLERSHUTTER_CHANNEL, null);
60 testChannelState(SHADE_CHANNEL, OnOffType.OFF);
61 testChannelState(AUTO_SHADE_CHANNEL, null);
62 for (int i = 0; i <= 100; i++) {
63 changeLoxoneState("position", i / 100.0);
64 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(i));
65 testChannelState(SHADE_CHANNEL, OnOffType.OFF);
66 changeLoxoneState("autoactive", a ? 1.0 : 0.0);
67 testChannelState(AUTO_SHADE_CHANNEL, a ? OnOffType.ON : OnOffType.OFF);
70 changeLoxoneState("position", 100.1);
71 testChannelState(ROLLERSHUTTER_CHANNEL, null);
72 changeLoxoneState("position", -0.1);
73 testChannelState(ROLLERSHUTTER_CHANNEL, null);
77 public void testCommands() {
78 for (int i = 0; i < 20; i++) {
79 executeCommand(SHADE_CHANNEL, OnOffType.ON);
81 executeCommand(SHADE_CHANNEL, OnOffType.OFF);
83 executeCommand(SHADE_CHANNEL, DecimalType.ZERO);
85 executeCommand(AUTO_SHADE_CHANNEL, OnOffType.ON);
87 executeCommand(AUTO_SHADE_CHANNEL, OnOffType.OFF);
89 executeCommand(AUTO_SHADE_CHANNEL, DecimalType.ZERO);
91 executeCommand(ROLLERSHUTTER_CHANNEL, UpDownType.UP);
93 executeCommand(ROLLERSHUTTER_CHANNEL, UpDownType.DOWN);
94 testAction("FullDown");
95 executeCommand(ROLLERSHUTTER_CHANNEL, StopMoveType.STOP);
97 executeCommand(ROLLERSHUTTER_CHANNEL, StopMoveType.MOVE);
103 public void testMovingToPosition() {
104 changeLoxoneState("position", 0.1);
105 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(10));
106 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(73));
107 testAction("FullDown");
108 changeLoxoneState("up", 0.0);
109 changeLoxoneState("down", 1.0);
110 for (int i = 10; i <= 72; i++) {
111 changeLoxoneState("position", i / 100.0);
112 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(i));
114 changeLoxoneState("position", 0.73);
116 changeLoxoneState("position", 0.74);
118 changeLoxoneState("up", 0.0);
119 changeLoxoneState("down", 0.0);
120 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(10));
121 testAction("FullUp");
122 changeLoxoneState("up", 1.0);
123 changeLoxoneState("down", 0.0);
124 for (int i = 74; i >= 11; i--) {
125 changeLoxoneState("position", i / 100.0);
126 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(i));
128 changeLoxoneState("position", 0.10);
130 changeLoxoneState("position", 0.09);
133 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(50));
134 testAction("FullDown");
135 changeLoxoneState("up", 0.0);
136 changeLoxoneState("down", 1.0);
137 changeLoxoneState("position", 0.80);
139 changeLoxoneState("position", 0.50);
142 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(90));
143 testAction("FullDown");
144 changeLoxoneState("up", 0.0);
145 changeLoxoneState("down", 0.0);
146 changeLoxoneState("position", 0.95);
148 changeLoxoneState("position", 0.85);
151 changeLoxoneState("down", 1.0);
152 changeLoxoneState("position", 0.85);
154 changeLoxoneState("position", 0.95);
156 changeLoxoneState("position", 0.85);
158 changeLoxoneState("position", 0.95);
160 changeLoxoneState("down", 0.0);
162 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(30));
163 testAction("FullUp");
164 changeLoxoneState("up", 1.0);
165 changeLoxoneState("down", 0.0);
166 changeLoxoneState("position", 0.40);
168 changeLoxoneState("position", 0.20);
170 changeLoxoneState("position", 0.40);
172 changeLoxoneState("position", 0.20);
174 changeLoxoneState("up", 0.0);
176 executeCommand(ROLLERSHUTTER_CHANNEL, PercentType.HUNDRED);
177 testAction("FullDown");
178 changeLoxoneState("up", 0.0);
179 changeLoxoneState("down", 1.0);
180 changeLoxoneState("position", 0.80);
182 changeLoxoneState("position", 1.00);
184 changeLoxoneState("down", 0.0);
186 executeCommand(ROLLERSHUTTER_CHANNEL, PercentType.ZERO);
187 testAction("FullUp");
188 changeLoxoneState("up", 1.0);
189 changeLoxoneState("down", 0.0);
190 changeLoxoneState("position", 0.20);
192 changeLoxoneState("position", 0.00);
194 changeLoxoneState("up", 0.0);