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_DIMMER;
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.library.types.PercentType;
22 import org.openhab.core.thing.Thing;
23 import org.openhab.core.types.Command;
26 * The {@link TouchWandDimmerHandler} is responsible for handling commands for Dimmer units
28 * @author Roie Geron - Initial contribution
32 public class TouchWandDimmerHandler extends TouchWandBaseUnitHandler {
34 public TouchWandDimmerHandler(Thing thing) {
39 void touchWandUnitHandleCommand(Command command) {
40 TouchWandBridgeHandler touchWandBridgeHandler = bridgeHandler;
41 if (touchWandBridgeHandler != null) {
42 if (command instanceof OnOffType) {
43 touchWandBridgeHandler.touchWandClient.cmdSwitchOnOff(unitId, (OnOffType) command);
45 touchWandBridgeHandler.touchWandClient.cmdDimmerPosition(unitId, command.toString());
51 void updateTouchWandUnitState(TouchWandUnitData unitData) {
52 if (unitData instanceof TouchWandShutterSwitchUnitData) {
53 int status = ((TouchWandShutterSwitchUnitData) unitData).getCurrStatus();
54 PercentType state = PercentType.ZERO;
55 int convertStatus = status;
56 state = new PercentType(convertStatus);
57 updateState(CHANNEL_DIMMER, state);
59 logger.debug("updateTouchWandUnitState incompatible TouchWandUnitData instance");