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.lutron.internal.radiora.handler;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lutron.internal.radiora.protocol.RadioRAFeedback;
18 import org.openhab.core.thing.Bridge;
19 import org.openhab.core.thing.Thing;
20 import org.openhab.core.thing.ThingStatus;
21 import org.openhab.core.thing.ThingStatusDetail;
22 import org.openhab.core.thing.binding.BaseThingHandler;
23 import org.openhab.core.thing.binding.ThingHandler;
26 * Base class for non bridge handlers for Lutron RadioRA devices
28 * @author Jeff Lauterbach - Initial Contribution
32 public abstract class LutronHandler extends BaseThingHandler {
34 public LutronHandler(Thing thing) {
38 public @Nullable RS232Handler getRS232Handler() {
39 Bridge bridge = getBridge();
41 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.BRIDGE_UNINITIALIZED, "Unable to get bridge");
44 ThingHandler th = bridge.getHandler();
45 if (th instanceof RS232Handler) {
46 return (RS232Handler) th;
48 updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Bridge not properly configured.");
54 * Returns true if system numbers match, meaning that either both are 2 or both are 1 or 0 (n/a).
56 public static boolean systemsMatch(int a, int b) {
57 return ((a == 2 && b == 2) || ((a == 0 || a == 1) && (b == 0 || b == 1)));
60 public abstract void handleFeedback(RadioRAFeedback feedback);
63 public void initialize() {
64 updateStatus(ThingStatus.ONLINE);