]> git.basschouten.com Git - openhab-addons.git/blob
4298f3f400f7ec74949f596fe1dea2d5467bffb1
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2020 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.lutron.internal.radiora.handler;
14
15 import org.openhab.binding.lutron.internal.radiora.protocol.RadioRAFeedback;
16 import org.openhab.core.thing.Bridge;
17 import org.openhab.core.thing.Thing;
18 import org.openhab.core.thing.ThingStatus;
19 import org.openhab.core.thing.ThingStatusDetail;
20 import org.openhab.core.thing.binding.BaseThingHandler;
21 import org.openhab.core.thing.binding.ThingHandler;
22
23 /**
24  * Base class for non bridge handlers for Lutron RadioRA devices
25  *
26  * @author Jeff Lauterbach - Initial Contribution
27  *
28  */
29 public abstract class LutronHandler extends BaseThingHandler {
30
31     public LutronHandler(Thing thing) {
32         super(thing);
33     }
34
35     public RS232Handler getRS232Handler() {
36         Bridge bridge = getBridge();
37         if (bridge == null) {
38             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED, "Unable to get bridge");
39             return null;
40         }
41         ThingHandler th = bridge.getHandler();
42         if (th instanceof RS232Handler) {
43             return (RS232Handler) th;
44         } else {
45             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Bridge not properly configured.");
46             return null;
47         }
48     }
49
50     public abstract void handleFeedback(RadioRAFeedback feedback);
51 }