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.velux.internal.bridge;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.binding.velux.internal.bridge.common.GetProductLimitation;
17 import org.openhab.binding.velux.internal.things.VeluxProductPosition;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * The {@link VeluxBridgeGetLimitation} represents a complete set of transactions
23 * for retrieval of the limitation of an actuator defined on the <B>Velux</B> bridge.
25 * It therefore provides the methods
27 * <LI>{@link VeluxBridgeGetLimitation#getMinimumLimitation} for querying the lower limitation of an actuator,</LI>
28 * <LI>{@link VeluxBridgeGetLimitation#getMaximumLimitation} for querying the high limitation of an actuator.</LI>
31 * Any parameters are controlled by {@link org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration}.
33 * @see VeluxBridgeProvider
35 * @author Guenther Schreiner - Initial contribution
38 public class VeluxBridgeGetLimitation {
39 private final Logger logger = LoggerFactory.getLogger(VeluxBridgeGetLimitation.class);
43 private VeluxProductPosition limitationResult = VeluxProductPosition.UNKNOWN;
45 // Class access methods
48 * Login into bridge, instruct the bridge to pass a command towards an actuator based
49 * on a well-prepared environment of a {@link VeluxBridgeProvider}.
51 * @param bridge Initialized Velux bridge handler.
52 * @param nodeId Number of Actuator to be modified.
53 * @return true if successful, and false otherwise.
55 public boolean getMinimumLimitation(VeluxBridge bridge, int nodeId) {
56 logger.trace("getMinimumLimitation(nodeId={}) called.", nodeId);
58 boolean success = false;
59 GetProductLimitation bcp = bridge.bridgeAPI().getProductLimitation();
61 bcp.setActuatorIdAndLimitationType(nodeId, true);
62 if (bridge.bridgeCommunicate(bcp) && bcp.isCommunicationSuccessful()) {
64 limitationResult = new VeluxProductPosition(bcp.getLimitation());
67 logger.debug("getMinimumLimitation() finished {}.", (success ? "successfully" : "with failure"));
72 * Login into bridge, instruct the bridge to pass a command towards an actuator based
73 * on a well-prepared environment of a {@link VeluxBridgeProvider}.
75 * @param bridge Initialized Velux bridge handler.
76 * @param nodeId Number of Actuator to be modified.
77 * @return true if successful, and false otherwise.
79 public boolean getMaximumLimitation(VeluxBridge bridge, int nodeId) {
80 logger.trace("getMaximumLimitation(nodeId={}) called.", nodeId);
82 boolean success = false;
83 GetProductLimitation bcp = bridge.bridgeAPI().getProductLimitation();
85 bcp.setActuatorIdAndLimitationType(nodeId, false);
86 if (bridge.bridgeCommunicate(bcp) && bcp.isCommunicationSuccessful()) {
88 limitationResult = new VeluxProductPosition(bcp.getLimitation());
91 logger.debug("getMaximumLimitation() finished {}.", (success ? "successfully" : "with failure"));
96 * Return the limitation value.
98 * @return limitationResult of type VeluxProductPosition.
100 public VeluxProductPosition getLimitation() {
101 return limitationResult;