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.IncreaseDecreaseType;
18 import org.openhab.core.library.types.OnOffType;
19 import org.openhab.core.library.types.PercentType;
20 import org.openhab.core.library.types.StopMoveType;
23 * Test class for (@link LxControlDimmer}
25 * @author Pawel Pieczul - initial contribution
28 public class LxControlEIBDimmerTest extends LxControlTest {
31 setupControl("faa30f5c-4b4f-11e2-8928b8ba17ef51ee", "0b734138-037d-034e-ffff403fb0c34b9e",
32 "0fe650c2-0004-d446-ffff504f9410790f", "Kitchen Dimmer");
36 public void testControlCreation() {
37 testControlCreation(LxControlDimmer.class, 1, 0, 1, 1, 1);
41 public void testChannels() {
42 testChannel("Dimmer");
46 public void testLoxonePositionChanges() {
47 // filling in missing state values
48 testChannelState(null);
49 for (Double i = 0.0; i <= 100.0; i += 1.0) {
50 changeLoxoneState("position", i);
51 testChannelState(new PercentType(i.intValue()));
54 changeLoxoneState("position", 199.9);
55 testChannelState(null);
56 changeLoxoneState("position", 400.1);
57 testChannelState(null);
61 public void testOnOffPercentCommands() {
62 executeCommand(OnOffType.ON);
64 executeCommand(OnOffType.OFF);
66 for (Double i = 0.0; i <= 100.0; i += 1.0) {
67 executeCommand(new PercentType(i.intValue()));
68 testAction(i.toString());
70 executeCommand(StopMoveType.MOVE);
75 public void testIncreaseDecreaseCommands() {
76 for (Double i = 0.0; i <= 95.0; i += 1.0) {
77 changeLoxoneState("position", i);
78 testChannelState(new PercentType(i.intValue()));
80 executeCommand(IncreaseDecreaseType.INCREASE);
82 testAction(j.toString());
84 for (Double i = 100.0; i >= 5.0; i -= 1.0) {
85 changeLoxoneState("position", i);
86 testChannelState(new PercentType(i.intValue()));
88 executeCommand(IncreaseDecreaseType.DECREASE);
90 testAction(j.toString());
92 // test not exceeding range
93 changeLoxoneState("position", 100.0);
94 testChannelState(PercentType.HUNDRED);
96 executeCommand(IncreaseDecreaseType.INCREASE);
99 changeLoxoneState("position", 0.0);
100 testChannelState(PercentType.ZERO);
102 executeCommand(IncreaseDecreaseType.DECREASE);