Search in sources :

Example 11 with Bridge

use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.

the class HueGroupHandler method getHueClient.

@Nullable
protected synchronized HueClient getHueClient() {
    if (hueClient == null) {
        Bridge bridge = getBridge();
        if (bridge == null) {
            return null;
        }
        ThingHandler handler = bridge.getHandler();
        if (handler instanceof HueBridgeHandler) {
            HueClient bridgeHandler = (HueClient) handler;
            hueClient = bridgeHandler;
            bridgeHandler.registerGroupStatusListener(this);
        } else {
            return null;
        }
    }
    return hueClient;
}
Also used : ThingHandler(org.openhab.core.thing.binding.ThingHandler) BaseThingHandler(org.openhab.core.thing.binding.BaseThingHandler) Bridge(org.openhab.core.thing.Bridge) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 12 with Bridge

use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.

the class HueLightHandler method getHueClient.

@Nullable
protected synchronized HueClient getHueClient() {
    if (hueClient == null) {
        Bridge bridge = getBridge();
        if (bridge == null) {
            return null;
        }
        ThingHandler handler = bridge.getHandler();
        if (handler instanceof HueClient) {
            HueClient bridgeHandler = (HueClient) handler;
            hueClient = bridgeHandler;
            bridgeHandler.registerLightStatusListener(this);
        } else {
            return null;
        }
    }
    return hueClient;
}
Also used : ThingHandler(org.openhab.core.thing.binding.ThingHandler) BaseThingHandler(org.openhab.core.thing.binding.BaseThingHandler) Bridge(org.openhab.core.thing.Bridge) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 13 with Bridge

use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.

the class HueSensorHandler method initialize.

@Override
public void initialize() {
    logger.debug("Initializing hue sensor handler.");
    Bridge bridge = getBridge();
    initializeThing((bridge == null) ? null : bridge.getStatus());
}
Also used : Bridge(org.openhab.core.thing.Bridge)

Example 14 with Bridge

use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.

the class HueSensorHandler method getHueClient.

@Nullable
protected synchronized HueClient getHueClient() {
    if (hueClient == null) {
        Bridge bridge = getBridge();
        if (bridge == null) {
            return null;
        }
        ThingHandler handler = bridge.getHandler();
        if (handler instanceof HueBridgeHandler) {
            HueClient bridgeHandler = (HueClient) handler;
            hueClient = bridgeHandler;
            bridgeHandler.registerSensorStatusListener(this);
        } else {
            return null;
        }
    }
    return hueClient;
}
Also used : ThingHandler(org.openhab.core.thing.binding.ThingHandler) BaseThingHandler(org.openhab.core.thing.binding.BaseThingHandler) Bridge(org.openhab.core.thing.Bridge) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 15 with Bridge

use of org.openhab.core.thing.Bridge in project openhab-addons by openhab.

the class InnogyDeviceHandler method getInnogyBridgeHandler.

/**
 * Returns the innogy bridge handler.
 *
 * @return the {@link InnogyBridgeHandler} or null
 */
@Nullable
private InnogyBridgeHandler getInnogyBridgeHandler() {
    synchronized (this.lock) {
        if (this.bridgeHandler == null) {
            @Nullable final Bridge bridge = getBridge();
            if (bridge == null) {
                return null;
            }
            @Nullable final ThingHandler handler = bridge.getHandler();
            if (handler instanceof InnogyBridgeHandler) {
                this.bridgeHandler = (InnogyBridgeHandler) handler;
                this.bridgeHandler.registerDeviceStatusListener(this);
            } else {
                return null;
            }
        }
        return this.bridgeHandler;
    }
}
Also used : ThingHandler(org.openhab.core.thing.binding.ThingHandler) BaseThingHandler(org.openhab.core.thing.binding.BaseThingHandler) Nullable(org.eclipse.jdt.annotation.Nullable) Bridge(org.openhab.core.thing.Bridge) Nullable(org.eclipse.jdt.annotation.Nullable)

Aggregations

Bridge (org.openhab.core.thing.Bridge)394 Nullable (org.eclipse.jdt.annotation.Nullable)95 Thing (org.openhab.core.thing.Thing)69 ThingHandler (org.openhab.core.thing.binding.ThingHandler)68 Test (org.junit.jupiter.api.Test)54 Configuration (org.openhab.core.config.core.Configuration)54 ChannelUID (org.openhab.core.thing.ChannelUID)49 BaseThingHandler (org.openhab.core.thing.binding.BaseThingHandler)43 ThingUID (org.openhab.core.thing.ThingUID)39 ArrayList (java.util.ArrayList)36 Channel (org.openhab.core.thing.Channel)32 ThingTypeUID (org.openhab.core.thing.ThingTypeUID)30 ThingStatus (org.openhab.core.thing.ThingStatus)29 BridgeHandler (org.openhab.core.thing.binding.BridgeHandler)29 NonNullByDefault (org.eclipse.jdt.annotation.NonNullByDefault)25 RefreshType (org.openhab.core.types.RefreshType)22 List (java.util.List)20 BeforeEach (org.junit.jupiter.api.BeforeEach)20 JavaOSGiTest (org.openhab.core.test.java.JavaOSGiTest)19 Command (org.openhab.core.types.Command)18