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.loxone.internal.controls;
15 import org.junit.jupiter.api.BeforeEach;
16 import org.junit.jupiter.api.Test;
17 import org.openhab.core.library.types.DecimalType;
18 import org.openhab.core.library.types.OnOffType;
21 * Test class for (@link LxControlMeter}
23 * @author Pawel Pieczul - initial contribution
26 public class LxControlMeterTest extends LxControlTest {
27 private static final String ACTUAL_VALUE_CHANNEL = " / Current";
28 private static final String TOTAL_VALUE_CHANNEL = " / Total";
29 private static final String RESET_CHANNEL = " / Reset";
33 setupControl("13b3ea27-00fc-6f1b-ffff403fb0c34b9e", "0b734138-037d-034e-ffff403fb0c34b9e",
34 "0fe650c2-0004-d446-ffff504f9410790f", "Energy Meter");
38 public void testControlCreation() {
39 testControlCreation(LxControlMeter.class, 1, 0, 3, 3, 2);
43 public void testChannels() {
44 testChannel("Number", ACTUAL_VALUE_CHANNEL, null, null, null, "%.3fkW", true, null);
45 testChannel("Number", TOTAL_VALUE_CHANNEL, null, null, null, "%.1fkWh", true, null);
46 testChannel("Switch", RESET_CHANNEL);
50 public void testLoxoneStateChanges() {
51 for (Double i = 0.0; i < 50.0; i += 0.25) {
52 changeLoxoneState("actual", i);
53 changeLoxoneState("total", i * 2.0);
54 testChannelState(ACTUAL_VALUE_CHANNEL, new DecimalType(i));
55 testChannelState(TOTAL_VALUE_CHANNEL, new DecimalType(i * 2.0));
56 testChannelState(RESET_CHANNEL, OnOffType.OFF);
61 public void testCommands() {
63 for (int i = 0; i < 100; i++) {
64 executeCommand(RESET_CHANNEL, OnOffType.ON);
66 testChannelState(RESET_CHANNEL, OnOffType.OFF);