]> git.basschouten.com Git - openhab-addons.git/blob
8cd7742f1e0ea23079b8f512cee354824e5f8e2b
[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.loxone.internal.controls;
14
15 import org.junit.jupiter.api.BeforeEach;
16 import org.junit.jupiter.api.Test;
17 import org.openhab.core.library.types.OnOffType;
18
19 /**
20  * Test class for (@link LxControlAlarm} - version with motion sensors
21  *
22  * @author Pawel Pieczul - initial contribution
23  *
24  */
25 public class LxControlAlarmWithPresenceTest extends LxControlAlarmNoPresenceTest {
26     private static final String MOTION_SENSORS_CHANNEL = " / Motion Sensors";
27
28     @Override
29     @BeforeEach
30     public void setup() {
31         setupControl("133d5db0-0333-5865-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
32                 "0fe650c2-0004-d446-ffff504f9410790f", "Burglar Alarm With Presence");
33     }
34
35     @Override
36     @Test
37     public void testControlCreation() {
38         testControlCreation(LxControlAlarm.class, 2, 1, 12, 13, 10);
39     }
40
41     @Override
42     @Test
43     public void testChannels() {
44         super.testChannels();
45         testChannel("Switch", MOTION_SENSORS_CHANNEL);
46     }
47
48     @Override
49     @Test
50     public void testCommandsDefaultChannel() {
51         testAction(null);
52         for (int i = 0; i < 20; i++) {
53             changeLoxoneState("disabledmove", 0.0);
54             executeCommand(OnOffType.ON);
55             testAction("on/1");
56             executeCommand(OnOffType.OFF);
57             testAction("off");
58             changeLoxoneState("disabledmove", 1.0);
59             executeCommand(OnOffType.ON);
60             testAction("on/0");
61             executeCommand(OnOffType.OFF);
62             testAction("off");
63         }
64     }
65
66     @Override
67     @Test
68     public void testCommandsArmWithDelayChannel() {
69         testAction(null);
70         for (int i = 0; i < 20; i++) {
71             changeLoxoneState("disabledmove", 0.0);
72             executeCommand(ARM_DELAYED_CHANNEL, OnOffType.ON);
73             testAction("delayedon/1");
74             executeCommand(ARM_DELAYED_CHANNEL, OnOffType.OFF);
75             testAction("off");
76             changeLoxoneState("disabledmove", 1.0);
77             executeCommand(ARM_DELAYED_CHANNEL, OnOffType.ON);
78             testAction("delayedon/0");
79             executeCommand(ARM_DELAYED_CHANNEL, OnOffType.OFF);
80             testAction("off");
81         }
82     }
83
84     @Test
85     public void testCommandsMotionSensors() {
86         testAction(null);
87         for (int i = 0; i < 20; i++) {
88             executeCommand(MOTION_SENSORS_CHANNEL, OnOffType.ON);
89             testAction("dismv/0");
90             executeCommand(MOTION_SENSORS_CHANNEL, OnOffType.OFF);
91             testAction("dismv/1");
92         }
93     }
94
95     @Test
96     public void testLoxoneMotionSensorsChanges() {
97         for (int i = 0; i < 20; i++) {
98             changeLoxoneState("disabledmove", 1.0);
99             testChannelState(MOTION_SENSORS_CHANNEL, OnOffType.OFF);
100             changeLoxoneState("disabledmove", 0.0);
101             testChannelState(MOTION_SENSORS_CHANNEL, OnOffType.ON);
102         }
103     }
104 }