]> git.basschouten.com Git - openhab-addons.git/blob
7f09401cf2803d3447140da6c5f6fd224d3a8a7e
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.rfxcom.internal.messages;
14
15 import static org.junit.jupiter.api.Assertions.assertArrayEquals;
16 import static org.openhab.binding.rfxcom.internal.RFXComTestHelper.commandChannelUID;
17 import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.HOME_CONFORT;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.junit.jupiter.api.Test;
21 import org.openhab.binding.rfxcom.internal.config.RFXComGenericDeviceConfiguration;
22 import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
23 import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.SubType;
24 import org.openhab.core.library.types.OnOffType;
25 import org.openhab.core.types.Command;
26 import org.openhab.core.util.HexUtils;
27
28 /**
29  * Test for RFXCom-binding
30  *
31  * @author Martin van Wingerden - Initial contribution
32  * @author Mike Jagdis - added message handling and real test
33  */
34 @NonNullByDefault
35 public class RFXComHomeConfortMessageTest {
36     private void testMessage(SubType subType, Command command, String deviceId, String data) throws RFXComException {
37         RFXComGenericDeviceConfiguration config = new RFXComGenericDeviceConfiguration();
38
39         config.deviceId = deviceId;
40         config.subType = subType.toString();
41
42         RFXComHomeConfortMessage message = (RFXComHomeConfortMessage) RFXComMessageFactoryImpl.INSTANCE
43                 .createMessage(HOME_CONFORT, config, commandChannelUID, command);
44
45         assertArrayEquals(HexUtils.hexToBytes(data), message.decodeMessage());
46     }
47
48     @Test
49     public void testMessage1() throws RFXComException {
50         testMessage(SubType.TEL_010, OnOffType.ON, "1118739.A.4", "0C1B0000111213410401000000");
51     }
52 }