Search in sources :

Example 11 with Thing

use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.

the class ThingManager method unregisterAndDisposeChildHandlers.

private void unregisterAndDisposeChildHandlers(Bridge bridge, ThingHandlerFactory thingHandlerFactory) {
    addThingsToBridge(bridge);
    for (Thing child : bridge.getThings()) {
        ThingHandler handler = child.getHandler();
        if (handler != null) {
            logger.debug("Unregister and dispose child '{}' of bridge '{}'.", child.getUID(), bridge.getUID());
            unregisterAndDisposeHandler(thingHandlerFactory, child, handler);
        }
    }
}
Also used : ThingHandler(org.eclipse.smarthome.core.thing.binding.ThingHandler) Thing(org.eclipse.smarthome.core.thing.Thing)

Example 12 with Thing

use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.

the class ThingRegistryImpl method onRemoveElement.

@Override
protected void onRemoveElement(Thing thing) {
    // needed because the removed element was taken from the storage and lost its dynamic state
    preserveDynamicState(thing);
    ThingUID bridgeUID = thing.getBridgeUID();
    if (bridgeUID != null) {
        Thing bridge = this.get(bridgeUID);
        if (bridge instanceof BridgeImpl) {
            ((BridgeImpl) bridge).removeThing(thing);
        }
    }
}
Also used : ThingUID(org.eclipse.smarthome.core.thing.ThingUID) Thing(org.eclipse.smarthome.core.thing.Thing)

Example 13 with Thing

use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.

the class ThingRegistryImpl method getChannel.

@Override
public Channel getChannel(ChannelUID channelUID) {
    ThingUID thingUID = channelUID.getThingUID();
    Thing thing = get(thingUID);
    if (thing != null) {
        return thing.getChannel(channelUID.getId());
    }
    return null;
}
Also used : ThingUID(org.eclipse.smarthome.core.thing.ThingUID) Thing(org.eclipse.smarthome.core.thing.Thing)

Example 14 with Thing

use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.

the class ThingConsoleCommandExtension method removeAllThings.

private void removeAllThings(Console console, Collection<Thing> things) {
    int numberOfThings = things.size();
    for (Thing thing : things) {
        managedThingProvider.remove(thing.getUID());
    }
    console.println(numberOfThings + " things successfully removed.");
}
Also used : Thing(org.eclipse.smarthome.core.thing.Thing)

Example 15 with Thing

use of org.eclipse.smarthome.core.thing.Thing in project smarthome by eclipse.

the class ThingConsoleCommandExtension method printThings.

private void printThings(Console console, Collection<Thing> things) {
    if (things.isEmpty()) {
        console.println("No things found.");
    }
    for (Thing thing : things) {
        String id = thing.getUID().toString();
        String thingType = thing instanceof Bridge ? "Bridge" : "Thing";
        ThingStatusInfo status = thingStatusInfoI18nLocalizationService.getLocalizedThingStatusInfo(thing, null);
        ThingUID bridgeUID = thing.getBridgeUID();
        String label = thing.getLabel();
        console.println(String.format("%s (Type=%s, Status=%s, Label=%s, Bridge=%s)", id, thingType, status, label, bridgeUID));
    }
}
Also used : ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingStatusInfo(org.eclipse.smarthome.core.thing.ThingStatusInfo) Thing(org.eclipse.smarthome.core.thing.Thing) Bridge(org.eclipse.smarthome.core.thing.Bridge)

Aggregations

Thing (org.eclipse.smarthome.core.thing.Thing)98 Test (org.junit.Test)43 ThingUID (org.eclipse.smarthome.core.thing.ThingUID)28 ChannelUID (org.eclipse.smarthome.core.thing.ChannelUID)24 Configuration (org.eclipse.smarthome.config.core.Configuration)19 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)19 JavaTest (org.eclipse.smarthome.test.java.JavaTest)18 ThingHandler (org.eclipse.smarthome.core.thing.binding.ThingHandler)14 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)13 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 Item (org.eclipse.smarthome.core.items.Item)9 Path (javax.ws.rs.Path)8 Nullable (org.eclipse.jdt.annotation.Nullable)8 Locale (java.util.Locale)7 RolesAllowed (javax.annotation.security.RolesAllowed)7 Channel (org.eclipse.smarthome.core.thing.Channel)7 ThingHandlerCallback (org.eclipse.smarthome.core.thing.binding.ThingHandlerCallback)7 Command (org.eclipse.smarthome.core.types.Command)7 List (java.util.List)6