2 * Copyright (c) 2010-2020 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.lutron.internal.radiora.handler;
15 import org.openhab.binding.lutron.internal.LutronBindingConstants;
16 import org.openhab.binding.lutron.internal.radiora.config.PhantomButtonConfig;
17 import org.openhab.binding.lutron.internal.radiora.protocol.ButtonPressCommand;
18 import org.openhab.binding.lutron.internal.radiora.protocol.LEDMapFeedback;
19 import org.openhab.binding.lutron.internal.radiora.protocol.RadioRAFeedback;
20 import org.openhab.core.library.types.OnOffType;
21 import org.openhab.core.thing.ChannelUID;
22 import org.openhab.core.thing.Thing;
23 import org.openhab.core.types.Command;
26 * Handler for RadioRA Phantom buttons
28 * @author Jeff Lauterbach - Initial Contribution
31 public class PhantomButtonHandler extends LutronHandler {
33 public PhantomButtonHandler(Thing thing) {
38 public void handleCommand(ChannelUID channelUID, Command command) {
39 if (channelUID.getId().equals(LutronBindingConstants.CHANNEL_SWITCH)) {
40 if (command instanceof OnOffType) {
41 ButtonPressCommand cmd = new ButtonPressCommand(
42 getConfigAs(PhantomButtonConfig.class).getButtonNumber(),
43 ButtonPressCommand.ButtonState.valueOf(command.toString()));
44 getRS232Handler().sendCommand(cmd);
50 public void handleFeedback(RadioRAFeedback feedback) {
51 if (feedback instanceof LEDMapFeedback) {
52 handleLEDMapFeedback((LEDMapFeedback) feedback);
56 private void handleLEDMapFeedback(LEDMapFeedback feedback) {
57 boolean zoneEnabled = feedback.getZoneValue(getConfigAs(PhantomButtonConfig.class).getButtonNumber()) == '1';
59 updateState(LutronBindingConstants.CHANNEL_SWITCH, zoneEnabled ? OnOffType.ON : OnOffType.OFF);