]> git.basschouten.com Git - openhab-addons.git/blob
742d85dfdbaa4bae6bc148e8048fd5a3f997e878
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.bluetooth.daikinmadoka.internal;
14
15 import static org.junit.jupiter.api.Assertions.*;
16
17 import org.junit.jupiter.api.Test;
18 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaMessage;
19 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.MadokaValue;
20 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.GetIndoorOutoorTemperatures;
21 import org.openhab.binding.bluetooth.daikinmadoka.internal.model.commands.SetPowerstateCommand;
22 import org.openhab.core.library.types.OnOffType;
23
24 /**
25  *
26  * @author blafois
27  *
28  */
29 public class MadokaMessageTest {
30
31     @Test
32     public void testMessageBuildTemperature() {
33         byte[] resp = MadokaMessage.createRequest(new GetIndoorOutoorTemperatures());
34         assertArrayEquals(resp, new byte[] { 0x00, 0x06, 0x00, 0x01, 0x10, 0x00, 0x00 });
35     }
36
37     @Test
38     public void testMessageBuildSetPower() {
39         boolean powered = true;
40         MadokaValue mv = new MadokaValue(0x20, 1, new byte[] { 1 });
41         byte[] resp = MadokaMessage.createRequest(new SetPowerstateCommand(OnOffType.ON), mv);
42         assertArrayEquals(
43                 new byte[] { 0x00, 0x07, 0x00, 0x40, 0x20, 0x20, 0x01, (byte) (powered == true ? 0x01 : 0x00) }, resp);
44     }
45 }