Search in sources :

Example 1 with BridgeHandler

use of org.eclipse.smarthome.core.thing.binding.BridgeHandler in project smarthome by eclipse.

the class BridgeImpl method getHandler.

@Override
public BridgeHandler getHandler() {
    BridgeHandler bridgeHandler = null;
    ThingHandler thingHandler = super.getHandler();
    if (thingHandler instanceof BridgeHandler) {
        bridgeHandler = (BridgeHandler) thingHandler;
    } else if (thingHandler != null) {
        logger.warn("Handler of bridge '{}' must implement BridgeHandler interface.", getUID());
    }
    return bridgeHandler;
}
Also used : BridgeHandler(org.eclipse.smarthome.core.thing.binding.BridgeHandler) ThingHandler(org.eclipse.smarthome.core.thing.binding.ThingHandler)

Example 2 with BridgeHandler

use of org.eclipse.smarthome.core.thing.binding.BridgeHandler in project smarthome by eclipse.

the class BeaconBluetoothHandler method initialize.

@Override
public void initialize() {
    try {
        address = new BluetoothAddress(getConfig().get(BluetoothBindingConstants.CONFIGURATION_ADDRESS).toString());
    } catch (IllegalArgumentException e) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, e.getLocalizedMessage());
        return;
    }
    Bridge bridge = getBridge();
    if (bridge == null) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Not associated with any bridge");
        return;
    }
    BridgeHandler bridgeHandler = bridge.getHandler();
    if (!(bridgeHandler instanceof BluetoothAdapter)) {
        updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "Associated with an unsupported bridge");
        return;
    }
    adapter = (BluetoothAdapter) bridgeHandler;
    try {
        deviceLock.lock();
        device = adapter.getDevice(address);
        device.addListener(this);
    } finally {
        deviceLock.unlock();
    }
    updateStatus(ThingStatus.UNKNOWN);
}
Also used : BridgeHandler(org.eclipse.smarthome.core.thing.binding.BridgeHandler) Bridge(org.eclipse.smarthome.core.thing.Bridge)

Aggregations

BridgeHandler (org.eclipse.smarthome.core.thing.binding.BridgeHandler)2 Bridge (org.eclipse.smarthome.core.thing.Bridge)1 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)1