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;
}
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);
}
}
}
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;
}
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);
}
}
}
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.");
}
Aggregations