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.*;
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.OnOffType;
21 import org.openhab.core.thing.Thing;
22 import org.openhab.core.types.Command;
25 * The {@link TouchWandSwitchHandler} is responsible for handling command for Switch unit
28 * @author Roie Geron - Initial contribution
32 public class TouchWandSwitchHandler extends TouchWandBaseUnitHandler {
34 public TouchWandSwitchHandler(Thing thing) {
39 void updateTouchWandUnitState(TouchWandUnitData unitData) {
40 if (unitData instanceof TouchWandShutterSwitchUnitData shutterSwitchUnitData) {
42 int status = shutterSwitchUnitData.getCurrStatus();
43 String sStatus = Integer.toString(status);
45 if (sStatus.equals(SWITCH_STATUS_OFF)) {
46 state = OnOffType.OFF;
47 } else if ((status >= 1) && (status <= 255)) {
50 logger.warn("updateTouchWandUnitState illegal update value {}", status);
53 updateState(CHANNEL_SWITCH, state);
55 logger.debug("updateTouchWandUnitState incompatible TouchWandUnitData instance");
60 void touchWandUnitHandleCommand(Command command) {
61 if (command instanceof OnOffType onOffCommand) {
62 TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
63 if (touchWandBridgeHandler != null) {
64 touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, onOffCommand);