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.touchwand.internal;
15 import static org.openhab.binding.touchwand.internal.TouchWandBindingConstants.CHANNEL_SHUTTER;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.touchwand.internal.dto.TouchWandShutterSwitchUnitData;
19 import org.openhab.binding.touchwand.internal.dto.TouchWandUnitData;
20 import org.openhab.core.library.types.PercentType;
21 import org.openhab.core.thing.Thing;
22 import org.openhab.core.types.Command;
25 * The {@link TouchWandShutterHandler} is responsible for handling commands for Shutter units
27 * @author Roie Geron - Initial contribution
31 public class TouchWandShutterHandler extends TouchWandBaseUnitHandler {
33 public TouchWandShutterHandler(Thing thing) {
38 void touchWandUnitHandleCommand(Command command) {
39 TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
40 if (touchWandBridgeHandler != null) {
41 switch (command.toString()) {
44 touchWandBridgeHandler.touchWandClient.cmdShutterDown(unitId);
48 touchWandBridgeHandler.touchWandClient.cmdShutterUp(unitId);
51 touchWandBridgeHandler.touchWandClient.cmdShutterStop(unitId);
54 touchWandBridgeHandler.touchWandClient.cmdShutterPosition(unitId, command.toString());
61 void updateTouchWandUnitState(TouchWandUnitData unitData) {
62 if (unitData instanceof TouchWandShutterSwitchUnitData) {
63 int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
64 PercentType state = PercentType.ZERO;
65 int convertStatus = 100 - status;
66 state = new PercentType(convertStatus);
67 updateState(CHANNEL_SHUTTER, state);
69 logger.debug("updateTouchWandUnitState incompatible TouchWandUnitData instance");