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.rfxcom.internal.messages;
15 import static org.openhab.binding.rfxcom.internal.RFXComBindingConstants.*;
16 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.FAN_FALMEC;
17 import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessage.SubType.FALMEC;
18 import static org.openhab.binding.rfxcom.internal.messages.RFXComFanMessageTest.testCommand;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.junit.jupiter.api.Test;
22 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
23 import org.openhab.core.library.types.DecimalType;
24 import org.openhab.core.library.types.OnOffType;
25 import org.openhab.core.library.types.StringType;
26 import org.openhab.core.types.UnDefType;
29 * Test for RFXCom-binding
31 * @author Martin van Wingerden - Initial contribution
34 public class RFXComFanFalmecMessageTest {
37 public void testFalmecCommandOn() throws RFXComException {
38 testCommand(FALMEC, CHANNEL_COMMAND, OnOffType.ON, OnOffType.ON, UnDefType.UNDEF, new DecimalType(2),
39 StringType.valueOf("SPEED_2"), FAN_FALMEC);
43 public void testFalmecCommandOff() throws RFXComException {
44 testCommand(FALMEC, CHANNEL_COMMAND, OnOffType.OFF, OnOffType.OFF, UnDefType.UNDEF, new DecimalType(0),
45 StringType.valueOf("POWER_OFF"), FAN_FALMEC);
49 public void testFanSpeed0() throws RFXComException {
50 testFalmecFanSpeed(0, OnOffType.OFF);
54 public void testFanSpeed1() throws RFXComException {
55 testFalmecFanSpeed(1, OnOffType.ON);
59 public void testFanSpeed2() throws RFXComException {
60 testFalmecFanSpeed(2, OnOffType.ON);
64 public void testFanSpeed3() throws RFXComException {
65 testFalmecFanSpeed(3, OnOffType.ON);
69 public void testFanSpeed4() throws RFXComException {
70 testFalmecFanSpeed(4, OnOffType.ON);
74 public void testFalmecFanLightOn() throws RFXComException {
75 testCommand(FALMEC, CHANNEL_FAN_LIGHT, OnOffType.ON, null, OnOffType.ON, null, StringType.valueOf("LIGHT_ON"),
80 public void testFalmecFanLightOff() throws RFXComException {
81 testCommand(FALMEC, CHANNEL_FAN_LIGHT, OnOffType.OFF, null, OnOffType.OFF, null,
82 StringType.valueOf("LIGHT_OFF"), FAN_FALMEC);
85 private void testFalmecFanSpeed(int value, OnOffType expectedCommand) throws RFXComException {
86 StringType expectedCommandString;
88 expectedCommandString = StringType.valueOf("POWER_OFF");
90 expectedCommandString = StringType.valueOf("SPEED_" + value);
92 testCommand(FALMEC, CHANNEL_FAN_SPEED, new DecimalType(value), expectedCommand, UnDefType.UNDEF,
93 new DecimalType(value), expectedCommandString, FAN_FALMEC);