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.SetProductLimitation;
17 import org.openhab.binding.velux.internal.things.VeluxProductPosition;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * The {@link VeluxBridgeSetLimitation} represents a complete set of transactions
23 * for modifying the limitation of an actuator defined on the <B>Velux</B> bridge.
25 * It therefore provides the methods
27 * <LI>{@link VeluxBridgeSetLimitation#setMinimumLimitation} for modifying the lower limitation of an actuator,</LI>
28 * <LI>{@link VeluxBridgeSetLimitation#setMaximumLimitation} for modifying the high limitation of an actuator.</LI>
30 * Any parameters are controlled by {@link org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration}.
32 * @see VeluxBridgeProvider
34 * @author Guenther Schreiner - Initial contribution
37 public class VeluxBridgeSetLimitation {
38 private final Logger logger = LoggerFactory.getLogger(VeluxBridgeSetLimitation.class);
40 // Class access methods
43 * Login into bridge, modify the scene parameters and logout from bridge based
44 * on a well-prepared environment of a {@link VeluxBridgeProvider}.
46 * @param bridge Initialized Velux bridge handler.
47 * @param nodeId Number of Actuator to be modified.
48 * @param limitationMinimum new value for minimum limit.
49 * @return true if successful, and false otherwise.
51 public boolean setMinimumLimitation(VeluxBridge bridge, int nodeId, VeluxProductPosition limitationMinimum) {
52 logger.trace("setMinimumLimitation(nodeId={}, limitation={}) called.", nodeId, limitationMinimum);
54 SetProductLimitation bcp = bridge.bridgeAPI().setProductLimitation();
56 logger.info("setMinimumLimitation(): aborting processing as there is handler available.");
59 bcp.setActuatorIdAndMinimumLimitation(nodeId, limitationMinimum.getPositionAsVeluxType());
60 if (bridge.bridgeCommunicate(bcp) && bcp.isCommunicationSuccessful()) {
61 logger.trace("setMinimumLimitation() finished successfully.");
64 logger.trace("setMinimumLimitation() finished with failure.");
69 * Login into bridge, modify the scene parameters and logout from bridge based
70 * on a well-prepared environment of a {@link VeluxBridgeProvider}.
72 * @param bridge Initialized Velux bridge handler.
73 * @param nodeId Number of Actuator to be modified.
74 * @param limitationMaximum new value for maximum limit.
75 * @return true if successful, and false otherwise.
77 public boolean setMaximumLimitation(VeluxBridge bridge, int nodeId, VeluxProductPosition limitationMaximum) {
78 logger.trace("setMaximumLimitation(nodeId={}, limitation={}) called.", nodeId, limitationMaximum);
80 SetProductLimitation bcp = bridge.bridgeAPI().setProductLimitation();
82 logger.info("setMaximumLimitation(): aborting processing as there is handler available.");
85 bcp.setActuatorIdAndMaximumLimitation(nodeId, limitationMaximum.getPositionAsVeluxType());
86 if (bridge.bridgeCommunicate(bcp) && bcp.isCommunicationSuccessful()) {
87 logger.trace("setMaximumLimitation() finished successfully.");
90 logger.trace("setMaximumLimitation() finished with failure.");