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.math.BigDecimal;
16 import java.util.ArrayList;
17 import java.util.List;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.core.library.types.DecimalType;
22 import org.openhab.core.library.types.OnOffType;
23 import org.openhab.core.library.types.PercentType;
24 import org.openhab.core.types.StateOption;
27 * Test class for (@link LxControlRadio} - variant with no 'all off' selection
29 * @author Pawel Pieczul - initial contribution
32 public class LxControlRadioTest extends LxControlTest {
35 setupControl("4255054f-0355-af47-ffff403fb0c34b9e", "11d68cf4-0080-7697-ffff403fb0c34b9e",
36 "0fe650c2-0004-d446-ffff504f9410790f", "Sprinkler 1");
40 public void testControlCreation() {
41 testControlCreation(LxControlRadio.class, 2, 0, 1, 1, 1);
45 public void testChannels() {
46 List<StateOption> opts = new ArrayList<>();
47 for (Integer i = 1; i <= 6; i++) {
48 opts.add(new StateOption(i.toString(), "Sprinkler " + i.toString()));
50 testChannel("Number", null, BigDecimal.ZERO, new BigDecimal(16), BigDecimal.ONE, null, false, opts);
54 public void testLoxoneCommonStateChanges() {
55 testChannelState(null);
56 for (int i = 1; i <= 6; i++) {
57 changeLoxoneState("activeoutput", i * 1.0);
58 testChannelState(new DecimalType(i));
60 changeLoxoneState("activeoutput", 0.5);
61 testChannelState(null);
63 changeLoxoneState("activeoutput", 7.0);
64 testChannelState(null);
65 changeLoxoneState("activeoutput", 17.0);
66 testChannelState(null);
70 public void testLoxoneZeroIndexChanges() {
71 changeLoxoneState("activeoutput", 0.0);
72 testChannelState(null);
76 public void testCommonCommands() {
77 for (Integer i = 1; i <= 6; i++) {
78 executeCommand(new DecimalType(i));
79 testAction(i.toString());
81 executeCommand(new DecimalType(7));
83 executeCommand(new DecimalType(17));
86 executeCommand(PercentType.HUNDRED);
91 public void testZeroIndexCommands() {
92 executeCommand(DecimalType.ZERO);
94 executeCommand(OnOffType.OFF);