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 java.util.Collections;
18 import org.junit.jupiter.api.BeforeEach;
19 import org.junit.jupiter.api.Test;
20 import org.openhab.core.library.types.DecimalType;
21 import org.openhab.core.library.types.OnOffType;
22 import org.openhab.core.library.types.PercentType;
23 import org.openhab.core.library.types.StopMoveType;
24 import org.openhab.core.library.types.UpDownType;
27 * Test class for (@link LxControlJalousie}
29 * @author Pawel Pieczul - initial contribution
32 public class LxControlJalousieTest extends LxControlTest {
34 private static final String ROLLERSHUTTER_CHANNEL = null;
35 private static final String SHADE_CHANNEL = " / Shade";
36 private static final String AUTO_SHADE_CHANNEL = " / Auto Shade";
40 setupControl("0e367c09-0161-e2c1-ffff403fb0c34b9e", "0e368d32-014f-4604-ffff403fb0c34b9e",
41 "0b734138-033e-02d8-ffff403fb0c34b9e", "Window Blinds");
45 public void testControlCreation() {
46 testControlCreation(LxControlJalousie.class, 1, 0, 3, 3, 11);
50 public void testChannels() {
51 testChannel("Rollershutter", Collections.singleton("Blinds"));
52 Set<String> tags = Collections.singleton("Switchable");
53 testChannel("Switch", SHADE_CHANNEL, tags);
54 testChannel("Switch", AUTO_SHADE_CHANNEL, tags);
58 public void testLoxonePositionAutoShadeStates() {
60 testChannelState(ROLLERSHUTTER_CHANNEL, null);
61 testChannelState(SHADE_CHANNEL, OnOffType.OFF);
62 testChannelState(AUTO_SHADE_CHANNEL, null);
63 for (int i = 0; i <= 100; i++) {
64 changeLoxoneState("position", i / 100.0);
65 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(i));
66 testChannelState(SHADE_CHANNEL, OnOffType.OFF);
67 changeLoxoneState("autoactive", a ? 1.0 : 0.0);
68 testChannelState(AUTO_SHADE_CHANNEL, a ? OnOffType.ON : OnOffType.OFF);
71 changeLoxoneState("position", 100.1);
72 testChannelState(ROLLERSHUTTER_CHANNEL, null);
73 changeLoxoneState("position", -0.1);
74 testChannelState(ROLLERSHUTTER_CHANNEL, null);
78 public void testCommands() {
79 for (int i = 0; i < 20; i++) {
80 executeCommand(SHADE_CHANNEL, OnOffType.ON);
82 executeCommand(SHADE_CHANNEL, OnOffType.OFF);
84 executeCommand(SHADE_CHANNEL, DecimalType.ZERO);
86 executeCommand(AUTO_SHADE_CHANNEL, OnOffType.ON);
88 executeCommand(AUTO_SHADE_CHANNEL, OnOffType.OFF);
90 executeCommand(AUTO_SHADE_CHANNEL, DecimalType.ZERO);
92 executeCommand(ROLLERSHUTTER_CHANNEL, UpDownType.UP);
94 executeCommand(ROLLERSHUTTER_CHANNEL, UpDownType.DOWN);
95 testAction("FullDown");
96 executeCommand(ROLLERSHUTTER_CHANNEL, StopMoveType.STOP);
98 executeCommand(ROLLERSHUTTER_CHANNEL, StopMoveType.MOVE);
104 public void testMovingToPosition() {
105 changeLoxoneState("position", 0.1);
106 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(10));
107 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(73));
108 testAction("FullDown");
109 changeLoxoneState("up", 0.0);
110 changeLoxoneState("down", 1.0);
111 for (int i = 10; i <= 72; i++) {
112 changeLoxoneState("position", i / 100.0);
113 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(i));
115 changeLoxoneState("position", 0.73);
117 changeLoxoneState("position", 0.74);
119 changeLoxoneState("up", 0.0);
120 changeLoxoneState("down", 0.0);
121 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(10));
122 testAction("FullUp");
123 changeLoxoneState("up", 1.0);
124 changeLoxoneState("down", 0.0);
125 for (int i = 74; i >= 11; i--) {
126 changeLoxoneState("position", i / 100.0);
127 testChannelState(ROLLERSHUTTER_CHANNEL, new PercentType(i));
129 changeLoxoneState("position", 0.10);
131 changeLoxoneState("position", 0.09);
134 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(50));
135 testAction("FullDown");
136 changeLoxoneState("up", 0.0);
137 changeLoxoneState("down", 1.0);
138 changeLoxoneState("position", 0.80);
140 changeLoxoneState("position", 0.50);
143 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(90));
144 testAction("FullDown");
145 changeLoxoneState("up", 0.0);
146 changeLoxoneState("down", 0.0);
147 changeLoxoneState("position", 0.95);
149 changeLoxoneState("position", 0.85);
152 changeLoxoneState("down", 1.0);
153 changeLoxoneState("position", 0.85);
155 changeLoxoneState("position", 0.95);
157 changeLoxoneState("position", 0.85);
159 changeLoxoneState("position", 0.95);
161 changeLoxoneState("down", 0.0);
163 executeCommand(ROLLERSHUTTER_CHANNEL, new PercentType(30));
164 testAction("FullUp");
165 changeLoxoneState("up", 1.0);
166 changeLoxoneState("down", 0.0);
167 changeLoxoneState("position", 0.40);
169 changeLoxoneState("position", 0.20);
171 changeLoxoneState("position", 0.40);
173 changeLoxoneState("position", 0.20);
175 changeLoxoneState("up", 0.0);
177 executeCommand(ROLLERSHUTTER_CHANNEL, PercentType.HUNDRED);
178 testAction("FullDown");
179 changeLoxoneState("up", 0.0);
180 changeLoxoneState("down", 1.0);
181 changeLoxoneState("position", 0.80);
183 changeLoxoneState("position", 1.00);
185 changeLoxoneState("down", 0.0);
187 executeCommand(ROLLERSHUTTER_CHANNEL, PercentType.ZERO);
188 testAction("FullUp");
189 changeLoxoneState("up", 1.0);
190 changeLoxoneState("down", 0.0);
191 changeLoxoneState("position", 0.20);
193 changeLoxoneState("position", 0.00);
195 changeLoxoneState("up", 0.0);