Search in sources :

Example 21 with ThingUID

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

the class ThingConfigDescriptionAliasProvider method getThingConfigDescriptionURI.

@Nullable
private URI getThingConfigDescriptionURI(URI uri) {
    // First, get the thing type so we get the generic config descriptions
    ThingUID thingUID = new ThingUID(uri.getSchemeSpecificPart());
    Thing thing = thingRegistry.get(thingUID);
    if (thing == null) {
        return null;
    }
    ThingType thingType = thingTypeRegistry.getThingType(thing.getThingTypeUID());
    if (thingType == null) {
        return null;
    }
    // Get the config description URI for this thing type
    URI configURI = thingType.getConfigDescriptionURI();
    return configURI;
}
Also used : ThingUID(org.eclipse.smarthome.core.thing.ThingUID) ThingType(org.eclipse.smarthome.core.thing.type.ThingType) URI(java.net.URI) Thing(org.eclipse.smarthome.core.thing.Thing) Nullable(org.eclipse.jdt.annotation.Nullable)

Example 22 with ThingUID

use of org.eclipse.smarthome.core.thing.ThingUID 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 23 with ThingUID

use of org.eclipse.smarthome.core.thing.ThingUID 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 24 with ThingUID

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

the class FirmwareUpdateService method processFirmwareStatusInfo.

private synchronized void processFirmwareStatusInfo(FirmwareUpdateHandler firmwareUpdateHandler, FirmwareStatusInfo newFirmwareStatusInfo, Firmware latestFirmware) {
    ThingUID thingUID = firmwareUpdateHandler.getThing().getUID();
    FirmwareStatusInfo previousFirmwareStatusInfo = firmwareStatusInfoMap.put(thingUID, newFirmwareStatusInfo);
    if (previousFirmwareStatusInfo == null || !previousFirmwareStatusInfo.equals(newFirmwareStatusInfo)) {
        eventPublisher.post(FirmwareEventFactory.createFirmwareStatusInfoEvent(newFirmwareStatusInfo, thingUID));
        if (newFirmwareStatusInfo.getFirmwareStatus() == FirmwareStatus.UPDATE_AVAILABLE && firmwareUpdateHandler instanceof FirmwareUpdateBackgroundTransferHandler && !firmwareUpdateHandler.isUpdateExecutable()) {
            transferLatestFirmware((FirmwareUpdateBackgroundTransferHandler) firmwareUpdateHandler, latestFirmware, previousFirmwareStatusInfo);
        }
    }
}
Also used : FirmwareStatusInfo(org.eclipse.smarthome.core.thing.firmware.FirmwareStatusInfo) FirmwareUpdateBackgroundTransferHandler(org.eclipse.smarthome.core.thing.binding.firmware.FirmwareUpdateBackgroundTransferHandler) ThingUID(org.eclipse.smarthome.core.thing.ThingUID)

Example 25 with ThingUID

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

the class FirmwareUpdateConsoleCommandExtension method cancelUpdate.

private void cancelUpdate(Console console, String[] args) {
    if (args.length != 2) {
        console.println("Specify the thing id to cancel the update: firmware cancel <thingUID>");
        return;
    }
    ThingUID thingUID = new ThingUID(args[1]);
    FirmwareUpdateHandler firmwareUpdateHandler = getFirmwareUpdateHandler(thingUID);
    if (firmwareUpdateHandler == null) {
        console.println(String.format("No firmware update handler available for thing with UID %s.", thingUID));
        return;
    }
    firmwareUpdateService.cancelFirmwareUpdate(thingUID);
    console.println("Firmware update canceled.");
}
Also used : FirmwareUpdateHandler(org.eclipse.smarthome.core.thing.binding.firmware.FirmwareUpdateHandler) ThingUID(org.eclipse.smarthome.core.thing.ThingUID)

Aggregations

ThingUID (org.eclipse.smarthome.core.thing.ThingUID)99 DiscoveryResult (org.eclipse.smarthome.config.discovery.DiscoveryResult)29 ThingTypeUID (org.eclipse.smarthome.core.thing.ThingTypeUID)27 Thing (org.eclipse.smarthome.core.thing.Thing)26 Test (org.junit.Test)25 HashMap (java.util.HashMap)21 JavaOSGiTest (org.eclipse.smarthome.test.java.JavaOSGiTest)14 ApiOperation (io.swagger.annotations.ApiOperation)10 ApiResponses (io.swagger.annotations.ApiResponses)10 Path (javax.ws.rs.Path)9 JsonObject (com.google.gson.JsonObject)8 JsonParser (com.google.gson.JsonParser)7 RolesAllowed (javax.annotation.security.RolesAllowed)7 Locale (java.util.Locale)6 Nullable (org.eclipse.jdt.annotation.Nullable)6 Consumes (javax.ws.rs.Consumes)5 Configuration (org.eclipse.smarthome.config.core.Configuration)5 Collection (java.util.Collection)4 GET (javax.ws.rs.GET)4 InboxPredicates.forThingUID (org.eclipse.smarthome.config.discovery.inbox.InboxPredicates.forThingUID)4