2 * Copyright (c) 2010-2021 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.RunProductCommand;
17 import org.openhab.binding.velux.internal.things.VeluxProductPosition;
18 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory;
22 * The {@link VeluxBridgeRunProductCommand} represents a complete set of transactions
23 * for executing a scene defined on the <B>Velux</B> bridge.
25 * It provides a method {@link VeluxBridgeRunProductCommand#sendCommand} for sending a parameter change command.
26 * Any parameters are controlled by {@link org.openhab.binding.velux.internal.config.VeluxBridgeConfiguration}.
28 * @see VeluxBridgeProvider
30 * @author Guenther Schreiner - Initial contribution
33 public class VeluxBridgeRunProductCommand {
34 private final Logger logger = LoggerFactory.getLogger(VeluxBridgeRunProductCommand.class);
36 // Class access methods
39 * Login into bridge, instruct the bridge to pass a command towards an actuator based
40 * on a well-prepared environment of a {@link VeluxBridgeProvider}.
42 * @param bridge Initialized Velux bridge handler.
43 * @param nodeId Number of Actuator to be modified.
44 * @param value Target value for Actuator main parameter.
45 * @return true if successful, and false otherwise.
47 public boolean sendCommand(VeluxBridge bridge, int nodeId, VeluxProductPosition value) {
48 logger.trace("sendCommand(nodeId={},value={}) called.", nodeId, value);
50 boolean success = false;
51 RunProductCommand bcp = bridge.bridgeAPI().runProductCommand();
53 int veluxValue = value.getPositionAsVeluxType();
55 bcp.setNodeAndMainParameter(nodeId, veluxValue);
56 if (bridge.bridgeCommunicate(bcp) && bcp.isCommunicationSuccessful()) {
60 logger.debug("sendCommand() finished {}.", (success ? "successfully" : "with failure"));