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.junit.jupiter.api.Assertions.assertArrayEquals;
16 import static org.openhab.binding.rfxcom.internal.messages.RFXComInterfaceMessage.TransceiverType._433_92MHZ_TRANSCEIVER;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.junit.jupiter.api.BeforeEach;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.rfxcom.internal.config.RFXComBridgeConfiguration;
22 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
23 import org.openhab.core.util.HexUtils;
26 * Test for RFXCom-binding
28 * @author Mike Jagdis - Initial contribution
31 public class RFXComInterfaceControlMessageTest {
32 private RFXComBridgeConfiguration configuration = new RFXComBridgeConfiguration();
35 public void resetConfig() {
36 configuration.transmitPower = -18;
37 configuration.enableUndecoded = false;
38 configuration.enableImagintronixOpus = false;
39 configuration.enableByronSX = false;
40 configuration.enableRSL = false;
41 configuration.enableLighting4 = false;
42 configuration.enableFineOffsetViking = false;
43 configuration.enableRubicson = false;
44 configuration.enableAEBlyss = false;
46 configuration.enableBlindsT1T2T3T4 = false;
47 configuration.enableBlindsT0 = false;
48 configuration.enableProGuard = false;
49 // configuration.enableFS20Packets = false;
50 configuration.enableLaCrosse = false;
51 configuration.enableHidekiUPM = false;
52 configuration.enableADLightwaveRF = false;
53 configuration.enableMertik = false;
55 configuration.enableVisonic = false;
56 configuration.enableATI = false;
57 configuration.enableOregonScientific = false;
58 configuration.enableMeiantech = false;
59 configuration.enableHomeEasyEU = false;
60 configuration.enableAC = false;
61 configuration.enableARC = false;
62 configuration.enableX10 = false;
65 private void testMessage(RFXComInterfaceMessage.TransceiverType transceiverType,
66 RFXComBridgeConfiguration configuration, String data) {
67 assertArrayEquals(HexUtils.hexToBytes(data),
68 new RFXComInterfaceControlMessage(transceiverType, configuration).decodeMessage());
72 public void testUndecodedMessage() throws RFXComException {
73 configuration.enableUndecoded = true;
74 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530080000000000000");
78 public void testImagintronixOpusMessage() throws RFXComException {
79 configuration.enableImagintronixOpus = true;
80 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530040000000000000");
84 public void testByronSXMessage() throws RFXComException {
85 configuration.enableByronSX = true;
86 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530020000000000000");
90 public void testRSLMessage() throws RFXComException {
91 configuration.enableRSL = true;
92 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530010000000000000");
96 public void testLighting4Message() throws RFXComException {
97 configuration.enableLighting4 = true;
98 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530008000000000000");
102 public void testFineOffsetVikingMessage() throws RFXComException {
103 configuration.enableFineOffsetViking = true;
104 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530004000000000000");
108 public void testRubicsonMessage() throws RFXComException {
109 configuration.enableRubicson = true;
110 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530002000000000000");
114 public void testAEBlyssMessage() throws RFXComException {
115 configuration.enableAEBlyss = true;
116 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530001000000000000");
120 public void testBlindsT1T2T3T4Message() throws RFXComException {
121 configuration.enableBlindsT1T2T3T4 = true;
122 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000800000000000");
126 public void testBlindsT0Message() throws RFXComException {
127 configuration.enableBlindsT0 = true;
128 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000400000000000");
132 public void testProGuardMessage() throws RFXComException {
133 configuration.enableProGuard = true;
134 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000200000000000");
138 // public void testFS20PacketsMessage() throws RFXComException {
139 // configuration.enableFS20Packets = true;
140 // testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000100000000000");
144 public void testLaCrosseMessage() throws RFXComException {
145 configuration.enableLaCrosse = true;
146 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000080000000000");
150 public void testHidekiUPMMessage() throws RFXComException {
151 configuration.enableHidekiUPM = true;
152 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000040000000000");
156 public void testLightwaverRFMessage() throws RFXComException {
157 configuration.enableADLightwaveRF = true;
158 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000020000000000");
162 public void testMertikMessage() throws RFXComException {
163 configuration.enableMertik = true;
164 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000010000000000");
168 public void testVisionicMessage() throws RFXComException {
169 configuration.enableVisonic = true;
170 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000008000000000");
174 public void testATIMessage() throws RFXComException {
175 configuration.enableATI = true;
176 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000004000000000");
180 public void testOregonScientificMessage() throws RFXComException {
181 configuration.enableOregonScientific = true;
182 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000002000000000");
186 public void testMeiantechMessage() throws RFXComException {
187 configuration.enableMeiantech = true;
188 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000001000000000");
192 public void testHomeEasyEUMessage() throws RFXComException {
193 configuration.enableHomeEasyEU = true;
194 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000000800000000");
198 public void testACMessage() throws RFXComException {
199 configuration.enableAC = true;
200 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000000400000000");
204 public void testARCMessage() throws RFXComException {
205 configuration.enableARC = true;
206 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000000200000000");
210 public void testX10Message() throws RFXComException {
211 configuration.enableX10 = true;
212 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530000000100000000");
216 public void testTransmitPower() throws RFXComException {
217 configuration.transmitPower = 0;
218 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203531200000000000000");
222 public void testPerSDK() throws RFXComException {
223 configuration.enableUndecoded = true;
224 configuration.enableLaCrosse = true;
225 configuration.enableOregonScientific = true;
226 configuration.enableAC = true;
227 configuration.enableARC = true;
228 configuration.enableX10 = true;
229 testMessage(_433_92MHZ_TRANSCEIVER, configuration, "0D00000203530080082700000000");